Scroom  0.14
pluginmanager.hh
Go to the documentation of this file.
1 /*
2  * Scroom - Generic viewer for 2D data
3  * Copyright (C) 2009-2022 Kees-Jan Dijkzeul
4  *
5  * SPDX-License-Identifier: LGPL-2.1
6  */
7 
8 #pragma once
9 
10 #include <list>
11 #include <map>
12 #include <string>
13 #include <utility>
14 
15 #include <gtk/gtk.h>
16 
20 #include <scroom/scroomplugin.hh>
21 #include <scroom/utilities.hh>
22 
23 #include "view.hh"
24 #include "workinterface.hh"
25 
27 {
28  GModule* plugin;
30 
31  PluginInformation(GModule* plugin_, PluginInformationInterface::Ptr pluginInformation_)
32  : plugin(plugin_)
33  , pluginInformation(std::move(pluginInformation_))
34  {
35  }
36 };
37 
39  : public WorkInterface
40  , public ScroomPluginInterface
41  , virtual public Scroom::Utils::Base
42 {
43 public:
44  using Ptr = boost::shared_ptr<PluginManager>;
45 
46 private:
48  {
53  };
54 
55 private:
56  bool devMode{false};
58  std::list<std::string> dirs;
59  std::list<std::string>::iterator currentDir;
60  std::list<std::string> files;
61  std::list<std::string>::iterator currentFile;
62  std::list<PluginInformation> pluginInformationList;
63  std::map<NewPresentationInterface::Ptr, std::string> newPresentationInterfaces;
64  std::map<std::string, NewAggregateInterface::Ptr> newAggregateInterfaces;
65  std::map<OpenPresentationInterface::Ptr, std::string> openPresentationInterfaces;
66  std::map<Scroom::TiledBitmap::OpenTiledBitmapInterface::Ptr, std::string> openTiledBitmapInterfaces;
67  std::map<OpenInterface::Ptr, std::string> openInterfaces;
68  std::map<ViewObserver::Ptr, std::string> viewObservers;
69  std::map<PresentationObserver::Ptr, std::string> presentationObservers;
70 
71 private:
72  void setStatusBarMessage(const char* message);
73 
74  PluginManager() = default;
75 
76 public:
77  static Ptr create();
78 
79  bool doWork() override;
80 
81  void addHook(bool devMode);
82 
83  void registerNewPresentationInterface(const std::string& identifier,
84  NewPresentationInterface::Ptr newPresentationInterface) override;
85  void registerNewAggregateInterface(const std::string& identifier, NewAggregateInterface::Ptr newAggregateInterface) override;
86  void registerOpenPresentationInterface(const std::string& extension,
87  OpenPresentationInterface::Ptr openPresentationInterface) override;
89  const std::string& identifier,
90  boost::shared_ptr<Scroom::TiledBitmap::OpenTiledBitmapInterface> openTiledBitmapInterface) override;
91  void registerOpenInterface(const std::string& extension, OpenInterface::Ptr openInterface) override;
92  void registerViewObserver(const std::string& identifier, ViewObserver::Ptr observer) override;
93  void registerPresentationObserver(const std::string& identifier, PresentationObserver::Ptr observer) override;
94 
95  const std::map<NewPresentationInterface::Ptr, std::string>& getNewPresentationInterfaces();
96  const std::map<std::string, NewAggregateInterface::Ptr>& getNewAggregateInterfaces();
97  const std::map<OpenPresentationInterface::Ptr, std::string>& getOpenPresentationInterfaces();
98  const std::map<Scroom::TiledBitmap::OpenTiledBitmapInterface::Ptr, std::string>& getOpenTiledBitmapInterfaces();
99  const std::map<OpenInterface::Ptr, std::string>& getOpenInterfaces();
100  const std::map<ViewObserver::Ptr, std::string>& getViewObservers();
101  const std::map<PresentationObserver::Ptr, std::string>& getPresentationObservers();
102 
103 public:
105 };
106 
107 void startPluginManager(bool devMode);
OpenPresentationInterface::Ptr
boost::shared_ptr< OpenPresentationInterface > Ptr
Definition: scroominterface.hh:56
PluginManager::LOADING_FILES
@ LOADING_FILES
Definition: pluginmanager.hh:51
workinterface.hh
PluginManager::registerViewObserver
void registerViewObserver(const std::string &identifier, ViewObserver::Ptr observer) override
Definition: pluginmanager.cc:289
PluginManager::FINDING_DIRECTORIES
@ FINDING_DIRECTORIES
Definition: pluginmanager.hh:49
PresentationObserver::Ptr
boost::shared_ptr< PresentationObserver > Ptr
Definition: scroominterface.hh:83
PLUGIN_API_VERSION
#define PLUGIN_API_VERSION
Definition: plugininformationinterface.hh:15
PluginManager::addHook
void addHook(bool devMode)
Definition: pluginmanager.cc:246
PluginInformation::pluginInformation
PluginInformationInterface::Ptr pluginInformation
Definition: pluginmanager.hh:29
PluginManager::Ptr
boost::shared_ptr< PluginManager > Ptr
Definition: pluginmanager.hh:44
PluginManager::getNewAggregateInterfaces
const std::map< std::string, NewAggregateInterface::Ptr > & getNewAggregateInterfaces()
Definition: pluginmanager.cc:306
PluginManager::registerPresentationObserver
void registerPresentationObserver(const std::string &identifier, PresentationObserver::Ptr observer) override
Definition: pluginmanager.cc:296
PluginManager::getOpenPresentationInterfaces
const std::map< OpenPresentationInterface::Ptr, std::string > & getOpenPresentationInterfaces()
Definition: pluginmanager.cc:311
PluginManager::doWork
bool doWork() override
Definition: pluginmanager.cc:35
utilities.hh
SCROOM_PLUGIN_DIRS
const std::string SCROOM_PLUGIN_DIRS
Definition: pluginmanager.cc:27
scroomplugin.hh
Scroom::TiledBitmap::ToOpenPresentationInterface
OpenPresentationInterface::Ptr ToOpenPresentationInterface(OpenTiledBitmapInterface::Ptr openTiledBitmapInterface)
Definition: tiledbitmappresentation.cc:424
NewAggregateInterface::Ptr
boost::shared_ptr< NewAggregateInterface > Ptr
Definition: scroominterface.hh:47
plugininformationinterface.hh
PluginManager::pluginInformationList
std::list< PluginInformation > pluginInformationList
Definition: pluginmanager.hh:62
PluginManager::PluginManagerState
PluginManagerState
Definition: pluginmanager.hh:47
PluginManager::getOpenTiledBitmapInterfaces
const std::map< Scroom::TiledBitmap::OpenTiledBitmapInterface::Ptr, std::string > & getOpenTiledBitmapInterfaces()
Definition: pluginmanager.cc:316
PluginManager::files
std::list< std::string > files
Definition: pluginmanager.hh:60
on_idle
gboolean on_idle(gpointer user_data)
Definition: callbacks.cc:272
PluginManager::newAggregateInterfaces
std::map< std::string, NewAggregateInterface::Ptr > newAggregateInterfaces
Definition: pluginmanager.hh:64
OpenInterface::Ptr
boost::shared_ptr< OpenInterface > Ptr
Definition: scroominterface.hh:72
PluginInformationInterface::Ptr
boost::shared_ptr< PluginInformationInterface > Ptr
Definition: plugininformationinterface.hh:20
on_new_viewobserver
void on_new_viewobserver(const ViewObserver::Ptr &viewObserver)
Definition: callbacks.cc:726
PluginManager::registerOpenInterface
void registerOpenInterface(const std::string &extension, OpenInterface::Ptr openInterface) override
Definition: pluginmanager.cc:284
PluginManager::create
static Ptr create()
Definition: pluginmanager.cc:31
PluginManager::presentationObservers
std::map< PresentationObserver::Ptr, std::string > presentationObservers
Definition: pluginmanager.hh:69
opentiledbitmapinterface.hh
startPluginManager
void startPluginManager(bool devMode)
Definition: pluginmanager.cc:33
PluginManager::getNewPresentationInterfaces
const std::map< NewPresentationInterface::Ptr, std::string > & getNewPresentationInterfaces()
Definition: pluginmanager.cc:301
PluginManager::getPresentationObservers
const std::map< PresentationObserver::Ptr, std::string > & getPresentationObservers()
Definition: pluginmanager.cc:325
PluginManager::devMode
bool devMode
Definition: pluginmanager.hh:56
PluginManager::openInterfaces
std::map< OpenInterface::Ptr, std::string > openInterfaces
Definition: pluginmanager.hh:67
PluginManager::registerNewPresentationInterface
void registerNewPresentationInterface(const std::string &identifier, NewPresentationInterface::Ptr newPresentationInterface) override
Definition: pluginmanager.cc:257
PluginManager::dirs
std::list< std::string > dirs
Definition: pluginmanager.hh:58
PluginManager::openTiledBitmapInterfaces
std::map< Scroom::TiledBitmap::OpenTiledBitmapInterface::Ptr, std::string > openTiledBitmapInterfaces
Definition: pluginmanager.hh:66
Scroom::Utils::Base
Definition: utilities.hh:30
PluginManager
Definition: pluginmanager.hh:38
PluginManager::registerNewAggregateInterface
void registerNewAggregateInterface(const std::string &identifier, NewAggregateInterface::Ptr newAggregateInterface) override
Definition: pluginmanager.cc:265
ScroomPluginInterface
Definition: scroominterface.hh:99
view.hh
callbacks.hh
ViewObserver::Ptr
boost::shared_ptr< ViewObserver > Ptr
Definition: scroominterface.hh:93
WorkInterface
Definition: workinterface.hh:12
PluginManager::currentFile
std::list< std::string >::iterator currentFile
Definition: pluginmanager.hh:61
PluginManager::getViewObservers
const std::map< ViewObserver::Ptr, std::string > & getViewObservers()
Definition: pluginmanager.cc:323
PluginInformation::plugin
GModule * plugin
Definition: pluginmanager.hh:28
scroominterface.hh
on_done_loading_plugins
void on_done_loading_plugins()
Definition: callbacks.cc:282
PluginManager::getInstance
static PluginManager::Ptr getInstance()
Definition: pluginmanager.cc:330
NewPresentationInterface::Ptr
boost::shared_ptr< NewPresentationInterface > Ptr
Definition: scroominterface.hh:38
PluginManager::getOpenInterfaces
const std::map< OpenInterface::Ptr, std::string > & getOpenInterfaces()
Definition: pluginmanager.cc:321
PluginManager::openPresentationInterfaces
std::map< OpenPresentationInterface::Ptr, std::string > openPresentationInterfaces
Definition: pluginmanager.hh:65
PluginManager::registerOpenPresentationInterface
void registerOpenPresentationInterface(const std::string &extension, OpenPresentationInterface::Ptr openPresentationInterface) override
Definition: pluginmanager.cc:270
PluginManager::state
PluginManagerState state
Definition: pluginmanager.hh:57
PluginInformation
Definition: pluginmanager.hh:26
PluginManager::PluginManager
PluginManager()=default
PluginManager::newPresentationInterfaces
std::map< NewPresentationInterface::Ptr, std::string > newPresentationInterfaces
Definition: pluginmanager.hh:63
startPluginManager
void startPluginManager(bool devMode)
Definition: pluginmanager.cc:33
pluginManager
static PluginManager::Ptr pluginManager
Definition: pluginmanager.cc:29
PluginManager::viewObservers
std::map< ViewObserver::Ptr, std::string > viewObservers
Definition: pluginmanager.hh:68
PluginManager::SCANNING_DIRECTORIES
@ SCANNING_DIRECTORIES
Definition: pluginmanager.hh:50
PluginInformation::PluginInformation
PluginInformation(GModule *plugin_, PluginInformationInterface::Ptr pluginInformation_)
Definition: pluginmanager.hh:31
pluginmanager.hh
PluginManager::registerOpenTiledBitmapInterface
void registerOpenTiledBitmapInterface(const std::string &identifier, boost::shared_ptr< Scroom::TiledBitmap::OpenTiledBitmapInterface > openTiledBitmapInterface) override
Definition: pluginmanager.cc:276
PluginManager::setStatusBarMessage
void setStatusBarMessage(const char *message)
Definition: pluginmanager.cc:240
PluginManager::DONE
@ DONE
Definition: pluginmanager.hh:52
PluginManager::currentDir
std::list< std::string >::iterator currentDir
Definition: pluginmanager.hh:59
on_newPresentationInterfaces_update
void on_newPresentationInterfaces_update(const std::map< NewPresentationInterface::Ptr, std::string > &newPresentationInterfaces)
Definition: callbacks.cc:615