Choreonoid  1.8
ExtensionManager.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_EXTENSION_MANAGER_H
6 #define CNOID_BASE_EXTENSION_MANAGER_H
7 
8 #include <cnoid/Signal>
9 #include <string>
10 #include "exportdecl.h"
11 
12 namespace cnoid {
13 
14 class Item;
15 class View;
16 class ToolBar;
17 class Archive;
18 class ItemManager;
19 class ViewManager;
20 class MenuManager;
21 class OptionManager;
22 
23 class CNOID_EXPORT ExtensionManager
24 {
25 public:
26 
27  ExtensionManager(const std::string& moduleName, bool isPlugin);
28  ExtensionManager(const std::string& moduleName, const std::string& version, bool isPlugin);
29  virtual ~ExtensionManager();
30 
31  const std::string& name() const;
32  const std::string& textDomain() const;
33 
34  ItemManager& itemManager();
35  ViewManager& viewManager();
36  MenuManager& menuManager();
37  OptionManager& optionManager();
38 
39 private:
40 
41  struct CNOID_EXPORT PtrHolderBase {
42  virtual ~PtrHolderBase();
43  };
44 
45  // smart pointer version
46  template <class PointerType> struct PtrHolder : public PtrHolderBase {
47  PtrHolder(PointerType pointer) : pointer(pointer) { }
48  virtual ~PtrHolder() { }
49  PointerType pointer;
50  };
51 
52  // raw pointer version
53  template <class Object> struct PtrHolder<Object*> : public PtrHolderBase {
54  PtrHolder(Object* pointer) : pointer(pointer) { }
55  virtual ~PtrHolder() { delete pointer; }
56  Object* pointer;
57  };
58 
59  void manageSub(PtrHolderBase* holder);
60 
61 public:
62 
63  void addToolBar(ToolBar* toolBar);
64 
74  void mountToolBar(ToolBar* toolBar);
75 
76  template <class PointerType> PointerType manage(PointerType pointer) {
77  manageSub(new PtrHolder<PointerType>(pointer));
78  return pointer;
79  }
80 
86  SignalProxy<void()> sigSystemUpdated();
87 
96  static void notifySystemUpdate();
97 
98  SignalProxy<void()> sigReleaseRequest();
99 
100  void setProjectArchiver(
101  const std::string& name,
102  std::function<bool(Archive&)> storeFunction,
103  std::function<void(const Archive&)> restoreFunction);
104 
105  void setProjectArchiver(
106  std::function<bool(Archive&)> storeFunction,
107  std::function<void(const Archive&)> restoreFunction);
108 
109 private:
111 
112  class Impl;
113  Impl* impl;
114 };
115 
116 }
117 
118 #endif
cnoid::ToolBar
Definition: ToolBar.h:22
cnoid::ExtensionManager
Definition: ExtensionManager.h:23
cnoid::ExtensionManager::manage
PointerType manage(PointerType pointer)
Definition: ExtensionManager.h:76
cnoid::Archive
Definition: Archive.h:22
cnoid::MenuManager
Definition: MenuManager.h:14
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::OptionManager
Definition: OptionManager.h:15
cnoid::ViewManager
Definition: ViewManager.h:19
cnoid::SignalProxy
Definition: Signal.h:470
cnoid::ItemManager
Definition: ItemManager.h:59