|
libzypp
9.1.2
|
Interface to pluigin scripts using a Stomp inspired communication protocol.
More...
#include <PluginScript.h>
Classes | |
| struct | Impl |
| PluginScript implementation. More... | |
Public Types | |
| typedef std::vector< std::string > | Arguments |
| Commandline arguments passed to a script on open. | |
Public Member Functions | |
| PluginScript () | |
| Default ctor. | |
| PluginScript (const Pathname &script_r) | |
| Ctor taking script path and no arguments. | |
| PluginScript (const Pathname &script_r, const Arguments &args_r) | |
| Ctor taking script path and script arguments. | |
| const Pathname & | script () const |
| Return the script path if set. | |
| const Arguments & | args () const |
| Return the script arguments if set. | |
| bool | isOpen () const |
| Whether we are connected to a script. | |
| pid_t | getPid () const |
| Return a connected scripts pid or NotConnected. | |
| int | lastReturn () const |
| Remembers a scripts return value after close until next open. | |
| const std::string & | lastExecError () const |
| Remembers a scripts execError string after close until next open. | |
| void | open () |
| Setup connection and execute script. | |
| void | open (const Pathname &script_r) |
| void | open (const Pathname &script_r, const Arguments &args_r) |
| int | close () |
| Close any open connection. | |
| void | send (const PluginFrame &frame_r) const |
| Send a PluginFrame. | |
| PluginFrame | receive () const |
| Receive a PluginFrame. | |
Static Public Attributes | |
| static const pid_t | NotConnected |
pid_t(-1) constant indicating no connection. | |
Private Attributes | |
| RW_pointer< Impl > | _pimpl |
| Pointer to implementation. | |
Friends | |
| std::ostream & | operator<< (std::ostream &str, const PluginScript &obj) |
Related Functions | |
(Note that these are not member functions.) | |
| std::ostream & | operator<< (std::ostream &str, const PluginScript &obj) |
Interface to pluigin scripts using a Stomp inspired communication protocol.
Timeout when sending/receiving data to/from a plugin default to 30 sec. The value (in seconds) my be changed via the environment variables ZYPP_PLUGIN_SEND_TIMEOUT, ZYPP_PLUGIN_RECEIVE_TIMEOUT or ZYPP_PLUGIN_TIMEOUT (both: send and receive).
// Setup comnnection to plugin script PluginScript scr; PluginScript::Arguments args; args.push_back( "-v" ); scr.open( "/soem/testplugin", args ); // send frame to plugin PluginFrame f( "COMMAND" ); f.setHeader( "key", "value" ); f.setBody( "some\ndata" ); scr.send( f ); // receive frame from plugin PluginFrame r( scr.receive() ); // explicitly close or let PluginScript go out of scope scr.close();
Definition at line 62 of file PluginScript.h.
| typedef std::vector<std::string> zypp::PluginScript::Arguments |
Commandline arguments passed to a script on open.
Definition at line 68 of file PluginScript.h.
Default ctor.
Definition at line 412 of file PluginScript.cc.
| zypp::PluginScript::PluginScript | ( | const Pathname & | script_r | ) |
Ctor taking script path and no arguments.
Definition at line 416 of file PluginScript.cc.
| zypp::PluginScript::PluginScript | ( | const Pathname & | script_r, |
| const Arguments & | args_r | ||
| ) |
Ctor taking script path and script arguments.
Definition at line 420 of file PluginScript.cc.
| const Pathname & zypp::PluginScript::script | ( | ) | const |
Return the script path if set.
Definition at line 424 of file PluginScript.cc.
References _pimpl, and zypp::PluginScript::Impl::script().
| const PluginScript::Arguments & zypp::PluginScript::args | ( | ) | const |
Return the script arguments if set.
Definition at line 427 of file PluginScript.cc.
References _pimpl, and zypp::PluginScript::Impl::args().
| bool zypp::PluginScript::isOpen | ( | ) | const |
Whether we are connected to a script.
Definition at line 430 of file PluginScript.cc.
References _pimpl, and zypp::PluginScript::Impl::isOpen().
| pid_t zypp::PluginScript::getPid | ( | ) | const |
Return a connected scripts pid or NotConnected.
Definition at line 433 of file PluginScript.cc.
References _pimpl, and zypp::PluginScript::Impl::getPid().
| int zypp::PluginScript::lastReturn | ( | ) | const |
Remembers a scripts return value after close until next open.
Definition at line 436 of file PluginScript.cc.
References _pimpl, and zypp::PluginScript::Impl::lastReturn().
| const std::string & zypp::PluginScript::lastExecError | ( | ) | const |
Remembers a scripts execError string after close until next open.
Definition at line 439 of file PluginScript.cc.
References _pimpl, and zypp::PluginScript::Impl::lastExecError().
| void zypp::PluginScript::open | ( | ) |
Setup connection and execute script.
| PluginScriptException | if already connected to a script |
| PluginScriptException | if script does not exist or is not executable |
| PluginScriptException | on error |
Definition at line 442 of file PluginScript.cc.
References _pimpl, zypp::PluginScript::Impl::args(), zypp::PluginScript::Impl::open(), and zypp::PluginScript::Impl::script().
Referenced by zypp::target::TargetImpl::buildCache(), and zypp::media::UrlResolverPlugin::resolveUrl().
| void zypp::PluginScript::open | ( | const Pathname & | script_r | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 445 of file PluginScript.cc.
References _pimpl, and zypp::PluginScript::Impl::open().
| void zypp::PluginScript::open | ( | const Pathname & | script_r, |
| const Arguments & | args_r | ||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 448 of file PluginScript.cc.
References _pimpl, and zypp::PluginScript::Impl::open().
| int zypp::PluginScript::close | ( | ) |
Close any open connection.
Definition at line 451 of file PluginScript.cc.
References _pimpl, and zypp::PluginScript::Impl::close().
| void zypp::PluginScript::send | ( | const PluginFrame & | frame_r | ) | const |
Send a PluginFrame.
| PluginScriptNotConnected | |
| PluginScriptSendTimeout | |
| PluginScriptDiedUnexpectedly | (does not close) |
| PluginScriptException | on error |
Definition at line 454 of file PluginScript.cc.
References _pimpl, and zypp::PluginScript::Impl::send().
Referenced by zypp::target::TargetImpl::buildCache(), and zypp::media::UrlResolverPlugin::resolveUrl().
| PluginFrame zypp::PluginScript::receive | ( | ) | const |
Receive a PluginFrame.
| PluginScriptNotConnected | |
| PluginScriptReceiveTimeout | |
| PluginScriptDiedUnexpectedly | (does not close) |
| PluginScriptException | on error |
Definition at line 457 of file PluginScript.cc.
References _pimpl, and zypp::PluginScript::Impl::receive().
Referenced by zypp::target::TargetImpl::buildCache(), and zypp::media::UrlResolverPlugin::resolveUrl().
| std::ostream& operator<< | ( | std::ostream & | str, |
| const PluginScript & | obj | ||
| ) | [friend] |
Definition at line 462 of file PluginScript.cc.
| std::ostream & operator<< | ( | std::ostream & | str, |
| const PluginScript & | obj | ||
| ) | [related] |
Stream output
Definition at line 462 of file PluginScript.cc.
const pid_t zypp::PluginScript::NotConnected [static] |
pid_t(-1) constant indicating no connection.
Definition at line 71 of file PluginScript.h.
Referenced by zypp::PluginScript::Impl::getPid().
RW_pointer<Impl> zypp::PluginScript::_pimpl [private] |
Pointer to implementation.
Definition at line 141 of file PluginScript.h.
Referenced by args(), close(), getPid(), isOpen(), lastExecError(), lastReturn(), open(), zypp::operator<<(), receive(), script(), and send().
1.7.6.1