libzypp 17.38.7
PluginScript.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_PLUGINSCRIPT_H
13#define ZYPP_PLUGINSCRIPT_H
14
15#include <iosfwd>
16#include <string>
17#include <vector>
18
20#include <zypp-core/Pathname.h>
21
24
26namespace zypp
27{
28
63 {
64 friend std::ostream & operator<<( std::ostream & str, const PluginScript & obj );
65
66 public:
68 using Arguments = std::vector<std::string>;
69
71 static const pid_t NotConnected;
72
73 public:
80
81 static long defaultSendTimeout();
82
84 static long defaultReceiveTimeout();
85
87 static void defaultSendTimeout( long newval_r );
88
90 static void defaultReceiveTimeout( long newval_r );
91
93 static void defaultTimeout( long newval_r )
94 { defaultSendTimeout( newval_r ); defaultReceiveTimeout( newval_r ); }
95
96
97 public:
100
102 PluginScript( Pathname script_r );
103
105 PluginScript( Pathname script_r, Arguments args_r );
106
107 public:
109 const Pathname & script() const;
110
112 const Arguments & args() const;
113
115 bool isOpen() const;
116
118 pid_t getPid() const;
119
121 int lastReturn() const;
122
126 const std::string & lastExecError() const;
127
128 public:
131
132 long sendTimeout() const;
133
135 long receiveTimeout() const;
136
138 void sendTimeout( long newval_r );
139
141 void receiveTimeout( long newval_r );
142
144 void timeout( long newval_r )
145 { sendTimeout( newval_r ); receiveTimeout( newval_r ); }
146
147
148 public:
154 void open();
155
157 void open( const Pathname & script_r );
158
160 void open( const Pathname & script_r, const Arguments & args_r );
161
165 void open( const Pathname & script_r, const Pathname & chroot_r );
166
170 void open( const Pathname & script_r, const Arguments & args_r, const Pathname & chroot_r );
171
179 void openChrooted( const Pathname & chroot_r );
180
182 int close();
183
184 public:
192 void send( const PluginFrame & frame_r ) const;
193
200 PluginFrame receive() const;
201
202 public:
204 struct Impl;
205 private:
208 };
209
211 std::ostream & operator<<( std::ostream & str, const PluginScript & obj );
212
214} // namespace zypp
216#endif // ZYPP_PLUGINSCRIPT_H
Command frame for communication with PluginScript.
Definition PluginFrame.h:42
Interface to plugin scripts using a Stomp inspired communication protocol.
PluginFrame receive() const
Receive a PluginFrame.
friend std::ostream & operator<<(std::ostream &str, const PluginScript &obj)
relates: PluginScript Stream output
std::vector< std::string > Arguments
Commandline arguments passed to a script on open.
void openChrooted(const Pathname &chroot_r)
Like open() but runs the script chrooted into chroot_r.
long sendTimeout() const
Local default timeout (sec.) when sending data.
void send(const PluginFrame &frame_r) const
Send a PluginFrame.
PluginScript()
Default ctor.
RW_pointer< Impl > _pimpl
Pointer to implementation.
int lastReturn() const
Remembers a scripts return value after close until next open.
static long defaultReceiveTimeout()
Global default timeout (sec.) when receiving data.
static const pid_t NotConnected
pid_t(-1) constant indicating no connection.
int close()
Close any open connection.
const std::string & lastExecError() const
Remembers a scripts execError string after close until next open.
void timeout(long newval_r)
Set local default timeout (sec.) (both: send and receive).
pid_t getPid() const
Return a connected scripts pid or NotConnected.
void open()
Setup connection and execute script.
static void defaultTimeout(long newval_r)
Set global default timeout (sec.) (both: send and receive).
const Pathname & script() const
Return the script path if set.
static long defaultSendTimeout()
Global default timeout (sec.) when sending data.
bool isOpen() const
Whether we are connected to a script.
long receiveTimeout() const
Local default timeout (sec.) when receiving data.
const Arguments & args() const
Return the script arguments if set.
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293