35 #ifndef NEKTAR_LIB_UTILITIES_BASIC_UTILS_NEK_MANAGER_HPP
36 #define NEKTAR_LIB_UTILITIES_BASIC_UTILS_NEK_MANAGER_HPP
43 #ifdef NEKTAR_USE_THREAD_SAFETY
44 #include <boost/thread/shared_mutex.hpp>
45 #include <boost/thread/locks.hpp>
52 namespace LibUtilities
54 #ifdef NEKTAR_USE_THREAD_SAFETY
55 typedef boost::unique_lock<boost::shared_mutex>
WriteLock;
56 typedef boost::shared_lock<boost::shared_mutex>
ReadLock;
59 template <
typename KeyType>
62 bool operator()(
const KeyType &lhs,
const KeyType &rhs)
const
68 template <
typename KeyType,
typename ValueT,
typename opLessCreator = defOpLessCreator<KeyType> >
87 if (!whichPool.empty())
119 if (!whichPool.empty())
121 #ifdef NEKTAR_USE_THREAD_SAFETY
132 #ifdef NEKTAR_USE_THREAD_SAFETY
201 return (*found).second;
210 f = (*keyFound).second;
218 (*m_values)[key] = v;
224 std::stringstream ss;
226 std::string message =
"No create func found for key " + ss.str();
246 if (!whichPool.empty())
248 #ifdef NEKTAR_USE_THREAD_SAFETY
253 "Could not find pool " + whichPool);
258 #ifdef NEKTAR_USE_THREAD_SAFETY
282 if (!whichPool.empty())
284 #ifdef NEKTAR_USE_THREAD_SAFETY
302 if (!whichPool.empty())
304 #ifdef NEKTAR_USE_THREAD_SAFETY
310 (*x->second) =
false;
329 #ifdef NEKTAR_USE_THREAD_SAFETY
330 static boost::shared_mutex m_mutex;
335 #ifdef NEKTAR_USE_THREAD_SAFETY
336 template <
typename KeyType,
typename ValueT,
typename opLessCreator>
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
BoolSharedPtr m_managementEnabled
static void DisableManagement(std::string whichPool="")
bool AlreadyCreated(const KeyType &key)
std::shared_ptr< bool > BoolSharedPtr
ValueType operator[](const KeyType &key)
std::map< std::string, BoolSharedPtr > FlagContainerPool
bool RegisterCreator(const KeyType &key, const CreateFuncType &createFunc)
Register the given function and associate it with the key. The return value is just to facilitate cal...
NekManager(std::string whichPool="")
NekManager< KeyType, ValueType, opLessCreator > & operator=(const NekManager< KeyType, ValueType, opLessCreator > &rhs)
std::shared_ptr< ValueT > ValueType
ValueContainerShPtr m_values
std::map< std::string, std::shared_ptr< ValueContainer > > ValueContainerPool
NekManager(CreateFuncType f, std::string whichPool="")
static ValueContainerPool m_ValueContainerPool
std::function< ValueType(const KeyType &key)> CreateFuncType
std::shared_ptr< ValueContainer > ValueContainerShPtr
static bool PoolCreated(std::string whichPool)
CreateFuncType m_globalCreateFunc
static FlagContainerPool m_managementEnabledContainerPool
bool RegisterGlobalCreator(const CreateFuncType &createFunc)
Register the Global Create Function. The return value is just to facilitate calling statically.
CreateFuncContainer m_keySpecificCreateFuncs
static void EnableManagement(std::string whichPool="")
void DeleteObject(const KeyType &key)
std::map< KeyType, CreateFuncType, opLessCreator > CreateFuncContainer
static void ClearManager(std::string whichPool="")
NekManager(const NekManager< KeyType, ValueType, opLessCreator > &rhs)
std::map< KeyType, ValueType > ValueContainer
boost::shared_lock< boost::shared_mutex > ReadLock
boost::unique_lock< boost::shared_mutex > WriteLock
The above copyright notice and this permission notice shall be included.
bool operator()(const KeyType &lhs, const KeyType &rhs) const