Class SBCClassFunction#
This class describes a class function in a class proxy. More...
#include <SBCClassFunction.hpp>
Inherited by the following classes: SBCClassConstFunction0, SBCClassConstFunction0< void, Class >, SBCClassConstFunction1, SBCClassConstFunction10, SBCClassConstFunction10< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(10)>, SBCClassConstFunction11, SBCClassConstFunction11< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(11)>, SBCClassConstFunction12, SBCClassConstFunction12< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(12)>, SBCClassConstFunction13, SBCClassConstFunction13< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(13)>, SBCClassConstFunction14, SBCClassConstFunction14< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(14)>, SBCClassConstFunction15, SBCClassConstFunction15< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(15)>, SBCClassConstFunction16, SBCClassConstFunction16< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(16)>, SBCClassConstFunction1< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(1)>, SBCClassConstFunction2, SBCClassConstFunction2< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(2)>, SBCClassConstFunction3, SBCClassConstFunction3< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(3)>, SBCClassConstFunction4, SBCClassConstFunction4< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(4)>, SBCClassConstFunction5, SBCClassConstFunction5< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(5)>, SBCClassConstFunction6, SBCClassConstFunction6< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(6)>, SBCClassConstFunction7, SBCClassConstFunction7< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(7)>, SBCClassConstFunction8, SBCClassConstFunction8< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(8)>, SBCClassConstFunction9, SBCClassConstFunction9< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(9)>, SBCClassFunction0, SBCClassFunction0< void, Class >, SBCClassFunction1, SBCClassFunction10, SBCClassFunction10< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(10)>, SBCClassFunction11, SBCClassFunction11< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(11)>, SBCClassFunction12, SBCClassFunction12< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(12)>, SBCClassFunction13, SBCClassFunction13< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(13)>, SBCClassFunction14, SBCClassFunction14< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(14)>, SBCClassFunction15, SBCClassFunction15< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(15)>, SBCClassFunction16, SBCClassFunction16< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(16)>, SBCClassFunction1< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(1)>, SBCClassFunction2, SBCClassFunction2< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(2)>, SBCClassFunction3, SBCClassFunction3< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(3)>, SBCClassFunction4, SBCClassFunction4< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(4)>, SBCClassFunction5, SBCClassFunction5< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(5)>, SBCClassFunction6, SBCClassFunction6< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(6)>, SBCClassFunction7, SBCClassFunction7< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(7)>, SBCClassFunction8, SBCClassFunction8< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(8)>, SBCClassFunction9, SBCClassFunction9< void, Class, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(9)>, SBCClassStaticFunction0, SBCClassStaticFunction0< void >, SBCClassStaticFunction1, SBCClassStaticFunction10, SBCClassStaticFunction10< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(10)>, SBCClassStaticFunction11, SBCClassStaticFunction11< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(11)>, SBCClassStaticFunction12, SBCClassStaticFunction12< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(12)>, SBCClassStaticFunction13, SBCClassStaticFunction13< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(13)>, SBCClassStaticFunction14, SBCClassStaticFunction14< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(14)>, SBCClassStaticFunction15, SBCClassStaticFunction15< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(15)>, SBCClassStaticFunction16, SBCClassStaticFunction16< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(16)>, SBCClassStaticFunction1< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(1)>, SBCClassStaticFunction2, SBCClassStaticFunction2< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(2)>, SBCClassStaticFunction3, SBCClassStaticFunction3< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(3)>, SBCClassStaticFunction4, SBCClassStaticFunction4< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(4)>, SBCClassStaticFunction5, SBCClassStaticFunction5< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(5)>, SBCClassStaticFunction6, SBCClassStaticFunction6< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(6)>, SBCClassStaticFunction7, SBCClassStaticFunction7< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(7)>, SBCClassStaticFunction8, SBCClassStaticFunction8< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(8)>, SBCClassStaticFunction9, SBCClassStaticFunction9< void, SB_MAKE_TEMPLATE_SPECIALIZATION_PARAMETERS(9)>
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 arguments t0 ,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#
This class describes a class function in a class proxy. 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");
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
:
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;
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.
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 arguments t0
,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.
function getNumberOfParameters#
Returns the number of parameters of the function.
function getOutputType#
Returns the output type of the function.
function getParameterType#
Returns the parameter type of the function parameter i
.
function getParameterTypeName#
Returns the parameter type name of the function parameter i
.
function isConstFunction#
Returns true if and only if the function is a const function.
function isStaticFunction#
Returns true if and only if the function is a static function.
function signature#
Returns the signature of the function.
function ~SBCClassFunction#
Destructs the class function.