Choreonoid  1.5
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 TimeSyncItemEngineManager;
21 class MenuManager;
22 class OptionManager;
23 
24 class ExtensionManagerImpl;
25 
27 {
28 public:
29 
30  ExtensionManager(const std::string& moduleName, bool isPlugin);
31  ExtensionManager(const std::string& moduleName, const std::string& version, bool isPlugin);
32  virtual ~ExtensionManager();
33 
34  const std::string& name() const;
35  const std::string& textDomain() const;
36 
37  ItemManager& itemManager();
38  TimeSyncItemEngineManager& timeSyncItemEngineManger();
39  ViewManager& viewManager();
40  MenuManager& menuManager();
41  OptionManager& optionManager();
42 
43 private:
44 
45  struct CNOID_EXPORT PtrHolderBase {
46  virtual ~PtrHolderBase();
47  };
48 
49  // smart pointer version
50  template <class PointerType> struct PtrHolder : public PtrHolderBase {
51  PtrHolder(PointerType pointer) : pointer(pointer) { }
52  virtual ~PtrHolder() { }
53  PointerType pointer;
54  };
55 
56  // raw pointer version
57  template <class Object> struct PtrHolder<Object*> : public PtrHolderBase {
58  PtrHolder(Object* pointer) : pointer(pointer) { }
59  virtual ~PtrHolder() { delete pointer; }
60  Object* pointer;
61  };
62 
63  void manageSub(PtrHolderBase* holder);
64 
65 public:
66 
67  void addToolBar(ToolBar* toolBar);
68 
69  template <class PointerType> PointerType manage(PointerType pointer) {
70  manageSub(new PtrHolder<PointerType>(pointer));
71  return pointer;
72  }
73 
82  SignalProxy<void()> sigSystemUpdated();
83 
93  static void notifySystemUpdate();
94 
95  SignalProxy<void()> sigReleaseRequest();
96 
97  void setProjectArchiver(
98  const std::string& name,
99  boost::function<bool(Archive&)> storeFunction,
100  boost::function<void(const Archive&)> restoreFunction);
101 
102  void setProjectArchiver(
103  boost::function<bool(Archive&)> storeFunction,
104  boost::function<void(const Archive&)> restoreFunction);
105 
106 private:
107  ExtensionManager(const ExtensionManager& org); // disable the copy constructor
108 
109  ExtensionManagerImpl* impl;
110 
111  friend class ExtensionManagerImpl;
112 };
113 
114 }
115 
116 #endif
PointerType manage(PointerType pointer)
Definition: ExtensionManager.h:69
Definition: Archive.h:21
Definition: ExtensionManager.h:26
Definition: OptionManager.h:15
Definition: ToolBar.h:22
Definition: MenuManager.h:23
Defines the minimum processing for performing pasing file for STL.
Definition: AbstractSceneLoader.h:9
Definition: ViewManager.h:20
#define CNOID_EXPORT
Definition: Util/exportdecl.h:37
Definition: Signal.h:380
Definition: TimeSyncItemEngine.h:28
Definition: ItemManager.h:39