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

#include <Y2Function.h>

Inheritance diagram for Y2Function:
Y2StdioFunction Y2SystemFunction Y2YCPFunction

Public Member Functions

virtual ~Y2Function ()
 
virtual bool attachParameter (const YCPValue &arg, const int position)=0
 
virtual constTypePtr wantedParameterType () const =0
 
virtual bool appendParameter (const YCPValue &arg)=0
 
virtual bool finishParameters ()=0
 
virtual YCPValue evaluateCall ()=0
 
virtual bool reset ()=0
 
virtual string name () const =0
 

Detailed Description

A function call interface. It is an abstract base for providing an interface for calling a function inside YaST. Any Y2 namespace can provide its own implementation for calling functions provided by the namespace. Typically returned value by Y2Namespace::createFunctionCall ("funcname", function_type).

an example to call Popup::Message()
first, find out the component for the namespace
Y2Component* impl = Y2ComponentBroker::provideNamespace ("Popup");
if (impl != 0)
{
let the component import the namespace
    Y2Namespace* ns = impl->import ("Popup");
    if (ns != 0)
    {
create a function call object for the function
        Y2Function* fnc = ns->createFunctionCall ("Message"
            , Type::fromSignature ("void (string)"));
        if (fnc != 0)
        {
pass the parameter for the function
            fnc->appendParameter (YCPString ("This is my test"));
            fnc->finishParameters ();
evaluate the call
            fnc->evaluateCall ();
function is not longer needed, free it
            delete fnc;
        }
    }
} 

Constructor & Destructor Documentation

virtual Y2Function::~Y2Function ( )
inlinevirtual

Whithout this, can't delete YEFunction which is derived from YCode, Y2Function

Member Function Documentation

virtual bool Y2Function::appendParameter ( const YCPValue arg)
pure virtual

Appends a parameter to the call.

Returns
false if there was a type mismatch

Implemented in Y2YCPFunction, Y2SystemFunction, and Y2StdioFunction.

Referenced by Y2SystemFunction::appendParameter().

virtual bool Y2Function::attachParameter ( const YCPValue arg,
const int  position 
)
pure virtual

Attaches a parameter to a given position to the call.

Returns
false if there was a type mismatch

Implemented in Y2YCPFunction, Y2SystemFunction, and Y2StdioFunction.

Referenced by Y2SystemFunction::attachParameter(), YEFunction::evaluate(), and YEFunctionPointer::evaluate().

virtual YCPValue Y2Function::evaluateCall ( )
pure virtual
virtual bool Y2Function::finishParameters ( )
pure virtual

Signal that we're done adding parameters.

Returns
false if there was a parameter missing

Implemented in Y2YCPFunction, Y2SystemFunction, and Y2StdioFunction.

Referenced by Y2SystemFunction::finishParameters().

virtual string Y2Function::name ( ) const
pure virtual
virtual bool Y2Function::reset ( )
pure virtual

Reset the current parameters, so the instance can be reused for the next call (appendParameter etc)

Returns
false if reset failed

Implemented in Y2YCPFunction, Y2SystemFunction, and Y2StdioFunction.

Referenced by YEFunction::evaluate(), YEFunctionPointer::evaluate(), and Y2SystemFunction::reset().

virtual constTypePtr Y2Function::wantedParameterType ( ) const
pure virtual

What type is expected for the next appendParameter (val) ? (Used when calling from Perl, to be able to convert from the simple type system of Perl to the elaborate type system of YCP)

Returns
Type::Any if number of parameters exceeded

Implemented in Y2YCPFunction, Y2SystemFunction, and Y2StdioFunction.

Referenced by Y2SystemFunction::wantedParameterType().


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

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