Choreonoid  1.8
Plugin.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_PLUGIN_H
6 #define CNOID_BASE_PLUGIN_H
7 
8 #include "ExtensionManager.h"
9 #include <cnoid/Config>
10 #include <string>
11 #include "exportdecl.h"
12 
13 namespace cnoid {
14 
15 class Item;
16 class View;
17 class ToolBar;
18 class PluginManager;
19 
20 class CNOID_EXPORT Plugin : public ExtensionManager
21 {
22 public:
23  typedef Plugin* (*PluginEntry)();
24 
25  Plugin(const std::string& name);
26  virtual ~Plugin();
27 
28  const std::string& name() const;
29  const std::string& filePath() const;
30 
31  virtual bool initialize();
32  virtual bool finalize();
33 
34  bool isActive() const { return isActive_; }
35  bool isUnloadable() const;
36 
37  const std::string& requisite(int index) const;
38  int numRequisites() const;
39 
40  const std::string& subsequence(int index) const;
41  int numSubsequences() const;
42 
43  const std::string& oldName(int index) const;
44  int numOldNames() const;
45 
46  virtual const char* description() const;
47 
48  int activationPriority() const;
49 
50  unsigned int internalVersion() const;
51 
52  // Only called from the getChoreonoidPlugin() function
53  void setInternalVersion(unsigned int version);
54 
55 protected:
56  void setPluginScope(Item* item);
57  void setPluginScope(View* view);
58  void setPluginScope(ToolBar* toolBar);
59 
60  void setUnloadable(bool on);
61 
62  void require(const std::string& pluginName);
63  void precede(const std::string& pluginName);
64 
72  void setActivationPriority(int priority);
73 
78  void addOldName(const std::string& name);
79 
80 #ifdef CNOID_BACKWARD_COMPATIBILITY
81  void depend(const std::string& pluginName);
82 #endif
83 
84  static const char* MITLicenseText();
85  static const char* LGPLtext();
86 
87 private:
88  Plugin(const Plugin& org); // disable the copy constructor
89  void setFilePath(const std::string& filePath);
90 
91  class Impl;
92  Impl* impl;
93  bool isActive_;
94 
95  friend class PluginManager;
96 };
97 
98 }
99 
100 
101 #define CNOID_IMPLEMENT_PLUGIN_ENTRY(PluginTypeName) \
102  extern "C" CNOID_BASE_DLLEXPORT cnoid::Plugin* getChoreonoidPlugin() \
103  { \
104  cnoid::Plugin* plugin = new PluginTypeName(); \
105  plugin->setInternalVersion(CNOID_INTERNAL_VERSION); \
106  return plugin; \
107  }
108 
109 #endif
cnoid::Plugin::isActive
bool isActive() const
Definition: Plugin.h:34
cnoid::ToolBar
Definition: ToolBar.h:22
cnoid::ExtensionManager
Definition: ExtensionManager.h:23
cnoid::View
Definition: View.h:27
cnoid::MITLicenseText
const char * MITLicenseText()
Definition: Licenses.cpp:5
cnoid::Plugin
Definition: Plugin.h:20
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::Item
Definition: Item.h:29
cnoid::PluginManager
Definition: PluginManager.h:16
cnoid::LGPLtext
const char * LGPLtext()
Definition: Licenses.cpp:27
ExtensionManager.h