|
The Vish Visualization Shell 0.3
Vish
|
A Creator is a forwarding of some data object to its creational object. More...
#include <elementary/memcore/Creator.hpp>
Public Member Functions | |
| Creator (const RefPtr< RefType > &D, const WCachePtr &MyCache) | |
| Construct a creator with a data object. | |
| RefPtr< RefType > | get () const override |
| A passive function to return the current Data object if it exists. | |
| CacheablePtr | getCacheable () const override |
| A passive function to return the current Data object if it exists. | |
| const type_info & | getType () override |
| It is assumed that the Data object provides a getType() function retrieving the actual operational value type id. | |
| bool | hasData () const override |
| Tell whether data exist here. | |
| Creature::ReasonForReleasal | release () override |
| Release operation, nothing can be done here. | |
| bool | supersede (const RefPtr< Domain > &NewData, bool CreateAsOld=false) |
| Replace the data stored here (if any) by another data set. | |
| RefPtr< RefType > | take () override |
| An active function to take the strong pointer out of here. | |
| Public Member Functions inherited from MemCore::CreatorBase< Domain > | |
| RefPtr< Domain > | create (bool CreateAsOld=false) |
| Actually create the object, using an existing one if existent via the get() function, otherwise calling the virtual produce() function. | |
| RefPtr< Domain > | createAsOld () |
| Get and possibly create data here without touching it, which is useful if the data is required only temporary. | |
| CreatorBase (const WCachePtr &theCache) | |
| Construct with Cache object given. | |
| RefPtr< Domain > | get_or_request (const result &R=nullptr) |
| Asynchronous data access: Get the data if available, otherwise request them if possible and return nullptr. | |
| bool | isUnderCreation () const override |
| return true while a request issued by the producer is still ongoing | |
| virtual bool | request (const result &R=nullptr) |
| Asynchron mode: Request data to be created. | |
Protected Member Functions | |
| Creator (const WCachePtr &MyCache) | |
| Constructor for no data yet. | |
| RefPtr< RefType > | produce () override |
| Object creation function (just returns the object which was specified during construction). | |
A Creator is a forwarding of some data object to its creational object.
Instead of referring to data objects, one can refer to CreatorBase's to this data object domain, and install Creators on this object by default. The references to the CreatorBase can be used like references to the objects, but optionally something else than an Creator of the object can be installed there. In this case, the object does not exist right from the beginning, but its creation is delayed until access.
Example code Instead of
use
|
inline |
Construct a creator with a data object.
Note that if the RefType is a Cacheable, it rather needs to get this Creator object defined as its creator (see Cacheable::setCreator() ). This constructor does not do this, because the RefType object might be anything refcountable. To automatize such functionality it needs to be implemented in a domain-specific base class.
Note that Caching is NOT activated at this moment, need to call Data::enableCaching() once this creator has been referenced.