Interface to a component via stdio. More...
#include <Y2StdioComponent.h>
Public Member Functions | |
| Y2StdioComponent (bool is_server, bool to_stderr, bool in_batchmode=false) | |
| ~Y2StdioComponent () | |
| string | name () const |
| YCPValue | evaluate (const YCPValue &command) |
| void | result (const YCPValue &result) |
| void | setServerOptions (int argc, char **argv) |
| YCPValue | doActualWork (const YCPList &arglist, Y2Component *user_interface) |
Private Member Functions | |
| void | send (const YCPValue &v) const |
| YCPValue | receive () |
Private Attributes | |
| const bool | is_server |
| bool | to_stderr |
| bool | batchmode |
| Parser | parser |
Interface to a component via stdio.
| Y2StdioComponent::Y2StdioComponent | ( | bool | is_server, | |
| bool | to_stderr, | |||
| bool | in_batchmode = false | |||
| ) |
Creates a new cat/stdio component.
| to_stderr,: | give true, if stderr should be used instead of stdout. |
| Y2StdioComponent::~Y2StdioComponent | ( | ) |
Cleans up
| YCPValue Y2StdioComponent::doActualWork | ( | const YCPList & | arglist, | |
| Y2Component * | user_interface | |||
| ) | [virtual] |
Here the client does its actual work.
| arglist | YCPList of client arguments. | |
| user_interface | Option display server (user interface) |
This method is only defined, if the component is a client.
Reimplemented from Y2Component.
References Parser::atEOF(), Y2Component::evaluate(), YCPElement::isNull(), parser, receive(), send(), and y2warning.
Defined only for the "cat" component: Prints a command to stdout and waits for the answer on stdin.
Reimplemented from Y2Component.
References batchmode, is_server, YCPElement::isNull(), receive(), send(), and y2error.
| string Y2StdioComponent::name | ( | ) | const [virtual] |
Returns "cat", if this is a server, or "stdio" if it's a module.
Implements Y2Component.
| YCPValue Y2StdioComponent::receive | ( | ) | [private] |
Reads one YCP value from stdin. Return 0 if no one could be read.
References YCPElement::isNull(), Parser::parse(), parser, and y2debug.
Referenced by doActualWork(), and evaluate().
| void Y2StdioComponent::result | ( | const YCPValue & | result | ) | [virtual] |
Defined only for the "cat" component: Prints result(..result..) on stdout.
Reimplemented from Y2Component.
References YCPTerm::add(), and send().
| void Y2StdioComponent::send | ( | const YCPValue & | v | ) | const [private] |
Sends a YCP value to stdout.
References YCPElement::isNull(), to_stderr, and y2debug.
Referenced by doActualWork(), evaluate(), and result().
| void Y2StdioComponent::setServerOptions | ( | int | argc, | |
| char ** | argv | |||
| ) | [virtual] |
Sets the commandline options of the server. Server options for the cat server are simply ignored.
This method is only defined, if the component is a server.
Reimplemented from Y2Component.
bool Y2StdioComponent::batchmode [private] |
If true, we're running in batchmode (i.e testsuite) As a client (called via doActualWork()) nothing changes As a server (called via evaluate()) no input is read
Referenced by evaluate(), and name().
const bool Y2StdioComponent::is_server [private] |
It this component a server or a client?
Referenced by evaluate().
Parser Y2StdioComponent::parser [private] |
Parser used to parse stdin
Referenced by doActualWork(), and receive().
bool Y2StdioComponent::to_stderr [private] |
1.6.3