Web Analytics Made Easy - Statcounter
Skip to content

Class SBCClassFunction#

ClassList > SBCClassFunction

This class describes a class function in a class proxy. More...

  • #include "SBCClassFunction.hpp"

Inherited by the following classes: SBCClassConstFunction0< void, Class >, SBCClassConstFunction1< void, Class, T0 >, SBCClassConstFunction10< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, SBCClassConstFunction11< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 >, SBCClassConstFunction12< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 >, SBCClassConstFunction13< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 >, SBCClassConstFunction14< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 >, SBCClassConstFunction15< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 >, SBCClassConstFunction16< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 >, SBCClassConstFunction2< void, Class, T0, T1 >, SBCClassConstFunction3< void, Class, T0, T1, T2 >, SBCClassConstFunction4< void, Class, T0, T1, T2, T3 >, SBCClassConstFunction5< void, Class, T0, T1, T2, T3, T4 >, SBCClassConstFunction6< void, Class, T0, T1, T2, T3, T4, T5 >, SBCClassConstFunction7< void, Class, T0, T1, T2, T3, T4, T5, T6 >, SBCClassConstFunction8< void, Class, T0, T1, T2, T3, T4, T5, T6, T7 >, SBCClassConstFunction9< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8 >, SBCClassFunction0< void, Class >, SBCClassFunction1< void, Class, T0 >, SBCClassFunction10< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, SBCClassFunction11< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 >, SBCClassFunction12< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 >, SBCClassFunction13< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 >, SBCClassFunction14< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 >, SBCClassFunction15< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 >, SBCClassFunction16< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 >, SBCClassFunction2< void, Class, T0, T1 >, SBCClassFunction3< void, Class, T0, T1, T2 >, SBCClassFunction4< void, Class, T0, T1, T2, T3 >, SBCClassFunction5< void, Class, T0, T1, T2, T3, T4 >, SBCClassFunction6< void, Class, T0, T1, T2, T3, T4, T5 >, SBCClassFunction7< void, Class, T0, T1, T2, T3, T4, T5, T6 >, SBCClassFunction8< void, Class, T0, T1, T2, T3, T4, T5, T6, T7 >, SBCClassFunction9< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8 >, SBCClassStaticFunction0< void >, SBCClassStaticFunction1< void, T0 >, SBCClassStaticFunction10< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, SBCClassStaticFunction11< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 >, SBCClassStaticFunction12< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 >, SBCClassStaticFunction13< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 >, SBCClassStaticFunction14< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 >, SBCClassStaticFunction15< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 >, SBCClassStaticFunction16< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 >, SBCClassStaticFunction2< void, T0, T1 >, SBCClassStaticFunction3< void, T0, T1, T2 >, SBCClassStaticFunction4< void, T0, T1, T2, T3 >, SBCClassStaticFunction5< void, T0, T1, T2, T3, T4 >, SBCClassStaticFunction6< void, T0, T1, T2, T3, T4, T5 >, SBCClassStaticFunction7< void, T0, T1, T2, T3, T4, T5, T6 >, SBCClassStaticFunction8< void, T0, T1, T2, T3, T4, T5, T6, T7 >, SBCClassStaticFunction9< void, T0, T1, T2, T3, T4, T5, T6, T7, T8 >, SBCClassConstFunction0, SBCClassConstFunction0< void, Class >, SBCClassConstFunction1, SBCClassConstFunction10, SBCClassConstFunction10< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, SBCClassConstFunction11, SBCClassConstFunction11< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 >, SBCClassConstFunction12, SBCClassConstFunction12< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 >, SBCClassConstFunction13, SBCClassConstFunction13< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 >, SBCClassConstFunction14, SBCClassConstFunction14< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 >, SBCClassConstFunction15, SBCClassConstFunction15< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 >, SBCClassConstFunction16, SBCClassConstFunction16< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 >, SBCClassConstFunction1< void, Class, T0 >, SBCClassConstFunction2, SBCClassConstFunction2< void, Class, T0, T1 >, SBCClassConstFunction3, SBCClassConstFunction3< void, Class, T0, T1, T2 >, SBCClassConstFunction4, SBCClassConstFunction4< void, Class, T0, T1, T2, T3 >, SBCClassConstFunction5, SBCClassConstFunction5< void, Class, T0, T1, T2, T3, T4 >, SBCClassConstFunction6, SBCClassConstFunction6< void, Class, T0, T1, T2, T3, T4, T5 >, SBCClassConstFunction7, SBCClassConstFunction7< void, Class, T0, T1, T2, T3, T4, T5, T6 >, SBCClassConstFunction8, SBCClassConstFunction8< void, Class, T0, T1, T2, T3, T4, T5, T6, T7 >, SBCClassConstFunction9, SBCClassConstFunction9< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8 >, SBCClassFunction0, SBCClassFunction0< void, Class >, SBCClassFunction1, SBCClassFunction10, SBCClassFunction10< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, SBCClassFunction11, SBCClassFunction11< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 >, SBCClassFunction12, SBCClassFunction12< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 >, SBCClassFunction13, SBCClassFunction13< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 >, SBCClassFunction14, SBCClassFunction14< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 >, SBCClassFunction15, SBCClassFunction15< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 >, SBCClassFunction16, SBCClassFunction16< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 >, SBCClassFunction1< void, Class, T0 >, SBCClassFunction2, SBCClassFunction2< void, Class, T0, T1 >, SBCClassFunction3, SBCClassFunction3< void, Class, T0, T1, T2 >, SBCClassFunction4, SBCClassFunction4< void, Class, T0, T1, T2, T3 >, SBCClassFunction5, SBCClassFunction5< void, Class, T0, T1, T2, T3, T4 >, SBCClassFunction6, SBCClassFunction6< void, Class, T0, T1, T2, T3, T4, T5 >, SBCClassFunction7, SBCClassFunction7< void, Class, T0, T1, T2, T3, T4, T5, T6 >, SBCClassFunction8, SBCClassFunction8< void, Class, T0, T1, T2, T3, T4, T5, T6, T7 >, SBCClassFunction9, SBCClassFunction9< void, Class, T0, T1, T2, T3, T4, T5, T6, T7, T8 >, SBCClassStaticFunction0, SBCClassStaticFunction0< void >, SBCClassStaticFunction1, SBCClassStaticFunction10, SBCClassStaticFunction10< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, SBCClassStaticFunction11, SBCClassStaticFunction11< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 >, SBCClassStaticFunction12, SBCClassStaticFunction12< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 >, SBCClassStaticFunction13, SBCClassStaticFunction13< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12 >, SBCClassStaticFunction14, SBCClassStaticFunction14< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13 >, SBCClassStaticFunction15, SBCClassStaticFunction15< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14 >, SBCClassStaticFunction16, SBCClassStaticFunction16< void, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 >, SBCClassStaticFunction1< void, T0 >, SBCClassStaticFunction2, SBCClassStaticFunction2< void, T0, T1 >, SBCClassStaticFunction3, SBCClassStaticFunction3< void, T0, T1, T2 >, SBCClassStaticFunction4, SBCClassStaticFunction4< void, T0, T1, T2, T3 >, SBCClassStaticFunction5, SBCClassStaticFunction5< void, T0, T1, T2, T3, T4 >, SBCClassStaticFunction6, SBCClassStaticFunction6< void, T0, T1, T2, T3, T4, T5 >, SBCClassStaticFunction7, SBCClassStaticFunction7< void, T0, T1, T2, T3, T4, T5, T6 >, SBCClassStaticFunction8, SBCClassStaticFunction8< void, T0, T1, T2, T3, T4, T5, T6, T7 >, SBCClassStaticFunction9, SBCClassStaticFunction9< void, T0, T1, T2, T3, T4, T5, T6, T7, T8 >

Public Functions#

Type Name
SBCClassFunction ()
Constructs a class function.
virtual SBValue call (const SBValue & object, const SBValue & t0=SBValue(), const SBValue & t1=SBValue(), const SBValue & t2=SBValue(), const SBValue & t3=SBValue(), const SBValue & t4=SBValue(), const SBValue & t5=SBValue(), const SBValue & t6=SBValue(), const SBValue & t7=SBValue(), const SBValue & t8=SBValue(), const SBValue & t9=SBValue(), const SBValue & t10=SBValue(), const SBValue & t11=SBValue(), const SBValue & t12=SBValue(), const SBValue & t13=SBValue(), const SBValue & t14=SBValue(), const SBValue & t15=SBValue()) const
Calls the function for the specific object with argumentst0 ,t1 , ...,t15 .
virtual bool canCall (const SBValue & t0=SBValue(), const SBValue & t1=SBValue(), const SBValue & t2=SBValue(), const SBValue & t3=SBValue(), const SBValue & t4=SBValue(), const SBValue & t5=SBValue(), const SBValue & t6=SBValue(), const SBValue & t7=SBValue(), const SBValue & t8=SBValue(), const SBValue & t9=SBValue(), const SBValue & t10=SBValue(), const SBValue & t11=SBValue(), const SBValue & t12=SBValue(), const SBValue & t13=SBValue(), const SBValue & t14=SBValue(), const SBValue & t15=SBValue()) const
Returns true if and only if the function can be called with argumentst0 ,t1 , ...,t15 .
virtual std::string getName () const = 0
Returns the name of the function.
virtual unsigned int getNumberOfParameters () noexcept const = 0
Returns the number of parameters of the function.
virtual std::string getOutputType () const = 0
Returns the output type of the function.
virtual SBValue getParameterType (int i) const = 0
Returns the parameter type of the function parameter i .
virtual std::string getParameterTypeName (int i) const = 0
Returns the parameter type name of the function parameter i .
virtual bool isConstFunction () noexcept const = 0
Returns true if and only if the function is a const function.
virtual bool isStaticFunction () noexcept const = 0
Returns true if and only if the function is a static function.
virtual std::string signature () const = 0
Returns the signature of the function.
virtual ~SBCClassFunction ()
Destructs the class function.

Detailed Description#

A class function object is a functor that provides access to a SAMSON Extension function that has been exposed through a class descriptor (see Introspection).

Assume for example a SAMSON Extension contains the following class:

class A {

SB_CLASS

public:

    A() {}
    virtual ~A() {}

    int multiplyByTwo(int i) {

        return 2 * i;

    }

};

SB_REGISTER_TYPE(A, "A", "BF99103E-06FE-C4C1-D929-4C6E833B101C");
as well as the following class descriptor:
SB_CLASS_BEGIN(A);

    SB_CLASS_TYPE(SBCClass::App);
    SB_CLASS_DESCRIPTION("Integer multiplier");

    SB_FACTORY_BEGIN;

        SB_CONSTRUCTOR_0(A);

    SB_FACTORY_END;

    SB_INTERFACE_BEGIN;

        SB_FUNCTION_1(int, A, multiplyByTwo, int);

    SB_INTERFACE_END;

SB_CLASS_END(A);

In this example, the function multiplyByTwo is accessible to other SAMSON Extensions through the Introspection, even when the definition of class A is not available. Precisely, even though other developers might not have access to the definition of class A (i.e. they do not have the appropriate header file), they may still access its functionality:

SBProxy* classProxy = SAMSON::getProxy("A");
SBInterface* classInterface = classProxy->getInterface();
SBFunction* classFunction = 
    classInterface->getFunction("multiplyByTwo", SB_VALUE<int>(0));

Since, in this example, the function is not static, we need an object of type A:

SBValue* objectHolder = classProxy->createInstance();

We may then use the exposed function by wrapping arguments and unwrapping results:

SBValue* argumentHolder = new SBValueHolder<int>(17);
SBValue* resultHolder = classFunction->call(objectHolder, argumentHolder);

int result = static_cast<SBValueHolder<int>*>(resultHolder)->getValue();

delete argumentHolder;
delete resultHolder;

Note that the class proxy also makes it possible to directly call a function provided by an exposed class without having first to obtain the SBCClassFunction object:

SBValue* argumentHolder = new SBValueHolder<int>(17);
SBValue* resultHolder =
    classProxy->call(objectHolder, "multiplyByTwo", argumentHolder);

int result = static_cast<SBValueHolder<int>*>(resultHolder)->getValue();

delete argumentHolder;
delete resultHolder;
However, when multiple calls are performed, it is more efficient to store a pointer to a SBCClassFunction object and reuse it.

Note that a class function object should never be deleted.

Please refer to the chapter about Introspection for more information.

Short name: SBFunction

See also: Introspection

See also: SBCClassInterface, SBCClassProxy

Public Functions Documentation#

function SBCClassFunction#

Constructs a class function.

SBCClassFunction::SBCClassFunction () 


function call#

Calls the function for the specific object with argumentst0 ,t1 , ...,t15 .

virtual SBValue SBCClassFunction::call (
    const SBValue & object,
    const SBValue & t0=SBValue (),
    const SBValue & t1=SBValue (),
    const SBValue & t2=SBValue (),
    const SBValue & t3=SBValue (),
    const SBValue & t4=SBValue (),
    const SBValue & t5=SBValue (),
    const SBValue & t6=SBValue (),
    const SBValue & t7=SBValue (),
    const SBValue & t8=SBValue (),
    const SBValue & t9=SBValue (),
    const SBValue & t10=SBValue (),
    const SBValue & t11=SBValue (),
    const SBValue & t12=SBValue (),
    const SBValue & t13=SBValue (),
    const SBValue & t14=SBValue (),
    const SBValue & t15=SBValue ()
) const


function canCall#

Returns true if and only if the function can be called with argumentst0 ,t1 , ...,t15 .

virtual bool SBCClassFunction::canCall (
    const SBValue & t0=SBValue (),
    const SBValue & t1=SBValue (),
    const SBValue & t2=SBValue (),
    const SBValue & t3=SBValue (),
    const SBValue & t4=SBValue (),
    const SBValue & t5=SBValue (),
    const SBValue & t6=SBValue (),
    const SBValue & t7=SBValue (),
    const SBValue & t8=SBValue (),
    const SBValue & t9=SBValue (),
    const SBValue & t10=SBValue (),
    const SBValue & t11=SBValue (),
    const SBValue & t12=SBValue (),
    const SBValue & t13=SBValue (),
    const SBValue & t14=SBValue (),
    const SBValue & t15=SBValue ()
) const


function getName#

Returns the name of the function.

virtual std::string SBCClassFunction::getName () const = 0


function getNumberOfParameters#

Returns the number of parameters of the function.

virtual unsigned int SBCClassFunction::getNumberOfParameters () noexcept const = 0


function getOutputType#

Returns the output type of the function.

virtual std::string SBCClassFunction::getOutputType () const = 0


function getParameterType#

Returns the parameter type of the function parameter i .

virtual SBValue SBCClassFunction::getParameterType (
    int i
) const = 0


function getParameterTypeName#

Returns the parameter type name of the function parameter i .

virtual std::string SBCClassFunction::getParameterTypeName (
    int i
) const = 0


function isConstFunction#

Returns true if and only if the function is a const function.

virtual bool SBCClassFunction::isConstFunction () noexcept const = 0


function isStaticFunction#

Returns true if and only if the function is a static function.

virtual bool SBCClassFunction::isStaticFunction () noexcept const = 0


function signature#

Returns the signature of the function.

virtual std::string SBCClassFunction::signature () const = 0


function ~SBCClassFunction#

Destructs the class function.

virtual SBCClassFunction::~SBCClassFunction ()