30 #ifndef CORE_UTILS_TYPEIDTABLE_H
31 #define CORE_UTILS_TYPEIDTABLE_H
33 #include <boost/thread/mutex.hpp>
34 #include <boost/noncopyable.hpp>
35 #include <boost/optional.hpp>
46 template <
class CtorInfo>
55 boost::mutex::scoped_lock s(lock_);
56 auto iter = lookup_.find(key);
57 if (iter == lookup_.end())
64 boost::mutex::scoped_lock s(lock_);
65 auto iter = lookup_.find(key);
66 if (iter != lookup_.end())
68 if (iter->second != info)
72 std::cerr <<
"WARNING: duplicate type exists: " << key <<
"\n";
80 size_t size()
const {
return lookup_.size(); }
83 mutable boost::mutex lock_;
84 std::map<std::string, CtorInfo> lookup_;
size_t size() const
Definition: TypeIDTable.h:80
bool registerConstructorInfo(const std::string &key, const CtorInfo &info)
Definition: TypeIDTable.h:62
A thread-safe map used for constructor lookup in Mesh/Field factories.
Definition: TypeIDTable.h:47
boost::optional< const CtorInfo & > CtorInfoOption
Definition: TypeIDTable.h:50
CtorInfoOption findConstructorInfo(const std::string &key) const
Definition: TypeIDTable.h:53