#include <pluginmanager.hh>
|
| bool | doWork () override |
| |
| void | addHook (bool devMode) |
| |
| void | registerNewPresentationInterface (const std::string &identifier, NewPresentationInterface::Ptr newPresentationInterface) override |
| |
| void | registerNewAggregateInterface (const std::string &identifier, NewAggregateInterface::Ptr newAggregateInterface) override |
| |
| void | registerOpenPresentationInterface (const std::string &extension, OpenPresentationInterface::Ptr openPresentationInterface) override |
| |
| void | registerOpenTiledBitmapInterface (const std::string &identifier, boost::shared_ptr< Scroom::TiledBitmap::OpenTiledBitmapInterface > openTiledBitmapInterface) override |
| |
| void | registerOpenInterface (const std::string &extension, OpenInterface::Ptr openInterface) override |
| |
| void | registerViewObserver (const std::string &identifier, ViewObserver::Ptr observer) override |
| |
| void | registerPresentationObserver (const std::string &identifier, PresentationObserver::Ptr observer) override |
| |
| const std::map< NewPresentationInterface::Ptr, std::string > & | getNewPresentationInterfaces () |
| |
| const std::map< std::string, NewAggregateInterface::Ptr > & | getNewAggregateInterfaces () |
| |
| const std::map< OpenPresentationInterface::Ptr, std::string > & | getOpenPresentationInterfaces () |
| |
| const std::map< Scroom::TiledBitmap::OpenTiledBitmapInterface::Ptr, std::string > & | getOpenTiledBitmapInterfaces () |
| |
| const std::map< OpenInterface::Ptr, std::string > & | getOpenInterfaces () |
| |
| const std::map< ViewObserver::Ptr, std::string > & | getViewObservers () |
| |
| const std::map< PresentationObserver::Ptr, std::string > & | getPresentationObservers () |
| |
| | Base ()=default |
| |
| | Base (const Base &)=delete |
| |
| | Base (Base &&)=delete |
| |
| Base & | operator= (const Base &)=delete |
| |
| Base & | operator= (Base &&)=delete |
| |
| virtual | ~Base ()=default |
| |
| template<typename R > |
| boost::shared_ptr< R > | shared_from_this () |
| |
| template<typename R > |
| boost::shared_ptr< R const > | shared_from_this () const |
| |
◆ Ptr
◆ PluginManagerState
| Enumerator |
|---|
| FINDING_DIRECTORIES | |
| SCANNING_DIRECTORIES | |
| LOADING_FILES | |
| DONE | |
◆ PluginManager()
| PluginManager::PluginManager |
( |
| ) |
|
|
privatedefault |
◆ addHook()
| void PluginManager::addHook |
( |
bool |
devMode | ) |
|
◆ create()
◆ doWork()
| bool PluginManager::doWork |
( |
| ) |
|
|
overridevirtual |
Implements WorkInterface.
51 std::string plugin_path = (boost::dll::program_location().parent_path() /
"plugins").generic_string();
52 dirs.push_back(plugin_path);
54 dirs.emplace_back(PLUGIN_DIR);
62 for(
char* i = path; *i !=
'\0'; i++)
67 const char envDelim =
';';
69 const char envDelim =
':';
77 dirs.emplace_back(path);
81 dirs.emplace_back(path);
100 spdlog::debug(
"Scanning directory: {}", *
currentDir);
102 namespace fs = boost::filesystem;
103 boost::system::error_code ec;
105 if(!fs::is_directory(folder, ec))
107 spdlog::error(
"Can't open directory: {}", folder);
112 for(
const auto& entry: fs::directory_iterator(folder))
114 if(fs::is_regular_file(entry) || fs::is_symlink(entry) || fs::is_other(entry))
116 files.push_back(entry.path().generic_string());
143 GModule* plugin = g_module_open(
currentFile->c_str(),
static_cast<GModuleFlags
>(0));
146 gpointer pgpi =
nullptr;
147 bool symbol_found =
false;
149 if(g_module_symbol(plugin,
"_Z20getPluginInformationv", &pgpi))
153 else if(g_module_symbol(plugin,
"getPluginInformation", &pgpi))
156 spdlog::warn(
"Plugin {} uses C-style GetPluginInformation - You need to recompile it", *
currentFile);
161 using PluginFunc = boost::shared_ptr<PluginInformationInterface> (*)();
163 auto gpi =
reinterpret_cast<PluginFunc
>(pgpi);
172 pi->registerCapabilities(shared_from_this<PluginManager>());
179 spdlog::error(
"Plugin {} has incorrect API version {}, instead of {}",
181 pi->pluginApiVersion,
187 spdlog::error(
"GetPluginInformation returned NULL for file {}", *
currentFile);
192 spdlog::error(
"Can't find the getPluginInterface function in file {}: {}", *
currentFile, g_module_error());
197 spdlog::warn(
"Can't lookup symbols in file {}: {}", *
currentFile, g_module_error());
202 g_module_close(plugin);
207 spdlog::error(
"Something went wrong for file {}: {}", *
currentFile, g_module_error());
217 std::vector<std::pair<std::string, std::string>> pluginInfo;
219 size_t maxPluginNameLength = 0;
222 pluginInfo.emplace_back(plugin.pluginInformation->getPluginName(), plugin.pluginInformation->getPluginVersion());
223 maxPluginNameLength = std::max(maxPluginNameLength, plugin.pluginInformation->getPluginName().size());
225 std::sort(pluginInfo.begin(), pluginInfo.end());
226 spdlog::info(
"Loaded plugins:");
227 for(
const auto& [name, version]: pluginInfo)
229 spdlog::info(
" {:{}} : {}", name, maxPluginNameLength, version);
◆ getInstance()
◆ getNewAggregateInterfaces()
◆ getNewPresentationInterfaces()
◆ getOpenInterfaces()
◆ getOpenPresentationInterfaces()
◆ getOpenTiledBitmapInterfaces()
◆ getPresentationObservers()
◆ getViewObservers()
| const std::map< ViewObserver::Ptr, std::string > & PluginManager::getViewObservers |
( |
| ) |
|
◆ registerNewAggregateInterface()
| void PluginManager::registerNewAggregateInterface |
( |
const std::string & |
identifier, |
|
|
NewAggregateInterface::Ptr |
newAggregateInterface |
|
) |
| |
|
overridevirtual |
◆ registerNewPresentationInterface()
◆ registerOpenInterface()
| void PluginManager::registerOpenInterface |
( |
const std::string & |
extension, |
|
|
OpenInterface::Ptr |
openInterface |
|
) |
| |
|
overridevirtual |
◆ registerOpenPresentationInterface()
◆ registerOpenTiledBitmapInterface()
◆ registerPresentationObserver()
◆ registerViewObserver()
| void PluginManager::registerViewObserver |
( |
const std::string & |
identifier, |
|
|
ViewObserver::Ptr |
observer |
|
) |
| |
|
overridevirtual |
◆ setStatusBarMessage()
| void PluginManager::setStatusBarMessage |
( |
const char * |
message | ) |
|
|
private |
◆ currentDir
| std::list<std::string>::iterator PluginManager::currentDir |
|
private |
◆ currentFile
| std::list<std::string>::iterator PluginManager::currentFile |
|
private |
◆ devMode
| bool PluginManager::devMode {false} |
|
private |
◆ dirs
| std::list<std::string> PluginManager::dirs |
|
private |
◆ files
| std::list<std::string> PluginManager::files |
|
private |
◆ newAggregateInterfaces
◆ newPresentationInterfaces
◆ openInterfaces
◆ openPresentationInterfaces
◆ openTiledBitmapInterfaces
◆ pluginInformationList
◆ presentationObservers
◆ state
◆ viewObservers
The documentation for this class was generated from the following files:
@ LOADING_FILES
Definition: pluginmanager.hh:51
@ FINDING_DIRECTORIES
Definition: pluginmanager.hh:49
boost::shared_ptr< PluginManager > Ptr
Definition: pluginmanager.hh:44
const std::string SCROOM_PLUGIN_DIRS
Definition: pluginmanager.cc:27
OpenPresentationInterface::Ptr ToOpenPresentationInterface(OpenTiledBitmapInterface::Ptr openTiledBitmapInterface)
Definition: tiledbitmappresentation.cc:424
std::list< PluginInformation > pluginInformationList
Definition: pluginmanager.hh:62
std::list< std::string > files
Definition: pluginmanager.hh:60
gboolean on_idle(gpointer user_data)
Definition: callbacks.cc:272
std::map< std::string, NewAggregateInterface::Ptr > newAggregateInterfaces
Definition: pluginmanager.hh:64
void on_new_viewobserver(const ViewObserver::Ptr &viewObserver)
Definition: callbacks.cc:726
std::map< PresentationObserver::Ptr, std::string > presentationObservers
Definition: pluginmanager.hh:69
bool devMode
Definition: pluginmanager.hh:56
std::map< OpenInterface::Ptr, std::string > openInterfaces
Definition: pluginmanager.hh:67
std::list< std::string > dirs
Definition: pluginmanager.hh:58
std::map< Scroom::TiledBitmap::OpenTiledBitmapInterface::Ptr, std::string > openTiledBitmapInterfaces
Definition: pluginmanager.hh:66
Definition: workinterface.hh:12
std::list< std::string >::iterator currentFile
Definition: pluginmanager.hh:61
void on_done_loading_plugins()
Definition: callbacks.cc:282
std::map< OpenPresentationInterface::Ptr, std::string > openPresentationInterfaces
Definition: pluginmanager.hh:65
PluginManagerState state
Definition: pluginmanager.hh:57
std::map< NewPresentationInterface::Ptr, std::string > newPresentationInterfaces
Definition: pluginmanager.hh:63
static PluginManager::Ptr pluginManager
Definition: pluginmanager.cc:29
std::map< ViewObserver::Ptr, std::string > viewObservers
Definition: pluginmanager.hh:68
@ SCANNING_DIRECTORIES
Definition: pluginmanager.hh:50
void setStatusBarMessage(const char *message)
Definition: pluginmanager.cc:240
@ DONE
Definition: pluginmanager.hh:52
std::list< std::string >::iterator currentDir
Definition: pluginmanager.hh:59
void on_newPresentationInterfaces_update(const std::map< NewPresentationInterface::Ptr, std::string > &newPresentationInterfaces)
Definition: callbacks.cc:615