DUECA/DUSIME
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
ScriptCreatableDataHolder< T > Class Template Reference

ScriptCreatable templated holder class. More...

#include <ScriptCreatableDataHolder.hxx>

Inheritance diagram for ScriptCreatableDataHolder< T >:
Inheritance graph
[legend]
Collaboration diagram for ScriptCreatableDataHolder< T >:
Collaboration graph
[legend]

Public Types

typedef T data_type
 Encapsulated type.
 

Public Member Functions

 ScriptCreatableDataHolder ()
 Constructor.
 
bool complete ()
 Continued construction.
 
const char * getTypeName ()
 Type name information.
 
virtual ~ScriptCreatableDataHolder ()
 Destructor.
 
T & data ()
 Gives access to the data object contained in this DataHolder.
 
const T & data () const
 Gives access to the data object contained in this DataHolder.
 

Detailed Description

template<class T>
class ScriptCreatableDataHolder< T >

ScriptCreatable templated holder class.

This template can be used for scheme creatable objects (defined in a DCO file) that do not directly derive from ScriptCreatable.

Typically, use of this class is invoked by setting

(Option ScriptCreatable)

in your DCO object definition.

This ensures that the object can be created from the (scheme) creation script, and all member variables are accessable and settable, with lines like:

(define obj (make-my-dco-object
'set-my-member-variable <some-value>;
)

In python this looks a little different,

object = dueca.MyDCOObject().param(
my_member_variable = <some value>;
)
This is a "light weight object" that enables you to read the latest set of data on a StreamChannelEnd...
Definition StreamReaderLatest.hxx:43

To "accept" one of these variables in your module, you can add a function to the parametertable which accepts a ScriptCreatable object. This object can take a dynamic cast to a ScriptCreatableDataHolder of your object type, and with the data() function the data can be accessed.

In your table:

{ "my-object",
new MemberCall<_ThisModule_,ScriptCreatable>
(&_ThisModule_::acceptMyObject),
"Pass a DCO object created in the script" },

Then the code to accept the object (declare a matching function in your class):

MyModule::acceptMyObject(const ScriptCreatable& objbase)
{
dynamic_cast<ScriptCreatableDataHolder<MyObject> >(&objbase);
if (obj != NULL) {
// do something with that, like
cout << obj->data() << endl;
}
else {
E_MOD ("You probably passed something that is not a MyObject");
return false;
}
return true;
}
ScriptCreatable templated holder class.
Definition ScriptCreatableDataHolder.hxx:95
T & data()
Gives access to the data object contained in this DataHolder.
Definition ScriptCreatableDataHolder.hxx:127
#define E_MOD(A)
Error messages for application module code.
Definition newlog-macros.hxx:620

Constructor & Destructor Documentation

◆ ScriptCreatableDataHolder()

template<class T >
ScriptCreatableDataHolder< T >::ScriptCreatableDataHolder ( )
inline

Constructor.

Is normally called from scheme/the creation script.

Member Function Documentation

◆ complete()

template<class T >
bool ScriptCreatableDataHolder< T >::complete ( )
inline

Continued construction.

This is called after all script parameters have been read and filled in, according to the parameter table.


The documentation for this class was generated from the following file: