VISH
0.2
|
Intermediate class for storing (named) references to parameters. More...
#include </home/werner/origo/vish/ocean/plankton/VSlot.hpp>
(Note that these are not member functions.)
Intermediate class for storing (named) references to parameters.
This reference class is used whereever we want to refer to a certain parameter, but the parameter itself may change since it might be connected to one or another object. This reference slot implements an edge in the data flow graph. Independently, each parameter may be related to one or many inputs, which are related through the control flow graph.
Note that global operators are provided that enable user-friendly convenient retrieval of slot values. Code looks like this:
Slot mySlot; Context myContext; int Value; if ( mySlot << myContext >> Value ) { printf("Yes, got a value, and its value is %d!\n", Value); } else { printf("Sorry, could not retrieve the desired input value...\n"); }
Wizt::VSlot::VSlot | ( | const WeakVObjectPtr & | theSlotOwner, |
const RefPtr< VParameter > & | p, | ||
const string & | name, | ||
const string & | member = "" |
||
) |
Construct slot from parameter and local name, optional member reference.
theSlotOwner | Where this slot will live, a VObject . |
bool Wizt::VSlot::assignParameter | ( | const RefPtr< VParameter > & | param, |
const string & | member = "" |
||
) |
Assign a parameter to this Slot and update its connection age.
This function should not be called by application code, use attachSlot() instead as these function will announce all changes.
false if the provided parameter and member is already assigned, in which case this assignment does nothing.
bool Wizt::VSlot::attachSlot | ( | const RefPtr< VSlot > & | SlotSource | ) |
Connect another Slot's parameter here.
This slot's parameter will be removed.
bool Wizt::VSlot::forceSetProperty | ( | const string & | name, |
const T & | value | ||
) | const [inline] |
Set a certain property of this parameter, and issue a notification event for the parameter's input object.
const WeakVObjectPtr& Wizt::VSlot::getSlotOwner | ( | ) | const [inline] |
Return the VObject that owns this current VSlot.
This is not necessarily the Source(), since the associated parameter of a VSlot may be provided by another VObject. In order to check if a VSlot's value stems from another object, compare the getSlotOwner() with the getSource(), which refers to the owner of the parameter value.
RefPtr<VManagedObject> Wizt::VSlot::getSource | ( | ) | const [inline] |
Return a possible source object of this slot, telling where these values stem from.
The returned object will provide a parameter that is referenced by this Slot.
bool Wizt::VSlot::getValue | ( | Type & | Variable, |
const RefPtr< ValuePool > & | VP | ||
) | const [inline] |
Get a value for a certain parameter.
void Wizt::VSlot::Globalize | ( | const RefPtr< ValuePool > & | GhostValues | ) | [inline] |
If a context-local parameter should rather be set to a global value, call this function.
Some context needs to be provided though in order to set the global state from this local context.
bool Wizt::VSlot::isNew | ( | const RefPtr< ValuePool > & | VP | ) | const |
Tell if this Slot is newer than its owner, i.e.
the object where it belongs to, its getSlotOwner().
Equivalent to
age(VP).isNewerThan( getSlotOwner().age(VP ));
void Wizt::VSlot::Localize | ( | ) | [inline] |
New object parameters start as global parameters.
If the value of a parameter is supposed to be context-local, then this may be specified by calling this function.
bool Wizt::VSlot::setProperty | ( | const string & | name, |
const T & | value | ||
) | const [inline] |
Set a certain property of this parameter if it differs, and issue a notification event for the parameter's input object if it has changed.
Get the age of this value relative to the given value pool.
const ValueSetPair& operator+= | ( | const ValueSetPair & | VSP, |
const RefPtr< VSlot > & | VS | ||
) | [friend] |
RefPtr<ValueSet> Changeables = new ValueSet();
Changeables & R += nLines, X, Y, Z, Length, DistributionWidth;
const ValueSetPair& operator, | ( | const ValueSetPair & | VSP, |
const RefPtr< VSlot > & | VS | ||
) | [friend] |
RefPtr<ValueSet> Changeables = new ValueSet();
Changeables & R += nLines, X, Y, Z, Length, DistributionWidth;
typedef std::pair<const RefPtr<VSlot>, const RefPtr<ValuePool> > SlotContext [related] |
Reference to an InputSlot plus context.
unsigned int Wizt::VSlot::AllowAutoConnection |
Specify whether this slot maybe be automatically connected with the slots of another VObject when connectSlots() is called.
This is the case for instance when a new VObject is created as an input object for some VObject. Here, usually it were beneficial to have all compatible slots (same type, same name) to be connected to the same input. However, there are case where this should not be the case. This flag (default is true) allows to specify such slots that are to be kept private.
unsigned int Wizt::VSlot::cached |
Specify whether this parameter should be cached, meaning: if this parameter is changed, should it trigger computing a new output result, or will that just be used from somewhere else? It is up to the VObject::update() routine to proper handle caching, which is non-trivial.
By default, parameters are not cached, so any change will trigger a new computation. This flag is checked by VObject::YoungestUncachedInput(). The typical use case scenario is like this:
class myObject : public VObject { TypedSlot<InputType> input; myObject() { input.cached = true; } update() { Ageable&CacheAge = ...; if (YoungestUncachedInput(Context).isOlderThan( CacheAge ) ) { // reuse cached result return; } // compute new result return } };
The function VObject::YoungestUncachedInput() will determine the youngest age of all input slots that are have not set cached to be enabled.
unsigned int Wizt::VSlot::inactive |
A flag to tell that this slot is currently inactive.
Means it is not used at the moment at all. It will therefore not be considered for any caching, and some GUI might want to hide it. Be cautious when setting this flag, because the activity of a slot might depend on the context, whereas this flag is global.
The flag must be set to true to specify inactivity. By default it is false.