libzypp  10.5.0
PluginScript.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_PLUGINSCRIPT_H
00013 #define ZYPP_PLUGINSCRIPT_H
00014 
00015 #include <iosfwd>
00016 #include <string>
00017 #include <vector>
00018 
00019 #include "zypp/base/PtrTypes.h"
00020 #include "zypp/Pathname.h"
00021 
00022 #include "zypp/PluginFrame.h"
00023 #include "zypp/PluginScriptException.h"
00024 
00026 namespace zypp
00027 { 
00028 
00062   class PluginScript
00063   {
00064     friend std::ostream & operator<<( std::ostream & str, const PluginScript & obj );
00065 
00066     public:
00068       typedef std::vector<std::string> Arguments;
00069 
00071       static const pid_t NotConnected;
00072 
00073     public:
00081         static long defaultSendTimeout();
00082 
00084         static long defaultReceiveTimeout();
00085 
00087         static void defaultSendTimeout( long newval_r );
00088 
00090         static void defaultReceiveTimeout( long newval_r );
00091 
00093         static void defaultTimeout( long newval_r )
00094         { defaultSendTimeout( newval_r ); defaultReceiveTimeout( newval_r ); }
00096 
00097     public:
00099       PluginScript();
00100 
00102       PluginScript( const Pathname & script_r );
00103 
00105       PluginScript( const Pathname & script_r, const Arguments & args_r );
00106 
00107     public:
00109       const Pathname & script() const;
00110 
00112       const Arguments & args() const;
00113 
00115       bool isOpen() const;
00116 
00118       pid_t getPid() const;
00119 
00121       int lastReturn() const;
00122 
00126       const std::string & lastExecError() const;
00127 
00128      public:
00132         long sendTimeout() const;
00133 
00135         long receiveTimeout() const;
00136 
00138         void sendTimeout( long newval_r );
00139 
00141         void receiveTimeout( long newval_r );
00142 
00144         void timeout( long newval_r )
00145         { sendTimeout( newval_r ); receiveTimeout( newval_r ); }
00147 
00148    public:
00154       void open();
00155 
00157       void open( const Pathname & script_r );
00158 
00160       void open( const Pathname & script_r, const Arguments & args_r );
00161 
00163       int close();
00164 
00165     public:
00173       void send( const PluginFrame & frame_r ) const;
00174 
00181       PluginFrame receive() const;
00182 
00183     public:
00185       class Impl;
00186     private:
00188       RW_pointer<Impl> _pimpl;
00189   };
00190 
00192   std::ostream & operator<<( std::ostream & str, const PluginScript & obj );
00193 
00195 } // namespace zypp
00197 #endif // ZYPP_PLUGINSCRIPT_H