|
The Vish Visualization Shell 0.3
Vish
|
A domain for objects which may be cached. More...
#include <elementary/memcore/Cacheable.hpp>
Public Types | |
| using | cachecounter_t = unsigned long |
| The type to store repeated accesses to a cached object. | |
Public Types inherited from MemCore::ReferenceBase< Cacheable > | |
| using | reference_domain_t = Cacheable |
| The type of the base class. | |
| using | SelfPtr_t = WeakPtr< Cacheable, Cacheable > |
| Type for a pointer to this object itself. | |
Public Member Functions | |
| Cacheable (const WeakPtr< Creature > &C) | |
| Constructor. | |
| virtual void | DeferredConstructor () |
| A virtual function that is called on the first strong referencing of a Cacheable object. | |
| bool | isCached () const |
| Check whether this object is managed by a cache queue. | |
| bool | isUncached () const |
| Check whether this object is managed by a cache queue. | |
| bool | markAsUsed () |
| Mark this data object as being recently used. | |
| virtual memsize_t | memsize () const =0 |
| Ask how many bytes this object occupies. | |
| WeakPtr< CacheBase > | myCache () const |
| Return the associated Cache object as known from the associated Creator, if any. | |
| const WeakPtr< Creature > & | myCreator () const |
| Return the associated Creator, if any. | |
| int | NumberOfListEntries () const |
| Count the number of entries here. | |
| void | PreDestructor () |
| This class uses a predestructor to remove itself's size from the cache queue. | |
| void | push_back (CacheQueue &Q) |
| Put the current item onto the BACK of the given cache queue. | |
| void | push_front (CacheQueue &Q) |
| Put the current item onto the FRONT of the given cache queue. | |
| void | setCreator (const WeakPtr< Creature > &C) |
| Set and the creator. | |
Public Member Functions inherited from MemCore::ReferenceBase< Cacheable > | |
| auto | getObjectCountID () const noexcept |
| Get a unique ID for this object in the given domain. | |
| bool | isIdentical (const WeakPtr< Cacheable, Cacheable > &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 (Cacheable *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. | |
Protected Member Functions | |
| void | adjustCacheableSize (memsize_t memDiff) |
| In case this object changes its size after insertion to the CacheQueue, call this function to adjust. | |
| ~Cacheable () | |
| Destructor. | |
Protected Member Functions inherited from MemCore::ReferenceBase< Cacheable > | |
| virtual void | extremeUnction () |
| A virtual function that will be called just before the object is destroyed. | |
| ReferenceBase & | operator= (const ReferenceBase &R) |
| Protected assignment operator (should not be called). | |
| void | suicide () |
| Delete this. | |
| virtual | ~ReferenceBase () |
| Virtual destructor. | |
A domain for objects which may be cached.
Cacheable objects must be derived from this base class such that a WeakPtrImpl<Cacheable> may point to such object and becomes notified when the object is removed. Any child classes must overload the virtual memsize() to tell the Cache class how costly the storage of objects of this kind is. Note that the memsize() does not necessarily need to be given in bytes, any other unit is acceptable as long as the same is used consistently for all objects that are assigned to the same Cache object.
|
protected |
In case this object changes its size after insertion to the CacheQueue, call this function to adjust.
Alternatively, the cachequeue's memsize could be recomputed, but is much more effortsome.
Referenced by MemCore::MutableCacheable::adjustCurrentMemsize().
|
virtual |
A virtual function that is called on the first strong referencing of a Cacheable object.
This (usually) is not possible within the constructor, so it may be assumed that the object has been completely constructed. The implementation of this function may thus perform operations on the object which should be done automatically when objects of this kind are created, but they may be aware of the full object status which is not possible in the constructor.
| bool MemCore::Cacheable::markAsUsed | ( | ) |
Mark this data object as being recently used.
This is the same as touching the data, but touch() is also used in the Ageable class, so here we use another name to avoid confusion.
References myCache(), MemCore::CacheQueue::push_front(), and MemCore::ReferenceBase< Cacheable >::self().
Referenced by Wizt::AnemoneCreator< AnemoneInitializer >::produce().
| int MemCore::Cacheable::NumberOfListEntries | ( | ) | const |
Count the number of entries here.
Never call this function, it is maximally slow.
| void MemCore::Cacheable::PreDestructor | ( | ) |
This class uses a predestructor to remove itself's size from the cache queue.
This could not be done in the "official" destructor itself because it depends on the call of the virtual function memsize() which is no longer available in the destructor.
References memsize(), myCache(), and MemCore::ReferenceBase< Cacheable >::self().
| void MemCore::Cacheable::push_back | ( | CacheQueue & | Q | ) |
Put the current item onto the BACK of the given cache queue.
The memory sizes of the current and new cache queues will be adjusted.
References memsize().
Referenced by MemCore::CacheMultiQueue::adjust().
| void MemCore::Cacheable::push_front | ( | CacheQueue & | Q | ) |
Put the current item onto the FRONT of the given cache queue.
The memory sizes of the current and new cache queues will be adjusted.
References memsize().