The JShell clas can be used to interact with the shell via I/O streams.
More...
#include <JShell.hh>
|
void | execute (const char *path, const char *arg0, const char *arg1=(char *) NULL, const char *arg2=(char *) NULL, const char *arg3=(char *) NULL, const char *arg4=(char *) NULL, const char *arg5=(char *) NULL, const char *arg6=(char *) NULL, const char *arg7=(char *) NULL, const char *arg8=(char *) NULL, const char *arg9=(char *) NULL) |
| Execute command. More...
|
|
virtual int_type | underflow () override |
| Check underflow. More...
|
|
bool | in_avail (JTimeval timeout=JTimeval::min()) const |
| Check availability of input. More...
|
|
virtual int_type | overflow (int_type c) override |
| Check overflow. More...
|
|
virtual int | sync () override |
| Synchronise buffer. More...
|
|
bool | out_avail (JTimeval timeout=JTimeval::min()) const |
| Check availability of output. More...
|
|
int | flush () |
| Flush internal buffer. More...
|
|
The JShell clas can be used to interact with the shell via I/O streams.
Definition at line 32 of file JShell.hh.
JSYSTEM::JShell::JShell |
( |
const std::size_t |
size = 65536 | ) |
|
|
inline |
Constructor.
- Parameters
-
size | size of internal buffer |
Definition at line 47 of file JShell.hh.
55 static_cast<ostream&
>(*this) <<
"set prompt=" <<
prompt << endl;
56 static_cast<ostream&
>(*this) <<
"echo hello" << endl;
int flush()
Flush internal buffer.
JFileStream(const JAbstractFile &in, const JAbstractFile &out, const std::size_t size=65536)
Constructor.
JProcess()
Default constructor.
JSYSTEM::JShell::~JShell |
( |
| ) |
|
|
inline |
Destructor.
Definition at line 65 of file JShell.hh.
void exit()
Exit this shell.
JSYSTEM::JShell::JShell |
( |
const JShell & |
| ) |
|
|
private |
JSYSTEM::JShell::JShell |
( |
JShell && |
| ) |
|
|
private |
static JShell& JSYSTEM::JShell::getInstance |
( |
| ) |
|
|
inlinestatic |
Get reference to unique instance of this class object.
- Returns
- reference to this class object
Definition at line 76 of file JShell.hh.
The JShell clas can be used to interact with the shell via I/O streams.
const std::string& JSYSTEM::JShell::getPrompt |
( |
| ) |
const |
|
inline |
Get prompt.
- Returns
- prompt
Definition at line 89 of file JShell.hh.
template<class T >
bool JSYSTEM::JShell::get |
( |
T & |
value | ) |
|
|
inline |
Get value.
Note that
- in case of success, the input stream is flushed; and
- in case of failure, the input stream is cleared and flushed.
- Parameters
-
- Returns
- true if valid; else false
Definition at line 106 of file JShell.hh.
110 if (*
this >> value) {
118 static_cast<istream&
>(*this).clear();
int flush()
Flush internal buffer.
bool JSYSTEM::JShell::getline |
( |
std::string & |
buffer, |
|
|
const char |
eol = '\n' |
|
) |
| |
|
inline |
Get line of text.
Extracts characters from this shell and stores them into the given buffer until the end of line character is found or the prompt is read.
- Parameters
-
buffer | buffer |
eol | end of line character |
- Returns
- true if valid; else false
Definition at line 137 of file JShell.hh.
145 const int c = this->
get();
147 if (c == streambuf::traits_type::eof()) {
149 return !buffer.empty();
151 }
else if (c == eol) {
159 if (buffer.size() >=
prompt.size()) {
161 const size_t pos = buffer.size() - this->
prompt.size();
163 if (buffer.substr(pos) == this->
prompt) {
167 return !buffer.empty();
virtual bool getStatus() const override
Get status of this shell.
$WORKDIR ev_configure_dqsimulator txt echo process $DQ_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DQ_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
JShell& JSYSTEM::JShell::flush |
( |
std::ostream & |
out = null | ) |
|
|
inline |
Extracts characters from this shell and flush them to the given output stream until the prompt is read.
- Parameters
-
- Returns
- this shell
Definition at line 184 of file JShell.hh.
188 for (
string buffer; this->
getline(buffer); ) {
189 out << buffer << endl;
bool getline(std::string &buffer, const char eol= '\n')
Get line of text.
virtual bool JSYSTEM::JShell::getStatus |
( |
| ) |
const |
|
inlineoverridevirtual |
Get status of this shell.
- Returns
- status of this shell
Implements JLANG::JAbstractObjectStatus.
Definition at line 201 of file JShell.hh.
203 return ((
bool) static_cast<const std::ostream&>(*
this) &&
204 (
bool) static_cast<const std::istream&>(*
this));
void JSYSTEM::JShell::exit |
( |
| ) |
|
|
inline |
Exit this shell.
Definition at line 211 of file JShell.hh.
215 static_cast<ostream&
>(*this) <<
"exit" << endl;
Get pointer to input stream buffer connected to the normal output stream.
- Parameters
-
size | size of internal buffers |
- Returns
- pointer input stream buffer
Definition at line 86 of file JProcess.hh.
89 gOut =
new JFileInputStreamBuffer(
out, size);
JFileInputStreamBuffer * gOut
Get pointer to input stream buffer connected to the error output stream.
- Parameters
-
size | size of internal buffers |
- Returns
- pointer to input stream buffer
Definition at line 102 of file JProcess.hh.
105 gErr =
new JFileInputStreamBuffer(
err, size);
JFileInputStreamBuffer * gErr
Get pointer to output stream buffer connected to the normal input stream.
- Parameters
-
size | size of internal buffers |
- Returns
- pointer to output stream buffer
Definition at line 118 of file JProcess.hh.
121 gIn =
new JFileOutputStreamBuffer(
in, size);
JFileOutputStreamBuffer * gIn
void JSYSTEM::JProcess::execute |
( |
const char * |
path, |
|
|
const char * |
arg0, |
|
|
const char * |
arg1 = (char*) NULL , |
|
|
const char * |
arg2 = (char*) NULL , |
|
|
const char * |
arg3 = (char*) NULL , |
|
|
const char * |
arg4 = (char*) NULL , |
|
|
const char * |
arg5 = (char*) NULL , |
|
|
const char * |
arg6 = (char*) NULL , |
|
|
const char * |
arg7 = (char*) NULL , |
|
|
const char * |
arg8 = (char*) NULL , |
|
|
const char * |
arg9 = (char*) NULL |
|
) |
| |
|
inlineprotectedinherited |
Execute command.
- Parameters
-
path | path |
arg0 | comma separted argument list |
arg1 | comma separted argument list |
arg2 | comma separted argument list |
arg3 | comma separted argument list |
arg4 | comma separted argument list |
arg5 | comma separted argument list |
arg6 | comma separted argument list |
arg7 | comma separted argument list |
arg8 | comma separted argument list |
arg9 | comma separted argument list |
Definition at line 143 of file JProcess.hh.
159 if (pipe(pipe_stdin)) {
THROW(JPipeOpenException,
"Error at pipe of standard input."); }
160 if (pipe(pipe_stdout)) {
THROW(JPipeOpenException,
"Error at pipe of standard output."); }
161 if (pipe(pipe_stderr)) {
THROW(JPipeOpenException,
"Error at pipe of standard error."); }
163 const pid_t pid = fork();
169 THROW(JForkException,
"JProcess::fork() failed");
175 close(pipe_stdin [1]);
176 if (dup2 (pipe_stdin [0], STDIN_FILENO) == -1) { JSystemException(
"dup2-stdin"); }
178 close(pipe_stdout[0]);
179 if (dup2 (pipe_stdout[1], STDOUT_FILENO) == -1) { JSystemException(
"dup2-stdout"); }
181 close(pipe_stdout[0]);
182 if (dup2 (pipe_stdout[1], STDERR_FILENO) == -1) { JSystemException(
"dup2-stderr"); }
184 execl(
path, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, (
char*) NULL);
193 out = pipe_stdout[0];
194 err = pipe_stderr[0];
196 close(pipe_stdin [0]);
197 close(pipe_stdout[1]);
198 close(pipe_stderr[1]);
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
void close(std::istream *pf)
Close file.
$WORKDIR driver txt done cat $WORKDIR driver txt<< EOFprocess ${DATAFILTER}$FILTER_HOST csh-c '(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&(JDataFilter-H\$SERVER\$-M\$LOGGER\$-d $DEBUG-u ${DATAFILTER}-P $PORT</dev/null > &/dev/null &))';process ${DATAWRITER}$WRITER_HOST csh-c '(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&(JDataWriter-H\$SERVER\$-M\$LOGGER\$-d $DEBUG-u ${DATAWRITER}</dev/null > &/dev/null &))';print enterevent ev_init{RC_CMD}event ev_reset{RC_CMD}event ev_init{RC_CMD}event ev_configure{RC_DFLTR%<$WORKDIR/ev_configure_datafilter.txt > RC_DQSIM<$WORKDIR/ev_configure_dqsimulator.txt > RC_DWRT path
virtual int_type JLANG::JFileInputStreamBuffer::underflow |
( |
| ) |
|
|
inlineoverridevirtualinherited |
Check underflow.
This method reads as many bytes as possible.
- Returns
- first character if OK; else EOF
Definition at line 60 of file JFileStreamBuffer.hh.
62 if (gptr() >= egptr()) {
64 char* __begin = this->
data();
66 if (eback() == __begin) {
75 const size_t len =
in.
read(__begin, this->size() - (__begin - this->
data()));
78 setg(this->
data(), __begin, __begin + len);
80 return traits_type::eof();
virtual int read(char *buffer, const int length)
Read data from file.
Check availability of input.
This method returns true if at least one byte can be read without blocking.
- Parameters
-
- Returns
- true if ready to read; else false
Definition at line 94 of file JFileStreamBuffer.hh.
Auxiliary class for method select.
bool in_avail(JTimeval timeout=JTimeval::min())
Check availability of input.
|
inlineoverridevirtualinherited |
Check overflow.
This method writes one byte if possible.
- Parameters
-
- Returns
- c if OK; else EOF
Definition at line 159 of file JFileStreamBuffer.hh.
161 if (
c != traits_type::eof()) {
167 if (
flush() == traits_type::eof()) {
168 return traits_type::eof();
int flush()
Flush internal buffer.
$WORKDIR ev_configure_dqsimulator txt echo process $DQ_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DQ_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
virtual int JLANG::JFileOutputStreamBuffer::sync |
( |
| ) |
|
|
inlineoverridevirtualinherited |
Synchronise buffer.
Definition at line 179 of file JFileStreamBuffer.hh.
181 if (
flush() == traits_type::eof())
int flush()
Flush internal buffer.
Check availability of output.
This method returns true if at least one byte can be written without blocking.
- Parameters
-
- Returns
- true if ready to write; else false
Definition at line 195 of file JFileStreamBuffer.hh.
bool out_avail(JTimeval timeout=JTimeval::min())
Check availability of output.
Auxiliary class for method select.
int JLANG::JFileOutputStreamBuffer::flush |
( |
| ) |
|
|
inlineprotectedinherited |
Flush internal buffer.
Definition at line 204 of file JFileStreamBuffer.hh.
206 const int len = pptr() - pbase();
211 return traits_type::eof();
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn this
virtual int write(const char *buffer, const int length)
Write data to file.
JLANG::JAbstractObjectStatus::operator bool |
( |
| ) |
const |
|
inlineinherited |
Type conversion operator.
- Returns
- status of this object
Definition at line 33 of file JAbstractObjectStatus.hh.
virtual bool getStatus() const =0
Get status of object.
bool JLANG::JAbstractObjectStatus::operator! |
( |
| ) |
const |
|
inlineinherited |
Negated status of this object.
- Returns
- negated status of this object
Definition at line 44 of file JAbstractObjectStatus.hh.
virtual bool getStatus() const =0
Get status of object.
int JSYSTEM::JProcess::out |
|
protectedinherited |
int JSYSTEM::JProcess::err |
|
protectedinherited |
int JSYSTEM::JProcess::in |
|
protectedinherited |
JFile JLANG::JFileInputStreamBuffer::in |
|
protectedinherited |
std::size_t JLANG::JFileInputStreamBuffer::memory |
|
protectedinherited |
JFile JLANG::JFileOutputStreamBuffer::out |
|
protectedinherited |
The documentation for this class was generated from the following file: