VISH  0.2
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | Related Functions
Wizt::VSlot Class Reference

Intermediate class for storing (named) references to parameters. More...

#include </home/werner/origo/vish/ocean/plankton/VSlot.hpp>

List of all members.

Classes

Public Member Functions

Static Public Member Functions

Public Attributes

Friends

Related Functions

(Note that these are not member functions.)


Detailed Description

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");
        }

Constructor & Destructor Documentation

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.

Parameters:
theSlotOwnerWhere this slot will live, a VObject .

Member Function Documentation

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.

template<class T >
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.

Todo:
Think about clustering of parameter property notifications. Won't be too hard, since the VParameter::setValueParameter() code is the one sending the notification. Just need to conceive a safe and convenient API.
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.

See also:
getSlotOwner() .
template<class Type >
bool Wizt::VSlot::getValue ( Type &  Variable,
const RefPtr< ValuePool > &  VP 
) const [inline]

Get a value for a certain parameter.

Returns:
false, if the value could not be set, because the parameter was not found or there was another error, for instance the parameter has an incompatible type.
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.

template<class T >
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.

Note:
An unequality operation must be defined for the template type T
Returns:
true if the parameter could be changed.
See also:
forceSetProperty Set a property unconditionally.
const Ageable & Wizt::VSlot::ValueAge ( const RefPtr< ValuePool > &  VP) const

Get the age of this value relative to the given value pool.

Returns:
It will yield Ageable::InfinitelyOld() if the current value does not have any representation in the given value pool.

Friends And Related Function Documentation

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.


Member Data Documentation

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.


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