21 #ifndef mia_core_productcache_hh 22 #define mia_core_productcache_hh 27 #include <tbb/recursive_mutex.h> 28 #include <tbb/spin_mutex.h> 61 void enable_write(
bool enable);
67 bool is_enabled()
const;
69 virtual void do_clear() = 0;
71 mutable tbb::spin_mutex m_enable_mutex;
81 template <
typename ProductPtr>
97 ProductPtr
get(
const std::string& name)
const;
105 void add(
const std::string& name, ProductPtr product);
108 virtual void do_clear();
110 typedef std::map<std::string, ProductPtr> CMap;
112 mutable tbb::recursive_mutex m_cache_mutex;
134 void register_cache(
const std::string& name,
CProductCache* cache);
141 std::map<std::string, CProductCache*> m_caches;
142 static CMutex m_creation_mutex;
148 template <
typename ProductPtr>
154 template <
typename ProductPtr>
158 auto i = m_cache.find(name);
159 if (i != m_cache.end())
164 template <
typename ProductPtr>
171 m_cache[name] = product;
175 template <
typename ProductPtr>
The type specific product cache.
The singleton that handles all product caches.
void add(const std::string &name, ProductPtr product)
base class for the product cache
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
ProductPtr get(const std::string &name) const
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
tbb::mutex CMutex
The mutex renamed to MIA style.
TProductCache(const std::string &descriptor)
tbb::recursive_mutex::scoped_lock CRecursiveScopedLock
#define NS_MIA_END
conveniance define to end the mia namespace