AMR-Wind  v0.1.0
CFD solver for wind plant simulations
Public Types | Public Member Functions | Protected Attributes | List of all members
amr_wind::CollMgr< Collection, Type, allow_duplicates > Class Template Reference

Interface to manage objects of sub-classes based on factory registration. More...

#include <CollMgr.H>

Inheritance diagram for amr_wind::CollMgr< Collection, Type, allow_duplicates >:
[legend]
Collaboration diagram for amr_wind::CollMgr< Collection, Type, allow_duplicates >:
[legend]

Public Types

using TypePtr = std::unique_ptr< Type >
 
using TypeVector = amrex::Vector< TypePtr >
 

Public Member Functions

 CollMgr ()=default
 
 ~CollMgr ()=default
 
 CollMgr (const CollMgr &)=delete
 
CollMgroperator= (const CollMgr &)=delete
 
template<class... Args>
Type & create (const std::string &key, Args &&... args)
 Create a new object and register it in the vector and setup lookup options. More...
 
TypeVectorobjects ()
 Return a vector of the registered objects. More...
 
const TypeVectorobjects () const
 
bool contains (const std::string &key) const
 Query if an object exists using the lookup key. More...
 
Type & operator() (const std::string &key)
 Return the object corresponding to a lookup key. More...
 
const Type & operator() (const std::string &key) const
 
template<typename T >
T & operator() (const std::string &key)
 Return object for a lookup key cast into its exact class definition. More...
 

Protected Attributes

TypeVector m_obj_vec
 Collection of objects registered so far. More...
 
std::unordered_map< std::string, int > m_obj_map
 Key word based lookup. More...
 

Detailed Description

template<typename Collection, typename Type, bool allow_duplicates = false>
class amr_wind::CollMgr< Collection, Type, allow_duplicates >

Interface to manage objects of sub-classes based on factory registration.

Provides boiler-plate code to register a collection and then query using lookup keywords

Template Parameters
CollectionClass holding instances of collection (e.g., PhysicsMgr)
Baseclass of the collection (e.g., Physics)

Member Typedef Documentation

◆ TypePtr

template<typename Collection , typename Type , bool allow_duplicates = false>
using amr_wind::CollMgr< Collection, Type, allow_duplicates >::TypePtr = std::unique_ptr<Type>

◆ TypeVector

template<typename Collection , typename Type , bool allow_duplicates = false>
using amr_wind::CollMgr< Collection, Type, allow_duplicates >::TypeVector = amrex::Vector<TypePtr>

Constructor & Destructor Documentation

◆ CollMgr() [1/2]

template<typename Collection , typename Type , bool allow_duplicates = false>
amr_wind::CollMgr< Collection, Type, allow_duplicates >::CollMgr ( )
default

◆ ~CollMgr()

template<typename Collection , typename Type , bool allow_duplicates = false>
amr_wind::CollMgr< Collection, Type, allow_duplicates >::~CollMgr ( )
default

◆ CollMgr() [2/2]

template<typename Collection , typename Type , bool allow_duplicates = false>
amr_wind::CollMgr< Collection, Type, allow_duplicates >::CollMgr ( const CollMgr< Collection, Type, allow_duplicates > &  )
delete

Member Function Documentation

◆ contains()

template<typename Collection , typename Type , bool allow_duplicates = false>
bool amr_wind::CollMgr< Collection, Type, allow_duplicates >::contains ( const std::string &  key) const
inline

Query if an object exists using the lookup key.

◆ create()

template<typename Collection , typename Type , bool allow_duplicates = false>
template<class... Args>
Type& amr_wind::CollMgr< Collection, Type, allow_duplicates >::create ( const std::string &  key,
Args &&...  args 
)
inline

Create a new object and register it in the vector and setup lookup options.

◆ objects() [1/2]

template<typename Collection , typename Type , bool allow_duplicates = false>
TypeVector& amr_wind::CollMgr< Collection, Type, allow_duplicates >::objects ( )
inline

Return a vector of the registered objects.

◆ objects() [2/2]

template<typename Collection , typename Type , bool allow_duplicates = false>
const TypeVector& amr_wind::CollMgr< Collection, Type, allow_duplicates >::objects ( ) const
inline

◆ operator()() [1/3]

template<typename Collection , typename Type , bool allow_duplicates = false>
Type& amr_wind::CollMgr< Collection, Type, allow_duplicates >::operator() ( const std::string &  key)
inline

Return the object corresponding to a lookup key.

◆ operator()() [2/3]

template<typename Collection , typename Type , bool allow_duplicates = false>
template<typename T >
T& amr_wind::CollMgr< Collection, Type, allow_duplicates >::operator() ( const std::string &  key)
inline

Return object for a lookup key cast into its exact class definition.

◆ operator()() [3/3]

template<typename Collection , typename Type , bool allow_duplicates = false>
const Type& amr_wind::CollMgr< Collection, Type, allow_duplicates >::operator() ( const std::string &  key) const
inline

◆ operator=()

template<typename Collection , typename Type , bool allow_duplicates = false>
CollMgr& amr_wind::CollMgr< Collection, Type, allow_duplicates >::operator= ( const CollMgr< Collection, Type, allow_duplicates > &  )
delete

Member Data Documentation

◆ m_obj_map

template<typename Collection , typename Type , bool allow_duplicates = false>
std::unordered_map<std::string, int> amr_wind::CollMgr< Collection, Type, allow_duplicates >::m_obj_map
protected

Key word based lookup.

◆ m_obj_vec

template<typename Collection , typename Type , bool allow_duplicates = false>
TypeVector amr_wind::CollMgr< Collection, Type, allow_duplicates >::m_obj_vec
protected

Collection of objects registered so far.


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