Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator > Class Template Reference

#include <NekManager.hpp>

Collaboration diagram for Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >:
Collaboration graph
[legend]

Public Types

typedef boost::shared_ptr< ValueT > ValueType
typedef boost::function
< ValueType(const KeyType &key)> 
CreateFuncType
typedef std::map< KeyType,
ValueType
ValueContainer
typedef boost::shared_ptr
< ValueContainer
ValueContainerShPtr
typedef std::map< KeyType,
CreateFuncType, opLessCreator > 
CreateFuncContainer
typedef std::map< std::string,
boost::shared_ptr
< ValueContainer > > 
ValueContainerPool
typedef boost::shared_ptr< bool > BoolSharedPtr
typedef std::map< std::string,
BoolSharedPtr
FlagContainerPool

Public Member Functions

 BOOST_CLASS_REQUIRE (KeyType, boost, LessThanComparableConcept)
 NekManager (std::string whichPool="")
 NekManager (CreateFuncType f, std::string whichPool="")
 ~NekManager ()
bool RegisterCreator (typename boost::call_traits< KeyType >::const_reference key, const CreateFuncType &createFunc)
 Register the given function and associate it with the key. The return value is just to facilitate calling statically.
bool RegisterGlobalCreator (const CreateFuncType &createFunc)
 Register the Global Create Function. The return value is just to facilitate calling statically.
bool AlreadyCreated (typename boost::call_traits< KeyType >::const_reference key)
ValueType operator[] (typename boost::call_traits< KeyType >::const_reference key)
void DeleteObject (typename boost::call_traits< KeyType >::const_reference key)

Static Public Member Functions

static void ClearManager (std::string whichPool="")
static void EnableManagement (std::string whichPool="")
static void DisableManagement (std::string whichPool="")

Private Member Functions

 NekManager (const NekManager< KeyType, ValueType, opLessCreator > &rhs)
NekManager< KeyType, ValueType,
opLessCreator > & 
operator= (const NekManager< KeyType, ValueType, opLessCreator > &rhs)

Private Attributes

ValueContainerShPtr m_values
BoolSharedPtr m_managementEnabled
CreateFuncType m_globalCreateFunc
CreateFuncContainer m_keySpecificCreateFuncs

Static Private Attributes

static ValueContainerPool m_ValueContainerPool
static FlagContainerPool m_managementEnabledContainerPool

Detailed Description

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
class Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >

Definition at line 64 of file NekManager.hpp.

Member Typedef Documentation

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
typedef boost::shared_ptr<bool> Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::BoolSharedPtr

Definition at line 75 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
typedef std::map<KeyType, CreateFuncType, opLessCreator> Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::CreateFuncContainer

Definition at line 73 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
typedef boost::function<ValueType (const KeyType& key)> Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::CreateFuncType

Definition at line 70 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
typedef std::map<std::string, BoolSharedPtr> Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::FlagContainerPool

Definition at line 76 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
typedef std::map<KeyType, ValueType> Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::ValueContainer

Definition at line 71 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
typedef std::map<std::string, boost::shared_ptr<ValueContainer> > Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::ValueContainerPool

Definition at line 74 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
typedef boost::shared_ptr<ValueContainer> Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::ValueContainerShPtr

Definition at line 72 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
typedef boost::shared_ptr<ValueT> Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::ValueType

Definition at line 69 of file NekManager.hpp.

Constructor & Destructor Documentation

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::NekManager ( std::string  whichPool = "")
inline

Definition at line 78 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::NekManager ( CreateFuncType  f,
std::string  whichPool = "" 
)
inlineexplicit

Definition at line 110 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::~NekManager ( )
inline

Definition at line 142 of file NekManager.hpp.

{
}
template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::NekManager ( const NekManager< KeyType, ValueType, opLessCreator > &  rhs)
private

Member Function Documentation

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
bool Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::AlreadyCreated ( typename boost::call_traits< KeyType >::const_reference  key)
inline

Definition at line 165 of file NekManager.hpp.

{
bool value = false;
typename ValueContainer::iterator found = m_values->find(key);
if( found != m_values->end() )
{
value = true;
}
return value;
}
template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::BOOST_CLASS_REQUIRE ( KeyType  ,
boost  ,
LessThanComparableConcept   
)
template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
static void Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::ClearManager ( std::string  whichPool = "")
inlinestatic

Definition at line 225 of file NekManager.hpp.

{
if (!whichPool.empty())
{
x = m_ValueContainerPool.find(whichPool);
"Could not find pool " + whichPool);
x->second->clear();
}
else
{
for (x = m_ValueContainerPool.begin(); x != m_ValueContainerPool.end(); ++x)
{
x->second->clear();
}
}
}
template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
void Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::DeleteObject ( typename boost::call_traits< KeyType >::const_reference  key)
inline

Definition at line 215 of file NekManager.hpp.

Referenced by Nektar::LocalRegions::PyrExp::v_DropLocStaticCondMatrix(), Nektar::LocalRegions::PrismExp::v_DropLocStaticCondMatrix(), Nektar::LocalRegions::TetExp::v_DropLocStaticCondMatrix(), Nektar::LocalRegions::TriExp::v_DropLocStaticCondMatrix(), Nektar::LocalRegions::QuadExp::v_DropLocStaticCondMatrix(), Nektar::LocalRegions::SegExp::v_DropLocStaticCondMatrix(), and Nektar::LocalRegions::HexExp::v_DropLocStaticCondMatrix().

{
typename ValueContainer::iterator found = m_values->find(key);
if( found != m_values->end() )
{
m_values->erase(found);
}
}
template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
static void Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::DisableManagement ( std::string  whichPool = "")
inlinestatic

Definition at line 261 of file NekManager.hpp.

{
if (!whichPool.empty())
{
x = m_managementEnabledContainerPool.find(whichPool);
{
(*x->second) = false;
}
else
{
m_managementEnabledContainerPool[whichPool] = BoolSharedPtr(new bool(false));
}
}
}
template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
static void Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::EnableManagement ( std::string  whichPool = "")
inlinestatic

Definition at line 244 of file NekManager.hpp.

{
if (!whichPool.empty())
{
x = m_managementEnabledContainerPool.find(whichPool);
{
(*x->second) = true;
}
else
{
m_managementEnabledContainerPool[whichPool] = BoolSharedPtr(new bool(true));
}
}
}
template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
NekManager<KeyType, ValueType, opLessCreator>& Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::operator= ( const NekManager< KeyType, ValueType, opLessCreator > &  rhs)
private
template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
ValueType Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::operator[] ( typename boost::call_traits< KeyType >::const_reference  key)
inline

Definition at line 177 of file NekManager.hpp.

{
typename ValueContainer::iterator found = m_values->find(key);
if( found != m_values->end() )
{
return (*found).second;
}
else
{
// No object, create a new one.
if( keyFound != m_keySpecificCreateFuncs.end() )
{
f = (*keyFound).second;
}
if( f )
{
ValueType v = f(key);
{
(*m_values)[key] = v;
}
return v;
}
else
{
std::string keyAsString = boost::lexical_cast<std::string>(key);
std::string message = std::string("No create func found for key ") + keyAsString;
NEKERROR(ErrorUtil::efatal, message.c_str());
static ValueType result;
return result;
}
}
}
template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
bool Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::RegisterCreator ( typename boost::call_traits< KeyType >::const_reference  key,
const CreateFuncType createFunc 
)
inline

Register the given function and associate it with the key. The return value is just to facilitate calling statically.

Definition at line 148 of file NekManager.hpp.

Referenced by Nektar::LibUtilities::BLPoints::BLPoints(), Nektar::LibUtilities::FourierPoints::FourierPoints(), Nektar::LibUtilities::FourierSingleModePoints::FourierSingleModePoints(), and Nektar::LibUtilities::GaussPoints::GaussPoints().

{
m_keySpecificCreateFuncs[key] = createFunc;
return true;
}
template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
bool Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::RegisterGlobalCreator ( const CreateFuncType createFunc)
inline

Register the Global Create Function. The return value is just to facilitate calling statically.

Definition at line 158 of file NekManager.hpp.

Referenced by Nektar::LibUtilities::Basis::Basis(), and Nektar::LibUtilities::TimeIntegrationSchemeManager().

{
m_globalCreateFunc = createFunc;
return true;
}

Member Data Documentation

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
CreateFuncType Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::m_globalCreateFunc
private

Definition at line 286 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
CreateFuncContainer Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::m_keySpecificCreateFuncs
private

Definition at line 287 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
BoolSharedPtr Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::m_managementEnabled
private

Definition at line 283 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
NekManager< KeyType, ValueT, opLessCreator >::FlagContainerPool Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::m_managementEnabledContainerPool
staticprivate

Definition at line 285 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
NekManager< KeyType, ValueT, opLessCreator >::ValueContainerPool Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::m_ValueContainerPool
staticprivate

Definition at line 284 of file NekManager.hpp.

template<typename KeyType, typename ValueT, typename opLessCreator = defOpLessCreator<KeyType>>
ValueContainerShPtr Nektar::LibUtilities::NekManager< KeyType, ValueT, opLessCreator >::m_values
private

Definition at line 282 of file NekManager.hpp.