23 #include <momemta/ModuleFactory.h> 24 #include <momemta/ModuleDefBuilder.h> 45 typedef std::function<ModuleRegistrationData()> RegisterOp;
53 void registerModule(RegisterOp registration_op);
60 void deregisterModule(
const std::string& module_name);
75 void exportList(
bool ignore_internal, ModuleList& list)
const;
80 void processRegistrations();
84 void callDeferred()
const;
85 void registerModuleWithLock(RegisterOp registration_op)
const;
87 mutable std::mutex mutex_;
93 mutable std::vector<RegisterOp> deferred_;
94 mutable std::unordered_map<std::string, const ModuleRegistrationData> registry_;
96 mutable bool initialized_ =
false;
99 class module_already_exists_error:
public std::runtime_error {
100 using std::runtime_error::runtime_error;
103 class module_not_found_error:
public std::runtime_error {
104 using std::runtime_error::runtime_error;
108 namespace registration {
124 #define REGISTER_MODULE(type) \ 125 REGISTER_MODULE_UNIQ_HELPER(__LINE__, #type, type) 126 #define REGISTER_MODULE_NAME(name, type) \ 127 REGISTER_MODULE_UNIQ_HELPER(__LINE__, name, type) 129 #define REGISTER_MODULE_UNIQ_HELPER(ctr, name, type) REGISTER_MODULE_UNIQ(ctr, name, type) 130 #define REGISTER_MODULE_UNIQ(ctr, name, type) \ 131 static const ::momemta::ModuleFactory::PMaker<type> register_module_factory##ctr(name); \ 132 static const ::momemta::registration::ModuleDefBuilderReceiver register_module##ctr = \ 133 ::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...