PicoScenes API Docs
 
Loading...
Searching...
No Matches
PicoScenesPluginManager.hxx
Go to the documentation of this file.
1//
2// Created by Zhiping Jiang on 2020/1/8.
3//
4
5#ifndef PICOSCENES_PLATFORM_PICOSCENESPLUGINMANAGER_HXX
6#define PICOSCENES_PLATFORM_PICOSCENESPLUGINMANAGER_HXX
7
8
9#include <utility>
10#include <vector>
11#include "BoostHeaders.hxx"
13#include "AbstractNIC.hxx"
14
15namespace fs = std::filesystem;
16
18
20
21class AbstractNIC;
22
24public:
25 PicoScenesPluginWrapper(const std::string &filePath, std::shared_ptr<PicoScenesPluginManager> manager);
26
27 [[nodiscard]] std::shared_ptr<PicoScenesPluginManager> getManager() const {
28 return manager;
29 }
30
31 [[nodiscard]] std::shared_ptr<AbstractPicoScenesPlugin> getPluginCore() const {
32 return pluginCore;
33 }
34
35 [[nodiscard]] const std::string &getLibraryFilePath() const {
36 return libraryFilePath;
37 }
38
39private:
40 std::string libraryFilePath;
41 boost::function<std::shared_ptr<AbstractPicoScenesPlugin>()> libraryHandle;
42 std::shared_ptr<AbstractPicoScenesPlugin> pluginCore;
43 std::shared_ptr<PicoScenesPluginManager> manager;
44};
45
46class PicoScenesPluginManager : public std::enable_shared_from_this<PicoScenesPluginManager> {
47public:
48 static std::shared_ptr<PicoScenesPluginManager> getInstance(const std::shared_ptr<AbstractNIC> &nic);
49
50 static std::vector<std::string> listPluginsInFolder();
51
52 static const std::vector<std::shared_ptr<po::options_description>> &getPluginOptions();
53
54 std::pair<bool, std::string> tryInstallPlugin(const std::string &pluginFilePath);
55
56 void parseAndExecuteCommands(const std::string &commandString);
57
58 void callRxHandles(const ModularPicoScenesRxFrame &rxs);
59
60 const std::vector<std::shared_ptr<PicoScenesPluginWrapper>> &getAllPlugins() const;
61
62 void uninstallPlugin(const std::string &plugInName);
63
65
67
68 static std::string pluginDir;
69
70private:
71 explicit PicoScenesPluginManager(std::shared_ptr<AbstractNIC> nic) : nic(std::move(nic)) {}
72
73 std::shared_ptr<AbstractNIC> nic;
74 std::vector<std::shared_ptr<PicoScenesPluginWrapper>> plugins;
75 static std::vector<std::shared_ptr<po::options_description>> pluginOptions;
76
77 static void ensureSinglePluginDescription(const std::shared_ptr<AbstractPicoScenesPlugin> &getPluginCore);
78};
79//
80
81#endif //PICOSCENES_PLATFORM_PICOSCENESPLUGINMANAGER_HXX
static std::vector< std::string > listPluginsInFolder()
void callRxHandles(const ModularPicoScenesRxFrame &rxs)
static std::shared_ptr< PicoScenesPluginManager > getInstance(const std::shared_ptr< AbstractNIC > &nic)
std::pair< bool, std::string > tryInstallPlugin(const std::string &pluginFilePath)
const std::vector< std::shared_ptr< PicoScenesPluginWrapper > > & getAllPlugins() const
void parseAndExecuteCommands(const std::string &commandString)
void uninstallPlugin(const std::string &plugInName)
static const std::vector< std::shared_ptr< po::options_description > > & getPluginOptions()
std::shared_ptr< PicoScenesPluginManager > getManager() const
const std::string & getLibraryFilePath() const
std::shared_ptr< AbstractPicoScenesPlugin > getPluginCore() const
PicoScenesPluginWrapper(const std::string &filePath, std::shared_ptr< PicoScenesPluginManager > manager)