zypp::PluginScript Class Reference

Interface to pluigin scripts using a Stomp inspired communication protocol. More...

#include <PluginScript.h>

List of all members.

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 Argumentsargs () 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.
Get/set local timeout settings.
long sendTimeout () const
 Local default timeout (sec.
long receiveTimeout () const
 Local default timeout (sec.
void sendTimeout (long newval_r)
 Set local default timeout (sec.
void receiveTimeout (long newval_r)
 Set local default timeout (sec.
void timeout (long newval_r)
 Set local default timeout (sec.

Static Public Member Functions

Get/set the global timeout settings.
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).

static long defaultSendTimeout ()
 Global default timeout (sec.
static long defaultReceiveTimeout ()
 Global default timeout (sec.
static void defaultSendTimeout (long newval_r)
 Set global default timeout (sec.
static void defaultReceiveTimeout (long newval_r)
 Set global default timeout (sec.
static void defaultTimeout (long newval_r)
 Set global default timeout (sec.

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)

Classes

struct  Impl
 PluginScript implementation. More...


Detailed Description

Interface to pluigin scripts using a Stomp inspired communication protocol.

Note:
PluginScript is copyable and assignable, but the connection is shared among multiple copies. It gets automatically closed if the last copy goes out of scope.
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();

See also:
http://stomp.codehaus.org/

Definition at line 62 of file PluginScript.h.


Member Typedef Documentation

typedef std::vector<std::string> zypp::PluginScript::Arguments

Commandline arguments passed to a script on open.

Definition at line 68 of file PluginScript.h.


Constructor & Destructor Documentation

zypp::PluginScript::PluginScript (  ) 

Default ctor.

Definition at line 460 of file PluginScript.cc.

zypp::PluginScript::PluginScript ( const Pathname &  script_r  ) 

Ctor taking script path and no arguments.

Definition at line 464 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 468 of file PluginScript.cc.


Member Function Documentation

long zypp::PluginScript::defaultSendTimeout (  )  [static]

Global default timeout (sec.

) when sending data.

Definition at line 436 of file PluginScript.cc.

References zypp::PluginScript::Impl::_defaultSendTimeout.

Referenced by defaultTimeout().

long zypp::PluginScript::defaultReceiveTimeout (  )  [static]

Global default timeout (sec.

) when receiving data.

Definition at line 439 of file PluginScript.cc.

References zypp::PluginScript::Impl::_defaultReceiveTimeout.

Referenced by defaultTimeout().

void zypp::PluginScript::defaultSendTimeout ( long  newval_r  )  [static]

Set global default timeout (sec.

) when sending data.

Definition at line 442 of file PluginScript.cc.

References zypp::PluginScript::Impl::_defaultSendTimeout.

void zypp::PluginScript::defaultReceiveTimeout ( long  newval_r  )  [static]

Set global default timeout (sec.

) when receiving data.

Definition at line 445 of file PluginScript.cc.

References zypp::PluginScript::Impl::_defaultReceiveTimeout.

static void zypp::PluginScript::defaultTimeout ( long  newval_r  )  [inline, static]

Set global default timeout (sec.

) (both: send and receive).

Definition at line 93 of file PluginScript.h.

References defaultReceiveTimeout(), and defaultSendTimeout().

const Pathname & zypp::PluginScript::script (  )  const

Return the script path if set.

Definition at line 472 of file PluginScript.cc.

References _pimpl.

const PluginScript::Arguments & zypp::PluginScript::args (  )  const

Return the script arguments if set.

Definition at line 475 of file PluginScript.cc.

References _pimpl.

bool zypp::PluginScript::isOpen (  )  const

Whether we are connected to a script.

Definition at line 478 of file PluginScript.cc.

References _pimpl.

pid_t zypp::PluginScript::getPid (  )  const

Return a connected scripts pid or NotConnected.

Definition at line 481 of file PluginScript.cc.

References _pimpl.

int zypp::PluginScript::lastReturn (  )  const

Remembers a scripts return value after close until next open.

Definition at line 484 of file PluginScript.cc.

References _pimpl.

const std::string & zypp::PluginScript::lastExecError (  )  const

Remembers a scripts execError string after close until next open.

See also:
ExternalProgram::execError.

Definition at line 487 of file PluginScript.cc.

References _pimpl.

long zypp::PluginScript::sendTimeout (  )  const

Local default timeout (sec.

) when sending data.

Definition at line 448 of file PluginScript.cc.

References _pimpl.

Referenced by timeout().

long zypp::PluginScript::receiveTimeout (  )  const

Local default timeout (sec.

) when receiving data.

Definition at line 451 of file PluginScript.cc.

References _pimpl.

Referenced by timeout().

void zypp::PluginScript::sendTimeout ( long  newval_r  ) 

Set local default timeout (sec.

) when sending data.

Definition at line 454 of file PluginScript.cc.

References _pimpl.

void zypp::PluginScript::receiveTimeout ( long  newval_r  ) 

Set local default timeout (sec.

) when receiving data.

Definition at line 457 of file PluginScript.cc.

References _pimpl.

void zypp::PluginScript::timeout ( long  newval_r  )  [inline]

Set local default timeout (sec.

) (both: send and receive).

Definition at line 144 of file PluginScript.h.

References receiveTimeout(), and sendTimeout().

void zypp::PluginScript::open (  ) 

Setup connection and execute script.

Exceptions:
PluginScriptException if already connected to a script
PluginScriptException if script does not exist or is not executable
PluginScriptException on error

Definition at line 490 of file PluginScript.cc.

References _pimpl.

Referenced by zypp::target::TargetImpl::buildCache(), and zypp::media::UrlResolverPlugin::resolveUrl().

void zypp::PluginScript::open ( const Pathname &  script_r  ) 

Definition at line 493 of file PluginScript.cc.

References _pimpl.

void zypp::PluginScript::open ( const Pathname &  script_r,
const Arguments args_r 
)

Definition at line 496 of file PluginScript.cc.

References _pimpl.

int zypp::PluginScript::close (  ) 

Close any open connection.

Definition at line 499 of file PluginScript.cc.

References _pimpl.

void zypp::PluginScript::send ( const PluginFrame frame_r  )  const

Send a PluginFrame.

Exceptions:
PluginScriptNotConnected 
PluginScriptSendTimeout 
PluginScriptDiedUnexpectedly (does not close)
PluginScriptException on error

Definition at line 502 of file PluginScript.cc.

References _pimpl.

Referenced by zypp::target::TargetImpl::buildCache(), and zypp::media::UrlResolverPlugin::resolveUrl().

PluginFrame zypp::PluginScript::receive (  )  const

Receive a PluginFrame.

Exceptions:
PluginScriptNotConnected 
PluginScriptReceiveTimeout 
PluginScriptDiedUnexpectedly (does not close)
PluginScriptException on error

Definition at line 505 of file PluginScript.cc.

References _pimpl.

Referenced by zypp::target::TargetImpl::buildCache(), and zypp::media::UrlResolverPlugin::resolveUrl().


Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  str,
const PluginScript obj 
) [friend]

Stream output

Definition at line 510 of file PluginScript.cc.


Member Data Documentation

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().

Pointer to implementation.

Definition at line 185 of file PluginScript.h.

Referenced by args(), close(), getPid(), isOpen(), lastExecError(), lastReturn(), open(), zypp::operator<<(), receive(), receiveTimeout(), script(), send(), and sendTimeout().


The documentation for this class was generated from the following files:

Generated on Tue May 5 14:49:24 2015 for libzypp by  doxygen 1.5.6