Loading...
Searching...
No Matches
SBCClassProxy Class Reference

This class describes a class proxy. More...

Constructors and destructors

virtual ~SBCClassProxy ()
 Destructs the class proxy.
 

Identity

virtual std::string getName () const
 Returns the name of the class.
 
virtual SBCClass::Type getType () const noexcept
 Returns the type of the class.
 
virtual SBCContainerUUID getUUID () const
 Returns the UUID of the class.
 
virtual std::string getDescription () const
 Returns the description of the class.
 
virtual std::string getShortcut () const
 Returns the shortcut of the class.
 
virtual std::string getToolTip () const
 Returns the tooltip of the class.
 
virtual std::string getPublicName () const
 Returns the public name of the class.
 
virtual std::string getIconFileName () const
 Returns the file name of the class icon.
 
virtual SBCContainerUUID getGUIUUID () const
 Returns the UUID of the GUI of the class.
 
virtual std::string getGUIShortcut () const
 Returns the shortcut of the GUI of the class.
 
virtual SBUserPlan getMinimumUserPlan () const noexcept
 Returns the minimum user plan required to use this class.
 
virtual std::string getElement () const noexcept
 Returns the SAMSON Extension containing the class.
 
virtual SBCContainerUUID getElementUUID () const
 Returns the UUID of the SAMSON Extension containing the class.
 
virtual SBVersionNumber getVersionNumber () const
 Returns the version number of the class.
 
virtual SBVersionNumber getSDKVersionNumber () const noexcept
 Returns the version number of the SAMSON SDK used to compile the class.
 

User interface

virtual bool isDiscoverable () const noexcept
 Returns true if can be discovered by the user.
 

Factory

virtual SBCClassFactory const * getFactory () const
 Returns the factory of the class.
 
virtual SBValue createInstanceType () const
 Creates a value type that holds the class type.
 
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.
 

Interface

virtual SBCClassInterface const * getInterface () const
 Returns the interface of the class.
 
virtual SBValue call (const SBValue &object, const std::string &functionName, 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 arguments t0, t1, ..., t15.
 
virtual SBValue constCall (const SBValue &object, const std::string &functionName, 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 const function for the specific object with arguments t0, t1, ..., t15.
 
virtual SBValue get (const SBValue &object, const std::string &attributeName) const
 Returns the value of attribute attributeName for the specific object.
 
virtual void set (const SBValue &object, const std::string &attributeName, const SBValue &value, const SBValue &size=0) const
 Sets the value of attribute attributeName for the specific object to value.
 
virtual bool has (const SBValue &object, const std::string &attributeName) const
 Returns whether attribute attributeName exists in the object and has a value.
 
virtual void clear (const SBValue &object, const std::string &attributeName) const
 Clears attribute attributeName from the object when possible.
 
virtual unsigned int getSize (const SBValue &object, const std::string &attributeName) const
 Returns the size of attribute attributeName in the object when relevant.
 

Debugging

void print (unsigned int offset=0) const
 Prints debugging information.
 
virtual SBCClassProxyData * getData () const noexcept
 
virtual void setData (SBCClassProxyData *data)
 
 SBCClassProxy ()
 

Detailed Description

This class describes a class proxy, i.e. an access to a class that has been exposed through a class descriptor in a SAMSON Extension.

Assume for example a SAMSON Extension contains the following class:

class A {
public:
A() {}
virtual ~A() {}
int multiplyByTwo(int i) {
return 2 * i;
}
};
SB_REGISTER_TYPE(A, "A", "BF99103E-06FE-C4C1-D929-4C6E833B101C");
#define SB_CLASS
Macro that is added inside the class declaration for Introspection, etc.
Definition: SBCClass.hpp:241
#define SB_REGISTER_TYPE(TYPE, SHORT_NAME, UUID)
Registers a type in a SAMSON Extension.
Definition: SBCMetaRegister.hpp:52

as well as the following class descriptor:

SB_CLASS_DESCRIPTION("Integer multiplier");
SB_FUNCTION_1(int, A, multiplyByTwo, int);
#define SB_FACTORY_BEGIN
Declares the beginning of the class factory.
Definition: SBCClassFactory.hpp:77
#define SB_FACTORY_END
Declares the end of the class factory.
Definition: SBCClassFactory.hpp:91
#define SB_CONSTRUCTOR_0(CLASS)
Declares a class constructor CLASS::CLASS()
Definition: SBCClassFactory.hpp:111
#define SB_INTERFACE_END
Declares the end of the class interface.
Definition: SBCClassInterface.hpp:122
#define SB_FUNCTION_1(OUTPUT, CLASS, FUNCTION, T0)
Declares a class function OUTPUT CLASS::FUNCTION(T0)
Definition: SBCClassInterface.hpp:154
#define SB_INTERFACE_BEGIN
Declares the beginning of the class interface.
Definition: SBCClassInterface.hpp:107
#define SB_CLASS_TYPE(CLASS_TYPE)
Declares the type of the class.
Definition: SBCClassProxy.hpp:196
#define SB_CLASS_END(CLASS)
Declares the end of a class.
Definition: SBCClassProxy.hpp:260
#define SB_CLASS_DESCRIPTION(CLASS_DESCRIPTION)
Declares the description of the class.
Definition: SBCClassProxy.hpp:202
#define SB_CLASS_BEGIN(CLASS)
Declares the beginning of a class.
Definition: SBCClassProxy.hpp:173
@ App
Apps.
Definition: SBCClass.hpp:28

In this example, the functionality of class A is accessible to developers of SAMSON Extensions, 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 create instances of it:

const SBValue& objectHolder = classProxy->createInstance();
This class represents values.
Definition: SBCMetaValue.hpp:23

and call its functions:

const SBValue& argumentHolder = new SBValueHolder<int>(17);
const SBValue& resultHolder = classProxy->call(objectHolder, "multiplyByTwo", argument);
int result = static_cast<SBValueHolder<int>*>(resultHolder)->getValue();
delete argumentHolder;
delete resultHolder;
virtual SBCMetaValue call(const std::string &functionName, const SBCMetaValue &t0=SBCMetaValue(), const SBCMetaValue &t1=SBCMetaValue(), const SBCMetaValue &t2=SBCMetaValue(), const SBCMetaValue &t3=SBCMetaValue(), const SBCMetaValue &t4=SBCMetaValue(), const SBCMetaValue &t5=SBCMetaValue(), const SBCMetaValue &t6=SBCMetaValue(), const SBCMetaValue &t7=SBCMetaValue(), const SBCMetaValue &t8=SBCMetaValue(), const SBCMetaValue &t9=SBCMetaValue(), const SBCMetaValue &t10=SBCMetaValue(), const SBCMetaValue &t11=SBCMetaValue(), const SBCMetaValue &t12=SBCMetaValue(), const SBCMetaValue &t13=SBCMetaValue(), const SBCMetaValue &t14=SBCMetaValue(), const SBCMetaValue &t15=SBCMetaValue()) const
Calls the function functionName of the value with arguments t0, t1, ..., t15.
Definition: SBCMetaValue.cpp:265

In general, a class proxy gives access to information about a class (e.g. its name, its type, etc.), as well as its factory (its collection of constructors) and its interface (its collection of functions).

Note that, when multiple instances of the class are created, or when multiple calls are performed, it is more efficient to store pointers to class constructors and class functions and reuse them.

Note that a class proxy should never be deleted.

Please refer to the chapter about introspection for more information.

Short name: SBProxy

See also
Introspection
SBCClassFactory
SBCClassConstructor
SBCClassInterface
SBCClassFunction