The Vish Visualization Shell 0.3
Vish
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | Related Symbols | List of all members
Wizt::VSlot Class Reference

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

#include <ocean/plankton/VSlot.hpp>

Inheritance diagram for Wizt::VSlot:
MemCore::ReferenceBase< VSlot >

Classes

struct  Empty
 Internal type for computational constructor. More...
 

Public Member Functions

bool AddAction (const RefPtr< ValueActionBase > &VAB) const
 Associate the change of a slot value with an arbitrary action.
 
const Ageableage (const RefPtr< ValuePool > &VP) const
 Get the age of this value relative to the given value pool or the age of the most recent connection, whatever is younger (happened more recently).
 
bool assignParameter (const RefPtr< VParameter > &param, const string &member={})
 Assign a parameter to this Slot and update its connection age.
 
bool attachSlot (const VSlotPtr &SlotSource)
 Connect another Slot's parameter here.
 
const AgeableConnectionAge () const
 Get the age when this slot was most recently connected to another parameter.
 
template<class T >
bool forceSetProperty (const string &theName, const T &value) const
 Set a certain property of this parameter, and issue a notification event for the parameter's input object.
 
WeakVObjectPtr getExternalOwner () const
 Get an external object only if this slot's parameter belongs to an object that is not its owner.
 
RefPtr< VValueBasegetGlobalValue () const
 Return the GLOBAL value associated with this slot.
 
const string & getMemberName () const
 Eventually, the member of the parameter which is used for this VObject.
 
const RefPtr< VParameter > & getParameter () const
 Get the associated parameter.
 
string getParameterName () const
 Global name of this parameter, i.e. how it is actually called.
 
RefPtr< VValueBasegetProperty (const string &s) const
 Retrieve a certain property with yet unknown type.
 
template<class T >
bool getProperty (const string &s, T &value) const
 Retrieve a certain property of a parameter.
 
const string & getSlotName () const
 Local name of this parameter, i.e. how it is accessed from an VObject.
 
const WeakPtrToVSlotContainergetSlotOwner () const
 Return the VObject that owns this current VSlot.
 
RefPtr< VManagedObjectgetSource () const
 Return a possible source object of this slot, telling where these values stem from.
 
string getStatus () const
 Provide the current status string.
 
template<class Type >
bool getValue (Type &Variable, const RefPtr< ValuePool > &VP) const
 Get a value for a certain parameter.
 
string getValueAsText (const RefPtr< ValuePool > &VP, const string &theMember={})
 Get the parameter to a certain value as some textual description.
 
RefPtr< VValueBasegetValueBase (const RefPtr< ValuePool > &VP) const
 Gets a value from the reference parameter.
 
void Globalize (const RefPtr< ValuePool > &GhostValues)
 If a context-local parameter should rather be set to a global value, call this function.
 
bool isLocal () const
 Tell if the current parameter is local relative to a given context.
 
bool isNew (const RefPtr< ValuePool > &VP) const
 Tell if this Slot is newer than its owner, i.e.
 
void Localize ()
 New object parameters start as global parameters.
 
const string & MemberName () const
 Eventually, the member of the parameter which is used for this VObject.
 
RefPtr< VValueBaseoperator() (const RefPtr< ValuePool > &VP) const
 Return the value associated with this slot relative to a given value pool.
 
const string & operator/= (const string &s)
 
string ParameterName () const
 Global name of this parameter, i.e. how it is actually called.
 
void resetAge ()
 Reset the age of the associated parameter to infinitely old such to not trigger updates.
 
void setClass (const string &s)
 
template<class T >
bool setProperty (const string &theName, const T &value) const
 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.
 
template<class T >
bool setPropertyIfNotExists (const string &theName, const T &defaultValue) const
 Set a certain property of this parameter if it does not exist yet, and issue a notification event for the parameter's input object if it was created.
 
void setRelevance (int rel)
 Set the relevance of the involved parameter.
 
bool setShadowValueFromText (const string &VariableText, const string &PoolName, const string &theMember={})
 Set a variable value from text with a context given via its name.
 
void setStatus (const string &newStatus, const ValuePoolPtr &Context)
 Set the current status string and issue a parameter notification if the status has changed.
 
template<class Type >
bool setValue (const Type &Variable, const RefPtr< ValuePool > &VP, const WeakPtr< ValueNotifier > &issuer=nullptr, const ValueNotifierList *Exclude=0) const
 Set the value in the associated parameter.
 
template<class Type >
bool setValueByPoolname (const Type &Variable, const string &PoolName, const WeakPtr< ValueNotifier > &issuer=nullptr, const ValueNotifierList *Exclude=0) const
 Set the value in the associated parameter with the context given via its name.
 
bool setValueFromText (const string &VariableText, const RefPtr< ValuePool > &VP, const string &theMember={})
 Set the parameter to a certain value from some textual description.
 
const string & SlotName () const
 Local name of this parameter, i.e. how it is accessed from an VObject.
 
const AgeableValueAge (const RefPtr< ValuePool > &VP) const
 Get the age of this value relative to the given value pool.
 
 VSlot ()
 Empty constructor.
 
 VSlot (VSlotContainer *theSlotOwner, const RefPtr< VParameter > &p, const string &name, const string &member={})
 Construct slot from parameter and local name, optional member reference.
 
 ~VSlot ()
 Destructor.
 
- Public Member Functions inherited from MemCore::ReferenceBase< VSlot >
auto getObjectCountID () const noexcept
 Get a unique ID for this object in the given domain.
 
bool isIdentical (const WeakPtr< VSlot, VSlot > &PossibleSelf) const noexcept
 Check if this object is identical to the one used by the given pointer.
 
void mkAutoDestructive ()
 Marks this object as being automatically destructed, e.g.
 
refcount_t refcount () const noexcept
 The strong reference count.
 
 ReferenceBase (VSlot *that) noexcept
 Constructor, initializes reference counter to zero.
 
const auto & self () const
 Return weak pointer to the object self.
 
refcount_t wrefcount () const noexcept
 The weak reference count.
 

Static Public Member Functions

static WeakVObjectPtr getVObjectPtr (VObject *)
 Internal helper function.
 

Public Attributes

unsigned int AllowAutoConnection:1
 Specify whether this slot maybe be automatically connected with the slots of another VObject when connectSlots() is called.
 
unsigned int cached:1
 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.
 
unsigned int dontSave:1
 A flag to specify that this slot shall never be saved, for instance if it is computed anyway or its associated type is unsaveable.
 
string helptext
 An help text for users, to be used to describe the functionality of this Slot relative to the current context where it is used.
 
unsigned int ignoreConnectionAge:1 = 0
 A flag to tell whether the connection age should be ignored when checking whether this Slot has changed during an update().
 
unsigned int inactive:1
 A flag to tell that this slot is currently inactive.
 
int myInputClass = 0
 By default, all slots are class zero.
 
std::set< MemCore::RefPtr< ValueNotifier > > myNotifiers
 A set of possible value notifiers that are lurking for events here.
 
unsigned int pinned:2 = 0
 Specification whether this slot is considered relevant to be displayed in a certain application scenario.
 
string status
 An status for users, to be used to describe the current state this Slot relative to the current context where it is used.
 

Friends

const ValueSetPairoperator+= (const ValueSetPair &VSP, const VSlotPtr &VS)
 
const ValueSetPairoperator, (const ValueSetPair &VSP, const VSlotPtr &VS)
 

Related Symbols

(Note that these are not member symbols.)

typedef std::pair< const RefPtr< VSlot >, const RefPtr< ValuePool > > SlotContext
 Reference to an InputSlot plus context.
 

Additional Inherited Members

- Public Types inherited from MemCore::ReferenceBase< VSlot >
using reference_domain_t = VSlot
 The type of the base class.
 
using SelfPtr_t = WeakPtr< VSlot, VSlot >
 Type for a pointer to this object itself.
 
- Protected Member Functions inherited from MemCore::ReferenceBase< VSlot >
virtual void extremeUnction ()
 A virtual function that will be called just before the object is destroyed.
 
ReferenceBaseoperator= (const ReferenceBase &R)
 Protected assignment operator (should not be called).
 
void suicide ()
 Delete this.
 
virtual ~ReferenceBase ()
 Virtual destructor.
 

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");
}
A set of variable names, with indices associated to each type.
Definition Context.hpp:18

Class Documentation

◆ Wizt::VSlot::Empty

struct Wizt::VSlot::Empty
template<int = 0>
struct Wizt::VSlot::Empty< int >

Internal type for computational constructor.

It is templatized to avoid early instantiation of constructors that depend on this argument.

See also
VSlotContainer

Constructor & Destructor Documentation

◆ VSlot()

Wizt::VSlot::VSlot ( VSlotContainer 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 .

References inactive, and MemCore::ReferenceBase< VSlot >::self().

Member Function Documentation

◆ assignParameter()

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.

Returns
false if the provided parameter and member is already assigned, in which case this assignment does nothing.

RefPtr<VObject> MyOwner = getSlotOwner();

References getSlotName(), getSlotOwner(), and MemCore::Ageable::touch().

◆ attachSlot()

bool Wizt::VSlot::attachSlot ( const VSlotPtr SlotSource)

Connect another Slot's parameter here.

This slot's parameter will be removed.

References Wizt::VConnectable::attachSlot(), and MemCore::ReferenceBase< VSlot >::self().

◆ forceSetProperty()

template<class T >
bool Wizt::VSlot::forceSetProperty ( const string &  theName,
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.

◆ getExternalOwner()

WeakVObjectPtr Wizt::VSlot::getExternalOwner ( ) const

Get an external object only if this slot's parameter belongs to an object that is not its owner.

This is equivalent to checking

RefPtr< VManagedObject > getSource() const
Return a possible source object of this slot, telling where these values stem from.
Definition VSlot.hpp:658
const WeakPtrToVSlotContainer & getSlotOwner() const
Return the VObject that owns this current VSlot.
Definition VSlot.hpp:290

References getSlotOwner(), and getSource().

◆ getSlotOwner()

const WeakPtrToVSlotContainer & 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.

Referenced by assignParameter(), getExternalOwner(), and isNew().

◆ getSource()

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() .

Referenced by getExternalOwner(), Wizt::VObject::iterateParents(), and ~VSlot().

◆ getValue()

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.

Typical usage:

RefPtr<VSlot> mySlot = ...;
int MyInteger = 42;
if (mySlot->getValue( MyInteger, Context) )
{
std::cout << "Yes, this slot contains an integer, and its value is " << MyInteger << " relative to the given Context.";
}
A reference counting pointer class which keeps objects alive as long as strong pointers to these obje...
Definition RefPtr.hpp:405

◆ Globalize()

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.

◆ isNew()

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

bool isNewerThan(const Ageable &a) const noexcept
Comparison operator.
Definition Ageable.hpp:205
const Ageable & age(const RefPtr< ValuePool > &VP) const
Get the age of this value relative to the given value pool or the age of the most recent connection,...
Definition VSlot.cpp:197

References age(), and getSlotOwner().

◆ Localize()

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.

◆ operator/=()

const string & Wizt::VSlot::operator/= ( const string &  s)
inline
       Syntactic sugar to set the class for
       this slot such that it can be reused
       for other slots, e.g. as in
inSmoothTexture /=
inTextureBlend /=
inTextureField /=
inTextureShiftX /=
inTextureShiftY /=
inTextureScale /= "texture";

Make sure to call VObject::recognizeInputClass("texture") to make these slots "visible".

◆ setClass()

void Wizt::VSlot::setClass ( const string &  s)

◆ setProperty()

template<class T >
bool Wizt::VSlot::setProperty ( const string &  theName,
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.

◆ setPropertyIfNotExists()

template<class T >
bool Wizt::VSlot::setPropertyIfNotExists ( const string &  theName,
const T &  defaultValue 
) const
inline

Set a certain property of this parameter if it does not exist yet, and issue a notification event for the parameter's input object if it was created.

Returns
true if the parameter was set first time.
See also
forceSetProperty Set a property unconditionally.

◆ setValueFromText()

bool Wizt::VSlot::setValueFromText ( const string &  VariableText,
const RefPtr< ValuePool > &  VP,
const string &  theMember = {} 
)
inline

Set the parameter to a certain value from some textual description.

Parameters
VPThe value pool specifying the context. Has no effect if the parameter is not set to local.
Returns
false if the Slot value cannot be set, i.e. type mismatch or parse error.

◆ ValueAge()

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.

References getValueBase(), and MemCore::Ageable::InfinitelyOld().

Referenced by age().

Friends And Related Symbol Documentation

◆ operator+=

const ValueSetPair & operator+= ( const ValueSetPair VSP,
const VSlotPtr VS 
)
friend
RefPtr<ValueSet> Changeables = new ValueSet();
Changeables & R += nLines, X, Y, Z, Length, DistributionWidth;
A set of values.
Definition ValueSet.hpp:33
Definition OmegaPtrCheck.cpp:14
Definition elementary/memcore/test/shared_ptr/main.cpp:55

◆ operator,

const ValueSetPair & operator, ( const ValueSetPair VSP,
const VSlotPtr VS 
)
friend
RefPtr<ValueSet> Changeables = new ValueSet();
Changeables & R += nLines, X, Y, Z, Length, DistributionWidth;

Member Data Documentation

◆ AllowAutoConnection

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.

◆ cached

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
{
myObject()
{
input.cached = true;
}
update()
{
Ageable&CacheAge = ...;
if (YoungestUncachedInput(Context).isOlderThan( CacheAge ) )
{
// reuse cached result
return;
}
// compute new result
return
}
};
Base class for objects which change from time to time.
Definition Ageable.hpp:25
An input slot for VObjects, bound to a specific type.
Definition TypedSlot.hpp:57
Generic base class for all VObjects.
Definition VObject.hpp:186

The function VObject::YoungestUncachedInput() will determine the youngest age of all input slots that are have not set cached to be enabled.

◆ ignoreConnectionAge

unsigned int Wizt::VSlot::ignoreConnectionAge

A flag to tell whether the connection age should be ignored when checking whether this Slot has changed during an update().

This is useful for Actions, for instance.

Referenced by age().

◆ inactive

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.

Referenced by VSlot().

◆ myInputClass

int Wizt::VSlot::myInputClass = 0

By default, all slots are class zero.

By default, all slots that are not class zero will be ignored

  • they must be recognized to via recognizeInputClass() be usable.
    See also
    VInputClass::getClass() Possible code with a VObject*that :
    inSeaLevel /=
    inContourThickness /=
    inHeightness /=
    inContourIntensity /=
    inVerticalGridScale /=
    inHorizontalGridScale /=
    that->recognizeInputClass("ContourLines");

Referenced by setClass().

◆ pinned

unsigned int Wizt::VSlot::pinned

Specification whether this slot is considered relevant to be displayed in a certain application scenario.

Two bits are available to manage four levels of relevance.