VISH
0.2
|
Let us assume a VISH Object wants to implement a new, user-defined type
struct MyType
{
...
};
and other objects shall use this type as inputs. The "MyType" class may also be an intrinsic type such as int or float. The type definition needs to be shared among all object using it, i.e. all objects providing input and using input. However, the providing objects and the requesting objects do not need to be within the same compilation unit. For utmost encapsulation, the type definition may be casted into its own compilation unit.
In order to allow an VISH Object to provide a certain input type, it must implement the virtual function getImplementation(), such as:
class MyObject : public VObject { RefPtr<VParameter> myOwnParameter; const RefPtr<VParameter>&getImplementation(const type_info&what, const string&); };
This function is responsible to deliver a VParameter given the provided type information and a textual description if the type itself is ambiguous otherwise:
const RefPtr<VParameter>&MyObject::getImplementation(const type_info&what, const string&name) { if (what == typeid(MyType) ) return myOwnParameter; return VObject::getImplementation(what, name); }
Note that the type check is optional and only required if the VObject provides more than one type. This is because the certain VObject will be called for only selected types anyway, namely those as provided by its associated VCreator. Use the template class VInputCreator<> for defining appropriate VCreators: VInputCreator<MyType, VCreator<MyObject> > myTypeCreator("MyType");
Note that template VInputCreator<> can well be used recursively if more than one input type is to be handled.
Alternatively, input types may also dynamically added and removed from a certain VCreator. This is done by calling the member functions
registerVInput(typeid(MyType), this); unregisterVInput(typeid(MyType), this);
at an appropriate place. Note that the unregister function must be called explicitely at the momen.
The value of a Parameter may be relative to a ValuePool, or globally shared.