123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #ifndef __PLUGINSUBSCRIBER_HPP_
- #define __PLUGINSUBSCRIBER_HPP_
- #include <iostream>
- #include "PuginFactory.hpp"
- namespace gsd
- {
- /**
- * @brief PluginSubscriber
- *
- */
- template <typename T>
- class PluginSubscriber{
- struct Register
- {
- // Register
- Register(){
- char *Name = nullptr;
- Name = abi::__cxa_demangle(typeid(T).name(), nullptr, nullptr, nullptr);
- std::string pluginName;
- if(Name != nullptr){
- pluginName = Name;
- free(Name);
- }
- PuginFactory::getPtr()->Regist(pluginName, getObjectPtr);
- }
- };
-
- /**
- * @description:
- * @return {*}
- */
- static std::shared_ptr<T> getObjectPtr(){
- return T::getPtr();
- }
- private:
- Register register_;
- };
- } // namespace gsd
- #endif
|