35#include <unordered_map>
68extern std::unordered_map<std::string, std::unique_ptr<creator_base>>&
71extern std::unordered_map<std::string, std::unique_ptr<creator_base>>&
97 nm, std::unique_ptr<wxm::detail::creator_base>(b));
101 wxe <<
"Duplicate Creator for class " << nm;
104 return *v.first->second;
118 nm, std::unique_ptr<wxm::detail::creator_base>(b));
122 wxe <<
"Duplicate Creator for class " << nm;
125 return *v.first->second;
135 std::cout <<
"unregistering " << nm << std::endl;
146 std::cout <<
"unregistering " << nm << std::endl;
170 wxe <<
"Creator for class " << nm <<
" not found";
193 wxe <<
"Creator for class " << nm <<
" not found";
210 if (*(i.second->type_) == type)
219 if (*(i.second->type_) == type)
256 return static_cast<B*
>(d);
288 D* d =
new D(parentPointer);
289 return static_cast<B*
>(d);
296#define WXM_UNUSED __attribute__((unused))
297#elif defined(_MSC_VER) && !defined(__clang__)
306#if defined(__COUNTER__) && (__COUNTER__ + 1 == __COUNTER__ + 0)
307#define WXM_PRIVATE_UNIQUE_ID __COUNTER__
309#define WXM_PRIVATE_UNIQUE_ID __LINE__
313#define WXM_PRIVATE_NAME(n) WXM_PRIVATE_CONCAT(wxm_creator_, WXM_PRIVATE_UNIQUE_ID, n)
314#define WXM_PRIVATE_CONCAT(a, b, c) WXM_PRIVATE_CONCAT2(a, b, c)
315#define WXM_PRIVATE_CONCAT2(a, b, c) a##b##c##_
317#define REGISTER_CREATOR(name, specialization, base) \
320 static auto& WXM_PRIVATE_NAME(registered) WXM_UNUSED = \
321 (WxCreatorMapBase<base>::addCreator(name, \
322 new WxCreator<specialization, base>(name))); \
325#define REGISTER_CREATOR_FOR_CHILDREN(name, specialization, base) \
328 static auto& WXM_PRIVATE_NAME(registered) \
329 WXM_UNUSED = (WxCreatorMapBase<base>::addCreatorForChildren( \
331 new WxCreatorForChildren<specialization, base>(name))); \
Opaque Pointer object that carries the referenced data type, but does not expose this payload type as...
Definition: wmopaqueptr.h:81
Definition: wxcreator.h:230
WxCreatorBase(std::string nm, const std::type_info *dtype)
Definition: wxcreator.h:232
virtual B * getNew()=0
calls constructors for derived class taking no arguments
Definition: wxcreator.h:261
WxCreatorForChildrenBase(std::string nm, const std::type_info *dtype)
Definition: wxcreator.h:263
virtual B * getNew(const WmConstOpaquePtr &parentPointer)=0
calls constructors for derived class taking the one parentPointer argument
This creator is meant to be used for classes that require a parent argument to their constructor.
Definition: wxcreator.h:279
B * getNew(const WmConstOpaquePtr &parentPointer)
calls constructors for derived class taking the one parentPointer argument
Definition: wxcreator.h:286
WxCreatorForChildren(std::string name)
Definition: wxcreator.h:281
This creator is meant to be used for classes with default constructor.
Definition: wxcreator.h:247
WxCreator(std::string name)
Definition: wxcreator.h:249
B * getNew()
calls constructors for derived class taking no arguments
Definition: wxcreator.h:253
Defines Common Interface for WxCreatorMap.
Definition: wxcreator.h:84
static wxm::detail::creator_base & addCreator(const std::string &nm, wxm::detail::creator_base *b)
Add a new creator object into the list of available creators for base classes that have default const...
Definition: wxcreator.h:93
static void removeCreatorForChild(const std::string &nm)
Remove a creator from the list of parent pointer constructor creators.
Definition: wxcreator.h:144
static wxm::detail::creator_base & addCreatorForChildren(const std::string &nm, wxm::detail::creator_base *b)
Add a new creator object into the list of available creators for base classes that have a parent poin...
Definition: wxcreator.h:114
static void removeCreatorForDefault(const std::string &nm)
Remove a creator from the list of default constructor creators.
Definition: wxcreator.h:133
Definition: wxcreator.h:152
static B * getNew(const std::string &nm)
Get a new object whose creator has the given name and base class has a default constructor.
Definition: wxcreator.h:161
static const std::string getRegisteredName(const std::type_info &type)
Returns the first registered name string associated with a particular derived type.
Definition: wxcreator.h:204
static B * getNew(const std::string &nm, const WmConstOpaquePtr &parentPointer)
Get a new object whose creator has the given name and base class has a constructor taking one WxAny a...
Definition: wxcreator.h:183
implementation detail so deletion happens correctly
Definition: wxcreator.h:54
creator_base(std::string name, const std::type_info *dtype)
Definition: wxcreator.h:59
const std::type_info * type_
Definition: wxcreator.h:57
std::string name_
Definition: wxcreator.h:56
virtual ~creator_base()=default
wxm::lib::Except is the class to use for creating and throwing exceptions.
Definition: wxexcept.h:31
std::unordered_map< std::string, std::unique_ptr< creator_base > > & creatorsForDefault()
std::unordered_map< std::string, std::unique_ptr< creator_base > > & creatorsForChildren()
Base namespace for everything not included in the global namespace.
Definition: field_source.h:8