Castor3D 0.12.0
Multiplatform 3D engine
Public Types | Public Member Functions | List of all members
castor3d::CacheViewT< CacheT, EventT > Class Template Reference

#include <CacheView.hpp>

Inheritance diagram for castor3d::CacheViewT< CacheT, EventT >:
Inheritance graph
[legend]
Collaboration diagram for castor3d::CacheViewT< CacheT, EventT >:
Collaboration graph
[legend]

Public Types

using ElementCacheT = CacheT
 
using ElementT = typename ElementCacheT::ElementT
 
using ElementKeyT = typename ElementCacheT::ElementKeyT
 
using ElementCacheTraitsT = typename ElementCacheT::ElementCacheTraitsT
 
using ElementPtrT = typename ElementCacheT::ElementPtrT
 
using ElementObsT = typename ElementCacheT::ElementObsT
 
using ElementContT = typename ElementCacheT::ElementContT
 
using ElementInitialiserT = typename ElementCacheT::ElementInitialiserT
 
using ElementCleanerT = typename ElementCacheT::ElementCleanerT
 
using ElementMergerT = typename ElementCacheT::ElementMergerT
 

Public Member Functions

 CacheViewT (castor::String const &name, ElementCacheT &cache, ElementInitialiserT initialise=[](ElementObsT const &){}, ElementCleanerT clean=[](ElementObsT const &){})
 Constructor. More...
 
 ~CacheViewT ()=default
 Destructor. More...
 
void clear ()
 Removes from the cache the elements created through this view. More...
 
template<typename ... ParametersT>
ElementObsT add (ElementKeyT const &name, ParametersT &&... params)
 Creates an element with the given informations. More...
 
template<typename ... ParametersT>
ElementObsT tryAdd (ElementKeyT const &name, bool initialise, ElementObsT &created, ParametersT &&... params)
 Creates or retrieves an element with the given informations. More...
 
bool tryAdd (ElementKeyT const &name, ElementPtrT &element, bool initialise=false)
 adds an already created an element. More...
 
ElementObsT add (ElementKeyT const &name, ElementPtrT &element, bool initialise=false)
 adds an already created an element. More...
 
bool isEmpty () const
 
bool has (ElementKeyT const &name) const
 
ElementObsT tryFind (ElementKeyT const &name) const
 Looks for an element with given name. More...
 
ElementObsT find (ElementKeyT const &name) const
 Looks for an element with given name. More...
 
ElementObsT tryRemove (ElementKeyT const &name)
 Removes an element, given a name. More...
 
void remove (ElementKeyT const &name)
 Removes an object, given a name. More...
 
Iteration.
auto begin ()
 
auto begin () const
 
auto end ()
 
auto end () const
 

Detailed Description

template<typename CacheT, EventType EventT>
class castor3d::CacheViewT< CacheT, EventT >

View on a resource cache.

Remarks
Allows deletion of elements created through the view, and only those.

Member Typedef Documentation

◆ ElementCacheT

template<typename CacheT , EventType EventT>
using castor3d::CacheViewT< CacheT, EventT >::ElementCacheT = CacheT

◆ ElementCacheTraitsT

template<typename CacheT , EventType EventT>
using castor3d::CacheViewT< CacheT, EventT >::ElementCacheTraitsT = typename ElementCacheT::ElementCacheTraitsT

◆ ElementCleanerT

template<typename CacheT , EventType EventT>
using castor3d::CacheViewT< CacheT, EventT >::ElementCleanerT = typename ElementCacheT::ElementCleanerT

◆ ElementContT

template<typename CacheT , EventType EventT>
using castor3d::CacheViewT< CacheT, EventT >::ElementContT = typename ElementCacheT::ElementContT

◆ ElementInitialiserT

template<typename CacheT , EventType EventT>
using castor3d::CacheViewT< CacheT, EventT >::ElementInitialiserT = typename ElementCacheT::ElementInitialiserT

◆ ElementKeyT

template<typename CacheT , EventType EventT>
using castor3d::CacheViewT< CacheT, EventT >::ElementKeyT = typename ElementCacheT::ElementKeyT

◆ ElementMergerT

template<typename CacheT , EventType EventT>
using castor3d::CacheViewT< CacheT, EventT >::ElementMergerT = typename ElementCacheT::ElementMergerT

◆ ElementObsT

template<typename CacheT , EventType EventT>
using castor3d::CacheViewT< CacheT, EventT >::ElementObsT = typename ElementCacheT::ElementObsT

◆ ElementPtrT

template<typename CacheT , EventType EventT>
using castor3d::CacheViewT< CacheT, EventT >::ElementPtrT = typename ElementCacheT::ElementPtrT

◆ ElementT

template<typename CacheT , EventType EventT>
using castor3d::CacheViewT< CacheT, EventT >::ElementT = typename ElementCacheT::ElementT

Constructor & Destructor Documentation

◆ CacheViewT()

template<typename CacheT , EventType EventT>
castor3d::CacheViewT< CacheT, EventT >::CacheViewT ( castor::String const &  name,
ElementCacheT cache,
ElementInitialiserT  initialise = [](ElementObsT const &){},
ElementCleanerT  clean = [](ElementObsT const &){} 
)
inline

Constructor.

Parameters
[in]nameThe view name.
[in]initialiseThe element initialiser.
[in]cleanThe element cleaner.
[in]cacheThe viewed cache.

◆ ~CacheViewT()

template<typename CacheT , EventType EventT>
castor3d::CacheViewT< CacheT, EventT >::~CacheViewT ( )
default

Destructor.

Member Function Documentation

◆ add() [1/2]

template<typename CacheT , EventType EventT>
ElementObsT castor3d::CacheViewT< CacheT, EventT >::add ( ElementKeyT const &  name,
ElementPtrT element,
bool  initialise = false 
)
inline

adds an already created an element.

Parameters
[in]nameThe element name.
[in]elementThe element.
[in]initialiseTells if the element is to be initialised after creation.

◆ add() [2/2]

template<typename CacheT , EventType EventT>
template<typename ... ParametersT>
ElementObsT castor3d::CacheViewT< CacheT, EventT >::add ( ElementKeyT const &  name,
ParametersT &&...  params 
)
inline

Creates an element with the given informations.

Parameters
[in]nameThe element name.
[in]paramsThe parameters forwarded to the viewed cache.
Returns
The created element.

◆ begin() [1/2]

template<typename CacheT , EventType EventT>
auto castor3d::CacheViewT< CacheT, EventT >::begin ( )
inline

◆ begin() [2/2]

template<typename CacheT , EventType EventT>
auto castor3d::CacheViewT< CacheT, EventT >::begin ( ) const
inline

◆ clear()

template<typename CacheT , EventType EventT>
void castor3d::CacheViewT< CacheT, EventT >::clear ( )
inline

Removes from the cache the elements created through this view.

◆ end() [1/2]

template<typename CacheT , EventType EventT>
auto castor3d::CacheViewT< CacheT, EventT >::end ( )
inline

◆ end() [2/2]

template<typename CacheT , EventType EventT>
auto castor3d::CacheViewT< CacheT, EventT >::end ( ) const
inline

◆ find()

template<typename CacheT , EventType EventT>
ElementObsT castor3d::CacheViewT< CacheT, EventT >::find ( ElementKeyT const &  name) const
inline

Looks for an element with given name.

Parameters
[in]nameThe object name.
Returns
The found element, nullptr if not found.

◆ has()

template<typename CacheT , EventType EventT>
bool castor3d::CacheViewT< CacheT, EventT >::has ( ElementKeyT const &  name) const
inline
Parameters
[in]nameThe object name.
Returns
true if an element with given name exists.

◆ isEmpty()

template<typename CacheT , EventType EventT>
bool castor3d::CacheViewT< CacheT, EventT >::isEmpty ( ) const
inline
Returns
true if the view is empty.

◆ remove()

template<typename CacheT , EventType EventT>
void castor3d::CacheViewT< CacheT, EventT >::remove ( ElementKeyT const &  name)
inline

Removes an object, given a name.

Parameters
[in]nameThe object name.

◆ tryAdd() [1/2]

template<typename CacheT , EventType EventT>
template<typename ... ParametersT>
ElementObsT castor3d::CacheViewT< CacheT, EventT >::tryAdd ( ElementKeyT const &  name,
bool  initialise,
ElementObsT created,
ParametersT &&...  params 
)
inline

Creates or retrieves an element with the given informations.

Parameters
[in]nameThe element name.
[in]initialiseTells if the element is to be initialised after creation.
[out]createdReceives the created element if ti was created.
[in]paramsThe parameters forwarded to the viewed cache.
Returns
The created or existing element.

◆ tryAdd() [2/2]

template<typename CacheT , EventType EventT>
bool castor3d::CacheViewT< CacheT, EventT >::tryAdd ( ElementKeyT const &  name,
ElementPtrT element,
bool  initialise = false 
)
inline

adds an already created an element.

Parameters
[in]nameThe element name.
[in]elementThe element.
[in]initialiseTells if the element is to be initialised after creation.

◆ tryFind()

template<typename CacheT , EventType EventT>
ElementObsT castor3d::CacheViewT< CacheT, EventT >::tryFind ( ElementKeyT const &  name) const
inline

Looks for an element with given name.

Parameters
[in]nameThe object name.
Returns
The found element, nullptr if not found.

◆ tryRemove()

template<typename CacheT , EventType EventT>
ElementObsT castor3d::CacheViewT< CacheT, EventT >::tryRemove ( ElementKeyT const &  name)
inline

Removes an element, given a name.

Parameters
[in]nameThe element name.

The documentation for this class was generated from the following files: