1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/PluginExecutor.h
11 #ifndef ZYPP_PLUGINEXECUTOR_H
12 #define ZYPP_PLUGINEXECUTOR_H
16 #include "zypp/base/PtrTypes.h"
17 #include "zypp/PluginScript.h"
19 ///////////////////////////////////////////////////////////////////
22 ///////////////////////////////////////////////////////////////////
23 /// \class PluginExecutor
24 /// \brief Parallel execution of stateful PluginScripts
26 /// Sent PluginFrames are distributed to all open PluginScripts and
27 /// need to be receipted by sending back either \c ACK or \c _ENOMETHOD
30 /// All PluginScripts receive an initial \c PLUGINBEGIN frame, containing
31 /// a \c userdata header if \ref ZConfig::userData are defined.
32 /// \see also zypper '--userdata' option
34 /// A final \c PLUGINEND frame is sent and open scripts are closed, when the
35 /// executors last reference goes out of scope. Failing PluginScripts are
36 /// closed immediately.
40 ///////////////////////////////////////////////////////////////////
43 friend std::ostream & operator<<( std::ostream & str, const PluginExecutor & obj );
44 friend bool operator==( const PluginExecutor & lhs, const PluginExecutor & rhs );
47 /** Default ctor: Empty plugin list */
50 /** Dtor: Send \c PLUGINEND and close all plugins */
54 /** Validate object in a boolean context: There are plugins waiting for input */
55 explicit operator bool() const
58 /** Whether no plugins are waiting */
61 /** Number of open plugins */
65 /** Find and launch plugins sending \c PLUGINBEGIN.
67 * If \a path_r is a directory all executable files within are
68 * expected to be plugins. Otherwise \a path_r must point to an
71 void load( const Pathname & path_r );
73 /** Send \ref PluginFrame to all open plugins.
74 * Failed plugins are removed from the execution list.
76 void send( const PluginFrame & frame_r );
79 class Impl; ///< Implementation class.
81 RW_pointer<Impl> _pimpl; ///< Pointer to implementation.
84 /** \relates PluginExecutor Stream output */
85 std::ostream & operator<<( std::ostream & str, const PluginExecutor & obj );
87 /** \relates PluginExecutor Comparison based on reference. */
88 inline bool operator==( const PluginExecutor & lhs, const PluginExecutor & rhs )
89 { return ( lhs._pimpl == rhs._pimpl ); }
91 /** \relates PluginExecutor Comparison based on reference. */
92 inline bool operator!=( const PluginExecutor & lhs, const PluginExecutor & rhs )
93 { return( ! operator==( lhs, rhs ) ); }
96 ///////////////////////////////////////////////////////////////////
97 #endif // ZYPP_PLUGINEXECUTOR_H