SBCClassConstructor Class Referenceabstract

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

Constructors and destructors

 SBCClassConstructor ()
 Constructs a class constructor.
 
virtual ~SBCClassConstructor ()
 Destructs the constructor.
 

Creation functions

virtual bool canCreateInstance (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 constructor can create an instance with arguments t0, t1, ..., t15.
 
virtual SBValue createInstance (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
 Creates an instance of the class with arguments t0, t1, ..., t15.
 

Identity

virtual std::string getClassName () const =0
 Returns the class name.
 
virtual std::string getParameterTypeName (int i) const =0
 Returns the parameter type name of the constructor parameter i.
 
virtual SBValue getParameterType (int i) const =0
 Returns the parameter type of the constructor parameter i.
 
virtual unsigned int getNumberOfParameters () const =0
 Returns the number of parameters of the function.
 
virtual std::string signature () const =0
 Returns the signature of the function.
 

Detailed Description

This class describes a class constructor in a class proxy. A class constructor object is a functor that provides access to a SAMSON Extension constructor that has been exposed through a class descriptor.

Assume for example a SAMSON Extension contains the following class:

class A {
public:
A() {}
virtual ~A() {}
};
SB_REGISTER_TYPE(A, "A", "BF99103E-06FE-C4C1-D929-4C6E833B101C");

as well as the following class descriptor:

In this example, the constructor A() is accessible to other SAMSON Extensions through the SAMSON introspection mechanism, 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 retrieve constructors through the class proxy:

SBProxy* classProxy = SAMSON::getProxy("A");
SBFactory* classFactory = classProxy->getFactory();
SBConstructor* classConstructor = classFactory->getConstructor();

which they may then use to construct an instance of class A:

SBValue* objectHolder = classConstructor->createInstance();

Note that the class proxy also makes it possible to directly create an instance of an exposed class without having first to obtain the SBCClassConstructor object:

SBValue* objectHolder = classProxy->createInstance();

However, when multiple calls to the constructor are performed, it is more efficient to store a pointer to a SBCClassConstructor object and reuse it.

Note that a class constructor object should never be deleted.

Please refer to the chapter about introspection for more information.

Short name: SBConstructor

See also
Introspection
SBCClassFactory
SBCClassProxy
virtual SBValue createInstance(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
Creates an instance of the class with arguments t0, t1, ..., t15.
Definition: SBCClassConstructor.cpp:79
static SBProxy * getProxy(const std::string &className, const SBUUID &elementUUID=SBUUID())
Returns the proxy of a class.
Definition: SAMSON.cpp:1787
This class describes a class constructor in a class proxy.
Definition: SBCClassConstructor.hpp:18
#define SB_INTERFACE_BEGIN
Declares the beginning of the class interface.
Definition: SBCClassInterface.hpp:107
#define SB_FACTORY_BEGIN
Declares the beginning of the class factory.
Definition: SBCClassFactory.hpp:77
virtual SBCClassFactory const * getFactory() const
Returns the factory of the class.
Definition: SBCClassProxy.cpp:212
#define SB_CLASS
Macro that is added inside the class declaration for Introspection, etc.
Definition: SBCClass.hpp:236
This class describes a class proxy.
Definition: SBCClassProxy.hpp:27
#define SB_CLASS_DESCRIPTION(CLASS_DESCRIPTION)
Declares the description of the class.
Definition: SBCClassProxy.hpp:208
#define SB_FACTORY_END
Declares the end of the class factory.
Definition: SBCClassFactory.hpp:91
#define SB_CLASS_END(CLASS)
Declares the end of a class.
Definition: SBCClassProxy.hpp:266
SBCClassConstructor * getConstructor(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 the constructor with arguments t0, t1, ..., t15.
Definition: SBCClassFactory.cpp:18
#define SB_CONSTRUCTOR_0(CLASS)
Declares a class constructor CLASS::CLASS()
Definition: SBCClassFactory.hpp:111
virtual SBValue createInstance(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
Creates an instance of the class with arguments t0, t1, ..., t15.
Definition: SBCClassProxy.cpp:97
#define SB_INTERFACE_END
Declares the end of the class interface.
Definition: SBCClassInterface.hpp:122
@ App
Apps.
Definition: SBCClass.hpp:28
#define SB_CLASS_TYPE(CLASS_TYPE)
Declares the type of the class.
Definition: SBCClassProxy.hpp:202
#define SB_CLASS_BEGIN(CLASS)
Declares the beginning of a class.
Definition: SBCClassProxy.hpp:175
This class describes a class factory in a class proxy.
Definition: SBCClassFactory.hpp:16
This class represents values.
Definition: SBCMetaValue.hpp:23
#define SB_REGISTER_TYPE(TYPE, SHORT_NAME, UUID)
Registers a type in a SAMSON Extension.
Definition: SBCMetaRegister.hpp:51