A Creator object that allows to create data on demand, when they are used and accessed.
More...
#include <OnDemandCreator.hpp>
List of all members.
Public Types
- enum { RANK = ResultArray_t::Dims
}
-
typedef ResultArray_t::value_type value_type
- The type of values provided by the associated data set.
Public Member Functions
-
OnDemandCreator (const Constructor_t &myConstructor, const MemCore::RefPtr< MemCore::Cache > &theCache)
- Construct an OnDemand Creator.
-
override bool release ()
-
override bool hasData () const
-
override const std::type_info & getType ()
-
override RefPtr< MemBase > get () const
-
override RefPtr< MemBase > create ()
Static Public Member Functions
Detailed Description
template<class Computer>
class Fiber::OnDemandCreator< Computer >
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
- 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.
- 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.
- provide a constructor that takes one argument of type Constructor_t .
- 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);
}
RefPtr<ResultArray_t> result() const
{
return result_storage;
}
};
RefPtr<CreativeArrayBase> cab = new OnDemandCreator<Compute>(123);
Member Enumeration Documentation
template<class Computer >
- Enumerator:
RANK |
The dimensionality of the data set.
|