5 #include <plugify/mem_addr.hpp>
6 #include <plugify/path.hpp>
7 #include <plugify/reference_wrapper.hpp>
8 #include <plugify_export.h>
14 class PluginDescriptorRef;
24 enum class PluginState : uint8_t {
37 using UniqueId = std::ptrdiff_t;
46 using MethodData = std::pair<MethodRef, MemAddr>;
59 UniqueId
GetId() const noexcept;
65 std::string_view GetName() const noexcept;
71 std::string_view GetFriendlyName() const noexcept;
77 std::filesystem::path_view GetBaseDir() const noexcept;
89 PluginState GetState() const noexcept;
95 std::string_view GetError() const noexcept;
101 std::span<const MethodData> GetMethods() const noexcept;
124 std::optional<std::filesystem::path_view> FindResource(std::filesystem::path_view path) const;
131 namespace PluginUtils {
137 [[maybe_unused]] constexpr std::string_view ToString(PluginState state) {
139 case PluginState::NotLoaded:
return "NotLoaded";
140 case PluginState::Error:
return "Error";
141 case PluginState::Loaded:
return "Loaded";
142 case PluginState::Running:
return "Running";
143 case PluginState::Terminating:
return "Terminating";
144 default:
return "Unknown";
153 [[maybe_unused]] constexpr PluginState FromString(std::string_view state) {
154 if (state ==
"NotLoaded") {
155 return PluginState::NotLoaded;
156 }
else if (state ==
"Error") {
157 return PluginState::Error;
158 }
else if (state ==
"Loaded") {
159 return PluginState::Loaded;
160 }
else if (state ==
"Running") {
161 return PluginState::Running;
162 }
else if (state ==
"Terminating") {
163 return PluginState::Terminating;
165 return PluginState::Unknown;
A reference class for the PluginDescriptor structure.
Reference wrapper to access for plugin's information.
UniqueId GetId() const noexcept
Get the unique identifier of the plugin.
A lightweight reference wrapper for objects of type T.