The Vish Visualization Shell 0.3
Vish
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Wizt::VOperatorCache< OperatorData > Struct Template Reference

The Operator Cache is used to memorize the result of some update() operation, and to provide it to other routines knowing the same value pool context. More...

#include <ocean/plankton/VOperatorCache.hpp>

Inheritance diagram for Wizt::VOperatorCache< OperatorData >:
MemCore::ReferenceBase< VOperatorCache< OperatorData > > MemCore::Intercube

Classes

struct  Cache
 A Cache object, that assigns an OperatorCache with each VObject. More...
 

Public Member Functions

bool unchanged (const RefPtr< ValueSet > &VS)
 Compare and assign a set of variable values.
 
 VOperatorCache ()
 Constructor.
 
- Public Member Functions inherited from MemCore::ReferenceBase< VOperatorCache< OperatorData > >
auto getObjectCountID () const noexcept
 Get a unique ID for this object in the given domain.
 
bool isIdentical (const WeakPtr< VOperatorCache< OperatorData >, VOperatorCache< OperatorData > > &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 (VOperatorCache< OperatorData > *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 Cacheretrieve (Intercube &IC)
 Create a Cache object that is associated with an arbitrary Intercube.
 

Public Attributes

RefPtr< ValueSetChangeables
 The set of associated variable values.
 

Additional Inherited Members

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

template<class OperatorData>
struct Wizt::VOperatorCache< OperatorData >

The Operator Cache is used to memorize the result of some update() operation, and to provide it to other routines knowing the same value pool context.

Provided we want to memorize a vector of doubles, then we simply instantiatee the OperatorCache template over this data type:

typedef OperatorCache<std::vector<double> > OC_t;

Now in the update() function we may get an operator cache given some Intercube object - for instance some field from the FiberLib2 library - (which relates to some driving input data) and a self() pointer:

bool VObject::update(VRequest&R, double precision)
{
RefPtr<Field> Vectors;
RefPtr<OC_t>&OC = OC_t::retrieve( *Vectors ) [ self() ];
if (!OC) OC = new OC_t();
}
const auto & self() const
Return weak pointer to the object self.
Definition RefPtr.hpp:1062
A reference counting pointer class which keeps objects alive as long as strong pointers to these obje...
Definition RefPtr.hpp:405
virtual bool update(VRequest &, double precision=1.0)
Virtual update function that implements some heavy action on the object.
Definition VObjectRequest.cpp:32
Request structure.
Definition VRequest.hpp:24

The OperatorCache contains a set of variable values, i.e. a ValueSet. The purpose is to associate the OperatorCache with such a set of values. If any of these values has changed since the last update() call, then the OperatorCache needs to be filled with data from a new computation. A ValueSet that contains the parameters of such a compuation is easily created by providing an evaluation context (via the &-operator) and then add VSlot's (via the += and comma operator). The unchanged() member function checks if any differences among the values stored with the OperatorCache and the current values had occured:

Changeables & R += nLines, X, Y, Z, Length, DistributionWidth;
if (OC->unchanged( Changeables ) )
{
return true;
}
A set of values.
Definition ValueSet.hpp:33
RefPtr< ValueSet > Changeables
The set of associated variable values.
Definition VOperatorCache.hpp:68
Definition OmegaPtrCheck.cpp:14
Definition elementary/memcore/test/shared_ptr/main.cpp:55

If there had been changes, they are implicitely assigned by the unchanged() member function and the following code is supposed to compute new data.

@TODO Redesign to take care of local variable values implicitely.

Member Function Documentation

◆ retrieve()

template<class OperatorData >
static Cache & Wizt::VOperatorCache< OperatorData >::retrieve ( Intercube IC)
inlinestatic

Create a Cache object that is associated with an arbitrary Intercube.

If the Intercube goes away, to will this Cache object. If the given Intercube doesn't have a Cache object yet, one will be created.

A typical application example is a time-dependend field, where each time slice of the field is an Intercube, such that an operator cache can be associated with it.

References MemCore::Intercube::addInterface().

◆ unchanged()

template<class OperatorData >
bool Wizt::VOperatorCache< OperatorData >::unchanged ( const RefPtr< ValueSet > &  VS)
inline

Compare and assign a set of variable values.

Note
A repeated call of this function will always return true.

References Wizt::VOperatorCache< OperatorData >::Changeables.