Plugin.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (c) 2013-2016 Josh Blum
  2. // 2019 Nicholas Corgan
  3. // SPDX-License-Identifier: BSL-1.0
  4. #include <Pothos/Plugin/Plugin.hpp>
  5. #include <Pothos/Util/TypeInfo.hpp>
  6. Pothos::Plugin::Plugin(void)
  7. {
  8. return;
  9. }
  10. Pothos::Plugin::Plugin(const PluginPath &path, const Object &object, const PluginModule &module):
  11. _module(module._impl),
  12. _path(path),
  13. _object(object)
  14. {
  15. return;
  16. }
  17. const Pothos::PluginPath &Pothos::Plugin::getPath(void) const
  18. {
  19. return _path;
  20. }
  21. const Pothos::Object &Pothos::Plugin::getObject(void) const
  22. {
  23. return _object;
  24. }
  25. Pothos::PluginModule Pothos::Plugin::getModule(void) const
  26. {
  27. PluginModule module;
  28. module._impl = _module.lock();
  29. return module;
  30. }
  31. std::string Pothos::Plugin::toString(void) const
  32. {
  33. std::string output = this->getPath().toString();
  34. if (this->getObject())
  35. {
  36. output += " {" + Util::typeInfoToString(this->getObject().type()) + "}";
  37. }
  38. if (not this->getModule().getFilePath().empty())
  39. {
  40. output += " [" + this->getModule().getFilePath() + "]";
  41. }
  42. return output;
  43. }
  44. #include <Pothos/Managed.hpp>
  45. static auto managedPlugin = Pothos::ManagedClass()
  46. .registerConstructor<Pothos::Plugin>()
  47. .registerConstructor<Pothos::Plugin, const Pothos::PluginPath &, const Pothos::Object &>()
  48. .registerMethod(POTHOS_FCN_TUPLE(Pothos::Plugin, getPath))
  49. .registerMethod(POTHOS_FCN_TUPLE(Pothos::Plugin, getObject))
  50. .registerMethod(POTHOS_FCN_TUPLE(Pothos::Plugin, getModule))
  51. .registerMethod(POTHOS_FCN_TUPLE(Pothos::Plugin, toString))
  52. .commit("Pothos/Plugin");