Web Analytics Made Easy - Statcounter
Skip to content

Class SBCClassConstructor#

ClassList > SBCClassConstructor

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

  • #include <SBCClassConstructor.hpp>

Inherits the following classes: SBCClassCallableMember

Inherited by the following classes: SBCClassConstructor0

Public Functions#

Type Name
SBCClassConstructor () noexcept
Constructs a class constructor.
SBCClassConstructor (const SBCClassCallableMemberDoc::Spec & spec)
Constructs a class constructor with the given doc.specs.
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 argumentst0 ,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 .
virtual std::string getClassName () const = 0
Returns the class name.
virtual unsigned int getNumberOfParameters () noexcept override const = 0
Returns the number of parameters of the constructor.
virtual SBValue getParameterType (int i) override const = 0
Returns the parameter type of the constructor parameter i .
virtual std::string getParameterTypeName (int i) override const = 0
Returns the parameter type name of the constructor parameter i .
virtual std::string signature (bool addArgumentNames=false) override const
Returns the signature of the constructor; if addArgumentNames istrue then also adds names of arguments.
virtual ~SBCClassConstructor ()
Destructs the constructor.

Detailed Description#

A class constructor object is a functor that provides access to a SAMSON Extension constructor 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() {}

};

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("Empty class");

    SB_FACTORY_BEGIN;

        SB_CONSTRUCTOR_0();

    SB_FACTORY_END;

    SB_INTERFACE_BEGIN;
    SB_INTERFACE_END;

SB_CLASS_END(A);

In this example, the constructor A() 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 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 classInstance = 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 classInstance = 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

See also: SBCClassFactory, SBCClassProxy

Public Functions Documentation#

function SBCClassConstructor [1/2]#

Constructs a class constructor.

SBCClassConstructor::SBCClassConstructor () noexcept


function SBCClassConstructor [2/2]#

Constructs a class constructor with the given doc.specs.

SBCClassConstructor::SBCClassConstructor (
    const SBCClassCallableMemberDoc::Spec & spec
) 

Constructs a class constructor with the given documentation specification.

Parameters:

  • spec Documentation specification for the constructor.

function canCreateInstance#

Returns true if and only if the constructor can create an instance with argumentst0 ,t1 , ...,t15 .

virtual bool SBCClassConstructor::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 the given arguments.

Parameters:

  • t0 First argument (optional).
  • t1 Second argument (optional).
  • t2 Third argument (optional).
  • t3 Fourth argument (optional).
  • t4 Fifth argument (optional).
  • t5 Sixth argument (optional).
  • t6 Seventh argument (optional).
  • t7 Eighth argument (optional).
  • t8 Ninth argument (optional).
  • t9 Tenth argument (optional).
  • t10 Eleventh argument (optional).
  • t11 Twelfth argument (optional).
  • t12 Thirteenth argument (optional).
  • t13 Fourteenth argument (optional).
  • t14 Fifteenth argument (optional).
  • t15 Sixteenth argument (optional).

Returns:

true if the constructor can create an instance with the supplied arguments; false otherwise.


function createInstance#

Creates an instance of the class with arguments t0 ,t1 , ...,t15 .

virtual SBValue SBCClassConstructor::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 using the supplied arguments.

Parameters:

  • t0 First argument (optional).
  • t1 Second argument (optional).
  • t2 Third argument (optional).
  • t3 Fourth argument (optional).
  • t4 Fifth argument (optional).
  • t5 Sixth argument (optional).
  • t6 Seventh argument (optional).
  • t7 Eighth argument (optional).
  • t8 Ninth argument (optional).
  • t9 Tenth argument (optional).
  • t10 Eleventh argument (optional).
  • t11 Twelfth argument (optional).
  • t12 Thirteenth argument (optional).
  • t13 Fourteenth argument (optional).
  • t14 Fifteenth argument (optional).
  • t15 Sixteenth argument (optional).

Returns:

SBValue representing the created instance.


function getClassName#

Returns the class name.

virtual std::string SBCClassConstructor::getClassName () const = 0


function getNumberOfParameters#

Returns the number of parameters of the constructor.

virtual unsigned int SBCClassConstructor::getNumberOfParameters () noexcept override const = 0


function getParameterType#

Returns the parameter type of the constructor parameter i .

virtual SBValue SBCClassConstructor::getParameterType (
    int i
) override const = 0


function getParameterTypeName#

Returns the parameter type name of the constructor parameter i .

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


function signature#

Returns the signature of the constructor; if addArgumentNames istrue then also adds names of arguments.

virtual std::string SBCClassConstructor::signature (
    bool addArgumentNames=false
) override const

Returns the signature of the constructor.

Parameters:

  • addArgumentNames If true, the signature includes the argument names (if available).

Returns:

String containing the constructor signature.


function ~SBCClassConstructor#

Destructs the constructor.

virtual SBCClassConstructor::~SBCClassConstructor () 

Destructs the class constructor.