diff --git a/notes b/notes index d53fef8..b30547d 100644 --- a/notes +++ b/notes @@ -35,8 +35,8 @@ TODO { about-license info } - rework RegisterPlugin slightly to automatically give a file-scope access to the PluginInfo - ^ use in graph + - rework RegisterPlugin slightly to automatically give a file-scope access to the PluginInfo + - ^ use in graph - pool I guess diff --git a/xybrid/config/pluginregistry.cpp b/xybrid/config/pluginregistry.cpp index a77211e..c08b75d 100644 --- a/xybrid/config/pluginregistry.cpp +++ b/xybrid/config/pluginregistry.cpp @@ -31,11 +31,11 @@ namespace { // clazy:excludeall=non-pod-global-static }; } -bool PluginRegistry::enqueueRegistration(std::function f) { +std::shared_ptr PluginRegistry::enqueueRegistration(std::function f) { auto& queue = regQueue(); queue.push_back(f); if (initialized()) f(); - return true; + return nullptr; } void PluginRegistry::init() { diff --git a/xybrid/config/pluginregistry.h b/xybrid/config/pluginregistry.h index f9a5bbc..1c4843b 100644 --- a/xybrid/config/pluginregistry.h +++ b/xybrid/config/pluginregistry.h @@ -29,7 +29,7 @@ namespace Xybrid::Config { }; namespace PluginRegistry { - bool enqueueRegistration(std::function); + std::shared_ptr enqueueRegistration(std::function); void registerPlugin(std::shared_ptr); void init(); @@ -39,7 +39,7 @@ namespace Xybrid::Config { } #define RegisterPlugin(NAME, ...) \ - namespace { bool _x___reg_##NAME = Xybrid::Config::PluginRegistry::enqueueRegistration([] { \ + namespace { std::shared_ptr _regInfo_##NAME = Xybrid::Config::PluginRegistry::enqueueRegistration([] { \ auto i = std::make_shared();\ i->createInstance = []{ return std::make_shared(); };\ __VA_ARGS__ \ diff --git a/xybrid/data/graph.cpp b/xybrid/data/graph.cpp index b767cd5..d96c363 100644 --- a/xybrid/data/graph.cpp +++ b/xybrid/data/graph.cpp @@ -15,20 +15,16 @@ using namespace Xybrid::Config; #include #include -namespace { // clazy:excludeall=non-pod-global-static - std::shared_ptr inf; -} - +// clazy:excludeall=non-pod-global-static RegisterPlugin(Graph, { i->id = "graph"; i->displayName = "Subgraph"; - inf = i; }) //std::string Graph::pluginName() const { return "Subgraph"; } Graph::Graph() { - plugin = inf; // harder bind + plugin = _regInfo_Graph;//inf; // harder bind } // propagate @@ -119,7 +115,7 @@ void Graph::onParent(std::shared_ptr) { for (auto c : children) { c->project = project; // let this handle the recursion for us, since this is all this function does - if (c->plugin == inf) c->onParent(c->parent.lock()); + if (c->plugin == _regInfo_Graph) c->onParent(c->parent.lock()); } }