libzypp 17.38.15

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
19#include <zypp-core/base/PtrTypes.h>
20#include <zypp-core/Pathname.h>
21
22#include <zypp-core/rpc/PluginFrame.h>
23#include <zypp/PluginScriptException.h>
24
26 namespace zypp
27{
28
62 class PluginScript
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:
99 PluginScript();
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 Pathname getChroot() const;
122
124 int lastReturn() const;
125
129 const std::string & lastExecError() const;
130
131 public:
134
135 long sendTimeout() const;
136
138 long receiveTimeout() const;
139
141 void sendTimeout( long newval_r );
142
144 void receiveTimeout( long newval_r );
145
147 void timeout( long newval_r )
148 { sendTimeout( newval_r ); receiveTimeout( newval_r ); }
149
150
151 public:
157 void open();
158
160 void open( const Pathname & script_r );
161
163 void open( const Pathname & script_r, const Arguments & args_r );
164
168 void open( const Pathname & script_r, const Pathname & chroot_r );
169
173 void open( const Pathname & script_r, const Arguments & args_r, const Pathname & chroot_r );
174
182 void openChrooted( const Pathname & chroot_r );
183
185 int close();
186
187 public:
195 void send( const PluginFrame & frame_r ) const;
196
203 PluginFrame receive() const;
204
205 public:
207 struct Impl;
208 private:
210 RW_pointer<Impl> _pimpl;
211 };
212
214 std::ostream & operator<<( std::ostream & str, const PluginScript & obj );
215
217} // namespace zypp
219#endif // ZYPP_PLUGINSCRIPT_H
Pathname.h
PluginFrame.h
PluginScriptException.h
PtrTypes.h
Impl
zypp::PluginFrame
Command frame for communication with PluginScript.
Definition PluginFrame.h:42
zypp::PluginScript
Interface to plugin scripts using a Stomp inspired communication protocol.
Definition PluginScript.h:63
zypp::PluginScript::receive
PluginFrame receive() const
Receive a PluginFrame.
Definition PluginScript.cc:556
zypp::PluginScript::operator<<
friend std::ostream & operator<<(std::ostream &str, const PluginScript &obj)
relates: PluginScript Stream output
Definition PluginScript.cc:561
zypp::PluginScript::Arguments
std::vector< std::string > Arguments
Commandline arguments passed to a script on open.
Definition PluginScript.h:68
zypp::PluginScript::getChroot
Pathname getChroot() const
Return a connected scripts chroot or an empty Pathname.
Definition PluginScript.cc:523
zypp::PluginScript::openChrooted
void openChrooted(const Pathname &chroot_r)
Like open() but runs the script chrooted into chroot_r.
Definition PluginScript.cc:547
zypp::PluginScript::sendTimeout
long sendTimeout() const
Local default timeout (sec.) when sending data.
Definition PluginScript.cc:487
zypp::PluginScript::send
void send(const PluginFrame &frame_r) const
Send a PluginFrame.
Definition PluginScript.cc:553
zypp::PluginScript::PluginScript
PluginScript()
Default ctor.
Definition PluginScript.cc:499
zypp::PluginScript::_pimpl
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition PluginScript.h:210
zypp::PluginScript::lastReturn
int lastReturn() const
Remembers a scripts return value after close until next open.
Definition PluginScript.cc:526
zypp::PluginScript::defaultReceiveTimeout
static long defaultReceiveTimeout()
Global default timeout (sec.) when receiving data.
Definition PluginScript.cc:478
zypp::PluginScript::NotConnected
static const pid_t NotConnected
pid_t(-1) constant indicating no connection.
Definition PluginScript.h:71
zypp::PluginScript::close
int close()
Close any open connection.
Definition PluginScript.cc:550
zypp::PluginScript::lastExecError
const std::string & lastExecError() const
Remembers a scripts execError string after close until next open.
Definition PluginScript.cc:529
zypp::PluginScript::timeout
void timeout(long newval_r)
Set local default timeout (sec.) (both: send and receive).
Definition PluginScript.h:147
zypp::PluginScript::getPid
pid_t getPid() const
Return a connected scripts pid or NotConnected.
Definition PluginScript.cc:520
zypp::PluginScript::open
void open()
Setup connection and execute script.
Definition PluginScript.cc:532
zypp::PluginScript::defaultTimeout
static void defaultTimeout(long newval_r)
Set global default timeout (sec.) (both: send and receive).
Definition PluginScript.h:93
zypp::PluginScript::script
const Pathname & script() const
Return the script path if set.
Definition PluginScript.cc:511
zypp::PluginScript::defaultSendTimeout
static long defaultSendTimeout()
Global default timeout (sec.) when sending data.
Definition PluginScript.cc:475
zypp::PluginScript::isOpen
bool isOpen() const
Whether we are connected to a script.
Definition PluginScript.cc:517
zypp::PluginScript::receiveTimeout
long receiveTimeout() const
Local default timeout (sec.) when receiving data.
Definition PluginScript.cc:490
zypp::PluginScript::args
const Arguments & args() const
Return the script arguments if set.
Definition PluginScript.cc:514
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
Definition Capabilities.cc:65
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293