Fish - FiberLib for VISH 0.3
Fish - The Fiber Bundle API for the Vish Visualization Shell
Fiber::OnDemandCreator< Computer, Rank, result_value_type > Class Template Reference

A Creator object that allows to create data on demand, when they are used and accessed. More...

#include <OnDemandCreator.hpp>

Inheritance diagram for Fiber::OnDemandCreator< Computer, Rank, result_value_type >:
Fiber::CreativeArrayBase MemCore::CreatorBase< MemBase > Fiber::Ownable< CreativeArrayBase, CreativeArrayBaseContainerBase > Fiber::SaveableAttributes Fiber::OwnerBase MemCore::Attributes

Classes

struct  Exception
 Associated Exception class. More...

Public Types

enum  Dims_t { RANK = Rank }
typedef result_value_type value_type
 The type of values provided by the associated data set.
Public Types inherited from Fiber::CreativeArrayBase
enum class  CreationFailure {
  None , OutOfMemory , CannotOpen , CannotRead ,
  CannotSave , Timeout , Unknown
}
Public Types inherited from Fiber::OwnerBase
template<class ItemType>
using Item = MemCore::InterfaceData<ItemType>
 An optional convenience class that allows to easily add arbitrary types to Intercubes .

Public Member Functions

 OnDemandCreator (const Constructor_t &myConstructor, const MemCore::RefPtr< MemCore::Cache > &theCache)
 Construct an OnDemand Creator.
Creature::ReasonForReleasal release () override
bool hasData () const override
const std::type_infogetType () override
MemCore::CacheablePtr getCacheable () const override
RefPtr< MemBaseget () const override
RefPtr< MemBasetake () override
RefPtr< MemBaseproduce () override
 The data creation: Create an object of type Computer (the template argument), passing the constructor object from the Computer's class and a weak ptr to the creator, such as in:
Public Member Functions inherited from Fiber::CreativeArrayBase
 CreativeArrayBase (const MemCore::WCachePtr &theCache)
Ageabletouch () throw ()
const AgeabletouchAttributes () const
const AgeableupdateAttributeAge (const Ageable &A) const
void extremeUnction ()
bool needsSaving () const
 Check if the data here need to be saved, i.e.
void hasBeenSaved () const
 Indicate that this dataset has been saved and does not need to be saved again.
void addDataMetaInfo (const MemCore::RefPtr< MemBase > &D)
 Set the type and size interfaces according to the given data.
const FiberTypeIndexgetFiberTypeIndex () const
auto value_type_size () const
 How many bytes this object occupies in memory.
RefPtr< FiberTypeBasegetFiberType () const
void setFiberType (const RefPtr< FiberTypeBase > &FTB)
template<class ... T>
bool isType () const
void addMetaInfo (const DynamicSize &theSize, const RefPtr< FiberTypeBase > &theDataType)
void addMetaInfo (int nDimensions, const RefPtr< FiberTypeBase > &theDataType)
RefPtr< BinderBasegetBinder () const
 Get the Binder from the Bundle where this Creator is contained, processing via Bundle::processOwnership(), which may be relatively slow.
void save (const MemCore::RefPtr< MemBase > &D) const
 Passes the data object backwards through the ownership hierarchy, ultimately calling Bundle::processOwnership() which in turn calls Binder::save().
Public Member Functions inherited from MemCore::CreatorBase< MemBase >
RefPtr< Domain > create (bool CreateAsOld=false)
RefPtr< Domain > createAsOld ()
 CreatorBase (const WCachePtr &theCache)
RefPtr< Domain > get_or_request (const result &R=nullptr)
bool isUnderCreation () const override
virtual bool request (const result &R=nullptr)
Public Member Functions inherited from Fiber::Ownable< CreativeArrayBase, CreativeArrayBaseContainerBase >
void x_updateOwnershipAge (const MemCore::Ageable &theNewAge) override
 Forward some age to all Owners.
void insertOwner (const Container &theOwner)
 Add some owner.
void addOwner (const Container &theOwner, const MemCore::Ageable &theNewAge)
 Add some owner and broadcast a new age to all Ownerrs.
 Ownable ()
 Default constructor, empty Ownership list.
Ownableoperator= (const Ownable &)
 Assignment, does NOT copy any ownership information, the assigned Ownable will retain all its ownership information.
MemCore::WeakPtr< Container > getPrimaryOwner () const
 Get the first valid owner.
size_t getNumberOfValidOwners () const
 Get the first valid owner.
bool processOwnership (MemCore::Intercube &Output, const MemCore::Intercube &Input) const override
 Process some ownership action.
Public Member Functions inherited from Fiber::OwnerBase
bool processOwnership (MemCore::Intercube &OutputAndInput) const
 Process ownership where the input information is shared with the output information in the same Intercube.
Public Member Functions inherited from Fiber::SaveableAttributes
void attributesHaveBeenSaved () const
bool attributesNeedSaving () const
Public Member Functions inherited from MemCore::Attributes
MemCore::RefPtr< MemCore::ChunkBasegetAttribute (const std::string &name) const
const AgeablegetAttributeAge () const
std::pair< bool, T > getAttributeValue (const string &AttributeName, size_t ElementNumber=0) const
attributes_t & getAttributeValues ()
const attributes_t & getAttributeValues () const
size_t getNumberOfAttributes () const
bool hasAttribute (const std::string &name) const
int Iterate (const Functor &L) const
int iterate (Iterator &it) const
int iterate_attributes (const Functor &L) const
size_t NumberOfAttributes () const
void setAttribute (const std::string &name, const MemCore::RefPtr< MemCore::ChunkBase > &AttribData)
ResizableChunk< T > & setAttributeValue (const std::string &name, const T &AttribData)
ResizableChunk< T > & setAttributeValues (const std::string &name, const std::initializer_list< T > &AttribData)
const T & setValue (const T &AttribData, const std::string &name)
const T & setValue (const T &AttribData, const std::string &name, const std::string &Comment, const std::string &CommentPrefix="Comment")
string toString () const
const AgeabletouchAttributes () const
const AgeableupdateAttributeAge (const Ageable &A) const

Static Public Member Functions

static WeakPtr< FiberTypeBasegetFiberType ()
 The FiberType that is associated with this data set.
Static Public Member Functions inherited from Fiber::CreativeArrayBase
static bool retryCreation (CreativeArrayBase &)

Additional Inherited Members

Public Attributes inherited from Fiber::CreativeArrayBase
AgeRelativeToBinder LastSavedTimes
enum Fiber::CreativeArrayBase::CreationFailure Error = CreationFailure::None
Public Attributes inherited from Fiber::Ownable< CreativeArrayBase, CreativeArrayBaseContainerBase >
std::unordered_set< MemCore::WeakPtr< Container > > Owners
 The (internal) list of owners.
Public Attributes inherited from Fiber::SaveableAttributes
MemCore::Ageable LastSavedAttributes
Protected Attributes inherited from Fiber::CreativeArrayBase
FiberTypeIndex myFiberTypeIndex
MemCore::WeakPtr< FiberTypeBasemyFiberTypeBase

Detailed Description

template<class Computer, Dims_t Rank = Computer::ResultArray_t::Dims, typename result_value_type = typename Computer::ResultArray_t::value_type>
class Fiber::OnDemandCreator< Computer, Rank, result_value_type >

A Creator object that allows to create data on demand, when they are used and accessed.

For instance, some Field may be defined on a Grid whose values are computed once the Field is accessed. Providing such an On-Demand-Field does neither require computational nor memory resources.

The computational logic is put in the template argument Computer. It must

  1. provide an type ResultArray_t, which is derived from a MemBase; the type ResultArray_t must define a type value_type which will be used as the value type of this Creator.
  2. provide a type Constructor_t, which is used to communicate data from the Creator to the actual Computer object. The Computer object is create dynamically with a copy of the data provided at the constructor of the OnDemandCreator.
  3. provide a constructor that takes one argument of type Constructor_t .
  4. provide a member function result() which returns a type that is convertible to RefPtr<MemBase>
struct Compute
{
typedef MemArray<1, double> ResultArray_t;
typedef index_t Constructor_t;
RefPtr<ResultArray_t> result_storage;
Compute(index_t howmany, const MemBase::Creator_t&C)
{
result_storage = new ResultArray_t(howmany, C);
}
{
return result_storage;
}
};
Class for N-dimensional MultiArrays with MemCore memory management.
Definition MemArray.hpp:34
OnDemandCreator(const Constructor_t &myConstructor, const MemCore::RefPtr< MemCore::Cache > &theCache)
Construct an OnDemand Creator.
Definition OnDemandCreator.hpp:104
StrongPtr< Object, ObjectBase > RefPtr
IndexTypeConfig< sizeof(void *)>::index_t index_t
Define the index type as according to the size of a pointer, i.e.
Definition Index.hpp:22
Todo
Revise, derive from CreativeArray and overload the Producer instead.

Member Enumeration Documentation

◆ Dims_t

template<class Computer, Dims_t Rank = Computer::ResultArray_t::Dims, typename result_value_type = typename Computer::ResultArray_t::value_type>
enum Fiber::OnDemandCreator::Dims_t
Enumerator
RANK 

The dimensionality of the data set.

Member Function Documentation

◆ get()

template<class Computer, Dims_t Rank = Computer::ResultArray_t::Dims, typename result_value_type = typename Computer::ResultArray_t::value_type>
RefPtr< MemBase > Fiber::OnDemandCreator< Computer, Rank, result_value_type >::get ( ) const
inlineoverridevirtual

◆ getType()

template<class Computer, Dims_t Rank = Computer::ResultArray_t::Dims, typename result_value_type = typename Computer::ResultArray_t::value_type>
const std::type_info & Fiber::OnDemandCreator< Computer, Rank, result_value_type >::getType ( )
inlineoverridevirtual

◆ produce()

template<class Computer, Dims_t Rank = Computer::ResultArray_t::Dims, typename result_value_type = typename Computer::ResultArray_t::value_type>
RefPtr< MemBase > Fiber::OnDemandCreator< Computer, Rank, result_value_type >::produce ( )
inlineoverride

The data creation: Create an object of type Computer (the template argument), passing the constructor object from the Computer's class and a weak ptr to the creator, such as in:

Computer MyComputer( MyConstructor, self() );

Then the Computer's result() function will be called to get the data array, which is the data object to be cached and returned here.

◆ take()

template<class Computer, Dims_t Rank = Computer::ResultArray_t::Dims, typename result_value_type = typename Computer::ResultArray_t::value_type>
RefPtr< MemBase > Fiber::OnDemandCreator< Computer, Rank, result_value_type >::take ( )
inlineoverridevirtual

Reimplemented from MemCore::CreatorBase< MemBase >.