The Vish Visualization Shell 0.3
Vish
Classes | Public Member Functions | Static Public Member Functions | List of all members
Wizt::ValuePool Class Reference

A ValuePool is the home of local values of certain input objects. More...

#include <ocean/plankton/ValuePool.hpp>

Inheritance diagram for Wizt::ValuePool:
MemCore::ReferenceBase< ValuePool > MemCore::Intercube

Classes

struct  iterator
 An iterator to traverse the existing value pools. More...
 
struct  VarMap_t
 

Public Member Functions

const string & Name () const
 Return the name, a textual identifier, for this ValuePool.
 
VObjectAgeObjectAgePool ()
 A pool of object ages.
 
bool setName (const string &name)
 Rename a value pool.
 
 ValuePool ()
 Constructor, should set identifier name later since the default name is somewhat unique, but weird.
 
 ValuePool (const string &name)
 Constructor with name (may be changed later, too)
 
 ~ValuePool ()
 Destructor.
 
Interface for Named Variables
WeakPtr< VValueBaseretrieveValue (const string &name) const
 If a certain variable is stored under a certain name, retrieve it now.
 
bool registerValue (const string &name, const WeakPtr< VValueBase > &val)
 Allow to store a certain variable under the specified name.
 
bool removeValue (const string &name)
 Remove the association of a local variable with a name.
 
Interface for Keyed Variables
RefPtr< VValueBasefindVariable (const Key_t &Key) const
 Find the value of an variable that is associated with the specified key, if present.
 
void createVariable (const Key_t &Key, const RefPtr< VValueBase > &v)
 Create the shadow of a variable in this pool, using the specified value.
 
void removeVariable (const Key_t &Key)
 Remove a variable's shadow from this pool.
 
void activate (const RefPtr< ValuePool, ValuePool > &OldPool, const WeakPtr< ValueNotifier > &who=NullPtr(), const ValueMap *VP=0) const
 Activate this set of variables, which induces sending a notification request (i.e.
 
- Public Member Functions inherited from MemCore::ReferenceBase< ValuePool >
auto getObjectCountID () const noexcept
 Get a unique ID for this object in the given domain.
 
bool isIdentical (const WeakPtr< ValuePool, ValuePool > &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 (ValuePool *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.
 
- Public Member Functions inherited from MemCore::Intercube
void addInterface (const RefPtr< InterfaceBase > &I) const
 Add an interface class object.
 
template<class Data >
void addInterfaceData (const Data &D)
 Add data via an interface class object.
 
template<class Data , typename TypeSelector >
void addInterfaceData (const Data &D)
 Add data via an interface class object.
 
void clearInterfaces ()
 Remove all interfaces.
 
bool const_iterateInterfaces (const RefPtr< InterfaceIterationParameter > &IIP) const
 Constant iterator.
 
virtual RefPtr< InterfaceBasecreateInterface (const type_info &) const
 Virtual function which allows derived objects to create Interface objects on demand.
 
RefPtr< InterfaceBasefindInterface (const type_info &t) const
 Find a certain interface of specified type.
 
RefPtr< InterfaceBasegetInterface (const type_info &t)
 Retrieve an interface object from a certain type.
 
std::string getInterfaceNames (const char delim=';') const
 Debug function retrieving all interfaces as human-readable string.
 
template<class Data >
bool gotNewInterfaceData (const Data &D)
 Check whether data on the given interface have changed, and if so, set new data as interface.
 
template<class Data >
bool gotNewInterfaceData (mutex &M, const Data &D)
 Check whether interface data have changed, if so, then set new interface data and return true.
 
template<class Data , typename Selector >
bool gotNewInterfaceData (mutex &M, const Data &D)
 Check whether interface data have changed, if so, then set new interface data and return true.
 
template<class Data , typename Selector >
bool gotNewInterfaceData (mutex &M, const Data &D, const Selector &S)
 Check whether interface data have changed, if so, then set new interface data and return true.
 
template<class Data , typename Selector >
bool gotNewInterfaceData (mutex &M, const Data &D, const Selector *S)
 Check whether interface data have changed, if so, then set new interface data and return true.
 
template<class Data >
bool hasChangedInterfaceData (const Data &D) const
 Check whether interface data have changed.
 
template<class Data , typename Selector >
bool hasChangedInterfaceData (const Data &D) const
 Check whether interface data have changed.
 
template<class Data , typename Selector >
bool hasChangedInterfaceData (const Data &D, const Selector &) const
 Check whether interface data have changed.
 
template<class Data , typename Selector >
bool hasChangedInterfaceData (const Data &D, const Selector *) const
 Check whether interface data have changed.
 
bool hasInterface (const type_info &t) const
 Check if some Interface might exist.
 
 Intercube ()
 Constructor.
 
bool iterateInterfaces (const RefPtr< InterfaceIterationParameter > &IIP)
 Modifyable iterator.
 
void printInterfaces () const
 Debug function that prints the names of all interfaces.
 
void registerInterface (const type_info &t)
 Register an interface type; when the interface is actually required, the virtual createInterface() function will be called.
 
template<class InterfaceType >
void removeInterface ()
 Remove an interface.
 
void removeInterfaceBase (const type_info &InterfaceBaseID)
 Remove an interface.
 
virtual ~Intercube ()
 Destructor.
 

Static Public Member Functions

static WeakPtr< ValuePool, ValuePoolgetValuePool (const string &name)
 Get a value pool that is associated with a certain name in the global database.
 

Additional Inherited Members

- Public Types inherited from MemCore::ReferenceBase< ValuePool >
using reference_domain_t = ValuePool
 The type of the base class.
 
using SelfPtr_t = WeakPtr< ValuePool, ValuePool >
 Type for a pointer to this object itself.
 
- Protected Member Functions inherited from MemCore::ReferenceBase< ValuePool >
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

A ValuePool is the home of local values of certain input objects.

When an input object is queried for its value, a VContext is specified. This VContext may refer to a pool of alternative copies.

The ValuePool provides two interfaces to access stored values:

However, the ValuePool may also host a local copy of variables which co-exist permanently. They are used by the VParameter only if it set to local, but are not destroyed when switching to global. As such, these local values may well reside as part of multiple VObjects.

Class skeleton (main purpose is to map ValueNotifierLists to VValueBases. It's basic structure is of the type

class ValuePool : public map<WeakPtr<ValueNotifierList>, RefPtr<VValueBase> >
{};
A ValuePool is the home of local values of certain input objects.
Definition ValuePool.hpp:58

whereby a ValuePool provides some additional properties like being an Intercube and a mutex for multithreaded operations. However, it should be avoided to lock an operation on a ValuePool since accessing the ValuePool is a very frequent operation.

Examples
LocalCompoundInput.cpp.

Constructor & Destructor Documentation

◆ ValuePool()

Wizt::ValuePool::ValuePool ( )

Constructor, should set identifier name later since the default name is somewhat unique, but weird.

Calling this constructor should be avoided.

References MemCore::ReferenceBase< ValuePool >::self().

Member Function Documentation

◆ activate()

void Wizt::ValuePool::activate ( const RefPtr< ValuePool, ValuePool > &  OldPool,
const WeakPtr< ValueNotifier > &  who = NullPtr(),
const ValueMap VP = 0 
) const

Activate this set of variables, which induces sending a notification request (i.e.

ValueNotifier::valueChanged() ) for all stored values.

Parameters
OldPoolThe previous pool of variables. It is required to determine which variables are changing at this activate() request and should receive a notify() call. Such circumstances arise when
  1. a local variable doesn't exist in this pool, i.e. its global value is used now
  2. or a variable is local in the new pool

Broadcast a value change event to all listening notifiers.

References findVariable(), Name(), MemCore::ReferenceBase< ValuePool >::self(), and MemCore::DynPtr< Object, ObjectBase >::speak().

◆ createVariable()

void Wizt::ValuePool::createVariable ( const Key_t Key,
const RefPtr< VValueBase > &  v 
)

Create the shadow of a variable in this pool, using the specified value.

Parameters
KeyThe notifier list, which is used as reference
vAn existing variable, which contains the value.

◆ getValuePool()

WeakPtr< ValuePool > Wizt::ValuePool::getValuePool ( const string &  name)
static

Get a value pool that is associated with a certain name in the global database.

It is not recommended to use this function, value pools should always be passed to calling routines that need them.

◆ removeValue()

bool Wizt::ValuePool::removeValue ( const string &  name)

Remove the association of a local variable with a name.

Note that this association is removed anyway on destruction of a local variable since only weak pointers are stored here.