5 #ifndef CNOID_BASE_VIEW_MANAGER_H
6 #define CNOID_BASE_VIEW_MANAGER_H
11 #include <cnoid/Signal>
13 #include "exportdecl.h"
17 class ExtensionManager;
29 virtual View* create() = 0;
42 SINGLE_OPTIONAL = Single,
43 SINGLE_DEFAULT = Single | Default,
44 MULTI_OPTIONAL = Multiple,
45 MULTI_DEFAULT = Multiple | Default
48 template <
class ViewType>
50 const std::string& className,
const std::string& defaultInstanceName,
int instantiationFlags = Single) {
52 typeid(ViewType), className, defaultInstanceName, instantiationFlags,
new Factory<ViewType>());
56 ViewManager& registerClassAlias(
const std::string& alias,
const std::string& orgClassName);
58 static ViewClass* viewClass(
const std::type_info& view_type_info);
61 static View* getOrCreateView(
const std::string& moduleName,
const std::string& className);
64 static View* getOrCreateView(
65 const std::string& moduleName,
const std::string& className,
const std::string& instanceName);
67 static std::vector<View*> allViews();
68 static std::vector<View*> activeViews();
70 template <
class ViewType>
static ViewType*
getOrCreateView(
bool doMountCreatedView =
false) {
71 return static_cast<ViewType*
>(getOrCreateSpecificTypeView(
typeid(ViewType), std::string(), doMountCreatedView));
74 template <
class ViewType>
static ViewType*
getOrCreateView(
const std::string& instanceName,
bool doMountCreatedView =
false) {
75 return static_cast<ViewType*
>(getOrCreateSpecificTypeView(
typeid(ViewType), instanceName, doMountCreatedView));
78 template <
class ViewType>
static ViewType*
findView() {
79 return static_cast<ViewType*
>(findSpecificTypeView(
typeid(ViewType), std::string()));
82 template <
class ViewType>
static ViewType*
findView(
const std::string& instanceName) {
83 return static_cast<ViewType*
>(findSpecificTypeView(
typeid(ViewType), instanceName));
86 void deleteView(
View* view);
88 static bool isPrimalInstance(
View* view);
90 static bool storeViewStates(
ArchivePtr archive,
const std::string& key);
96 operator bool()
const {
return (data != 0); }
102 static bool restoreViews(
104 const std::set<std::string>& optionalPlugins);
118 const std::type_info& view_type_info,
119 const std::string& className,
const std::string& defaultInstanceName,
int instantiationFlags,
120 FactoryBase* factory);
121 static View* getOrCreateSpecificTypeView(
122 const std::type_info& view_type_info,
const std::string& instanceName,
bool doMountCreatedView);
123 static View* findSpecificTypeView(
const std::type_info& view_type_info,
const std::string& instanceName);