Castor3D 0.16.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.
 
void clear ()
 Removes from the cache the elements created through this view.
 
template<typename ... ParametersT>
ElementObsT add (ElementKeyT const &name, ParametersT &&... params)
 Creates an element with the given informations.
 
template<typename ... ParametersT>
ElementObsT tryAdd (ElementKeyT const &name, bool initialise, ElementObsT &created, ParametersT &&... params)
 Creates or retrieves an element with the given informations.
 
bool tryAdd (ElementKeyT const &name, ElementPtrT &element, bool initialise=false)
 adds an already created an element.
 
ElementObsT add (ElementKeyT const &name, ElementPtrT &element, bool initialise=false)
 adds an already created an element.
 
bool isEmpty () const
 
bool has (ElementKeyT const &name) const
 
ElementObsT tryFind (ElementKeyT const &name) const
 Looks for an element with given name.
 
ElementObsT find (ElementKeyT const &name) const
 Looks for an element with given name.
 
ElementPtrT tryRemove (ElementKeyT const &name)
 Removes an element, given a name.
 
ElementPtrT remove (ElementKeyT const &name)
 Removes an object, given a name.
 
auto & getCache () const
 
Iteration.
auto begin ()
 
auto begin () const
 
auto end ()
 
auto end () const
 
- Public Member Functions inherited from castor::NamedBaseT< T >
 NamedBaseT (T name) noexcept
 Constructor.
 
T const & getName () const noexcept
 Retrieves the name.
 
void rename (T name) noexcept
 

Additional Inherited Members

- Protected Attributes inherited from castor::NamedBaseT< T >
m_name
 

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 &){} )

Constructor.

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

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 )

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 )

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 ( )

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

Looks for an element with given name.

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

◆ getCache()

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

◆ has()

template<typename CacheT , EventType EventT>
bool castor3d::CacheViewT< CacheT, EventT >::has ( ElementKeyT const & name) const
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
Returns
true if the view is empty.

◆ remove()

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

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 )

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 )

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

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>
ElementPtrT castor3d::CacheViewT< CacheT, EventT >::tryRemove ( ElementKeyT const & name)

Removes an element, given a name.

Parameters
[in]nameThe element name.

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