yast2-core
Public Member Functions | List of all members
Y2Component Class Referenceabstract

Communication handle to a YaST2 component. More...

#include <Y2Component.h>

Inheritance diagram for Y2Component:
TestY2Component TestY2Component TestY2Component Y2AgentComp< Agent > Y2AgentComp< ScriptingAgent > Y2ErrorComponent Y2IniAgentComponent Y2PluginComponent Y2ProgramComponent Y2SerialComponent Y2StdioComponent Y2WFMComponent

Public Member Functions

 Y2Component ()
 
virtual ~Y2Component ()
 
virtual string name () const =0
 
virtual YCPValue evaluate (const YCPValue &command)
 
virtual void result (const YCPValue &result)
 
virtual void setServerOptions (int argc, char **argv)
 
virtual Y2Namespaceimport (const char *name_space)
 
virtual YCPValue doActualWork (const YCPList &arglist, Y2Component *user_interface)
 
virtual SCRAgentgetSCRAgent ()
 
virtual bool remote () const
 

Detailed Description

Communication handle to a YaST2 component.

See Also
componentbroker
Y2ComponentBroker

YaST2 is a network oriented client/server architecture. Currently there exist five differnt types of components: userinterfaces, modules, the workflowmanagers, the repository (scr) and scr agents. All components are communicating using the same protocol.

The communication between two components is asymmetric. On component is said to be the server, the other to be the client. The protocol begins with the client sending an YCPValueRep, the command to the server. The server evaluates it and returns an YCPValueRep, the answer. Now the client sends the next command and so on. When the client has finished the work with the server, it sends a result value to the server and both sides close the connection. The result is a special YCPValueRep that is a term with the symbol "result" and exactly one argument.

Each component may be realized by a binary program (under Linux: ELF), by a process listening to an internet-domain socket, by a shared library plugin in ELF format (ending in .so), by a YCP script that is executed by the Workflowmanager (WFM), or by a C++ class that is linked to the Generic YaST2 Frontend (GF).

When you want to implement a component you need to subclass Y2Component and define the virtual functions (some of them only for a client component, some of them only for a server component). Furthermore you need to subclass Y2ComponentCreator and create a global variable from this class.

When you implement a component that needs the services of another component then you ask the Y2ComponentBroker to get a handle to it. That handle is of type Y2Component. Once you have got the handle, you can use it communicate with the component, regardless whether it is realized by a program, a plugin or what so ever.

See Y2ComponentBroker for examples.

Constructor & Destructor Documentation

Y2Component::Y2Component ( )
Y2Component::~Y2Component ( )
virtual

Base class must have virtual destructor.

Member Function Documentation

YCPValue Y2Component::doActualWork ( const YCPList arglist,
Y2Component user_interface 
)
virtual

This function must be overridden by an actual client. Here the client does its actual work.

Parameters
arglistYCPList of client arguments.
user_interfaceOption display server (user interface) Most clients need interaction with the user. The different YaST2 user interfaces are servers. If the user interace is already active and running, give a handle to it with this parameter. Give 0 here if no user interface is running yet and either the module launches the user interace itself or it it does not need one.
Returns
The result value (exit code) of the called client. The result code has not yet been sent to the display server. Destroy it after use.

This method is only defined, if the component is a client.

Reimplemented in Y2ProgramComponent, Y2PluginComponent, Y2SerialComponent, Y2StdioComponent, and Y2WFMComponent.

References name(), and y2internal.

Referenced by Y2WFMComponent::CallFunction(), Y2PluginComponent::doActualWork(), and main().

YCPValue Y2Component::evaluate ( const YCPValue command)
virtual

Starts the server, if it is not already started and does what a server is good for: Gets a command, evaluates (or executes) it and returns the result.

Parameters
commandThe command to be executed. Any YCPValueRep can be executed. The execution is performed by some YCPInterpreter.
Returns
the result. Destroy it after use with YCPElementRep::destroy.

This method is only defined, if the component is a server.

Reimplemented in Y2ProgramComponent, Y2PluginComponent, Y2SerialComponent, Y2StdioComponent, Y2IniAgentComponent, Y2AgentComp< Agent >, and Y2AgentComp< ScriptingAgent >.

References name(), and y2internal.

Referenced by Y2StdioComponent::doActualWork(), Y2SerialComponent::doActualWork(), Y2ProgramComponent::doActualWork(), Y2PluginComponent::evaluate(), main(), and SCRSubAgent::mount().

SCRAgent * Y2Component::getSCRAgent ( )
virtual

Returns the SCRAgent of the Y2Component or NULL, if it doesn't have one. Note: This might trigger the creation of the Interpreter and Agent associated with the Y2Component. For plugins, this might trigger the loading of the plugin as well.

Reimplemented in Y2PluginComponent, Y2AgentComp< Agent >, and Y2AgentComp< ScriptingAgent >.

Referenced by WFMSubAgent::agent(), Y2PluginComponent::getSCRAgent(), and SCRSubAgent::mount().

Y2Namespace * Y2Component::import ( const char *  name_space)
virtual

Try to import a given namespace. This method is used for transparent handling of namespaces (YCP modules) through whole YaST. NOTICE: there is no reverse operation to import. Semantics of YCP modules is there is a single instance and it is available from the first import until the end of YaST run.

Parameters
name_spacethe name of the required namespace
Returns
on errors, NULL should be returned. The error reporting must be done by the component itself (typically using y2log). On success, the method should return a proper instance of the imported namespace ready to be used. The returned instance is still owned by the component, any other part of YaST will try to free it. Thus, it's possible to share the instance.

Reimplemented in Y2PluginComponent, Y2WFMComponent, TestY2Component, TestY2Component, and TestY2Component.

References y2internal.

Referenced by Debugger::findSymbol(), Import::import(), and Y2PluginComponent::import().

virtual string Y2Component::name ( ) const
pure virtual
bool Y2Component::remote ( ) const
virtual

Reimplemented in Y2ProgramComponent.

void Y2Component::result ( const YCPValue result)
virtual

Tells this server, that the client doesn't need it's services any longer and that the exit code of the client is result.

This method is only defined, if the component is a server.

Reimplemented in Y2ProgramComponent, Y2PluginComponent, Y2SerialComponent, and Y2StdioComponent.

Referenced by Y2WFMComponent::CallFunction(), main(), Y2WFMComponent::SetArgs(), and Y2PluginComponent::~Y2PluginComponent().

void Y2Component::setServerOptions ( int  argc,
char **  argv 
)
virtual

Sets the commandline options of the server.

Parameters
argcnumber of arguments including argv[0], the name of the component
argva pointer to a field of argc+1 char *, where the last one must be 0. The caller of the function must assure that the data field is persistent. This method will not make a copy of it.

This method is only defined, if the component is a server.

Reimplemented in Y2ProgramComponent, Y2PluginComponent, Y2SerialComponent, and Y2StdioComponent.

Referenced by Y2PluginComponent::loadPlugin(), main(), and Y2PluginComponent::setServerOptions().


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

Generated on a sunny day for yast2-core by doxygen 1.8.6