24 #include <momemta/ModuleFactory.h> 25 #include <momemta/ModuleDefBuilder.h> 46 typedef std::function<ModuleRegistrationData()> RegisterOp;
54 void registerModule(RegisterOp registration_op);
61 void deregisterModule(
const std::string& module_name);
76 void exportList(
bool ignore_internal, ModuleList& list)
const;
81 void processRegistrations();
85 void callDeferred()
const;
86 void registerModuleWithLock(RegisterOp registration_op)
const;
88 mutable std::mutex mutex_;
94 mutable std::vector<RegisterOp> deferred_;
95 mutable std::unordered_map<std::string, const ModuleRegistrationData> registry_;
97 mutable bool initialized_ =
false;
100 class module_already_exists_error:
public std::runtime_error {
101 using std::runtime_error::runtime_error;
104 class module_not_found_error:
public std::runtime_error {
105 using std::runtime_error::runtime_error;
109 namespace registration {
125 #define REGISTER_MODULE(type) \ 126 REGISTER_MODULE_UNIQ_HELPER(__LINE__, #type, type) 127 #define REGISTER_MODULE_NAME(name, type) \ 128 REGISTER_MODULE_UNIQ_HELPER(__LINE__, name, type) 130 #define REGISTER_MODULE_UNIQ_HELPER(ctr, name, type) REGISTER_MODULE_UNIQ(ctr, name, type) 131 #define REGISTER_MODULE_UNIQ(ctr, name, type) \ 132 static const ::momemta::ModuleFactory::PMaker<type> register_module_factory##ctr(name); \ 133 static const ::momemta::registration::ModuleDefBuilderReceiver register_module##ctr = \ 134 ::momemta::registration::ModuleDefBuilder(name).Type<type>() virtual const ModuleRegistrationData & find(const std::string &module_name) const =0
Returns the registration data for a given module. Throws an exception if no such module exists...