Choreonoid  1.8
ProjectManager.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_PROJECT_MANAGER_H
6 #define CNOID_BASE_PROJECT_MANAGER_H
7 
8 #include "ItemList.h"
9 #include <string>
10 #include <functional>
11 #include "exportdecl.h"
12 
13 namespace cnoid {
14 
15 class ExtensionManager;
16 class Archive;
17 
18 class CNOID_EXPORT ProjectManager
19 {
20 public:
21  // This function is called before initializaing the App class
22  static void setDefaultOptionToStoreLayoutInProjectFile(bool on);
23 
24  static void initializeClass(ExtensionManager* ext);
25  static ProjectManager* instance();
26 
27  //The constructor used to create a sub instance for recursive loading / saving
29 
30  ~ProjectManager();
31 
32  void clearProject();
33 
34  /*
35  \param parentItem The item to add the root item of the project to load.
36  If this argument is nullptr, the items of the existing project are cleared
37  and the project is newly loaded.
38  */
39  void loadProject(const std::string& filename, Item* parentItem = nullptr);
40 
41  void loadBuiltinProject(const std::string& resourceFile, Item* parentItem = nullptr);
42  bool isLoadingProject() const;
43  void saveProject(const std::string& filename, Item* item = nullptr);
44  void overwriteCurrentProject();
45  std::string currentProjectFile() const;
46  std::string currentProjectDirectory() const;
47  void setCurrentProjectName(const std::string& filename);
48 
49  SignalProxy<void(int recursiveLevel)> sigProjectAboutToBeLoaded();
50  SignalProxy<void(int recursiveLevel)> sigProjectLoaded();
51 
52 private:
54 
55  class Impl;
56  Impl* impl;
57 
58  friend class ExtensionManager;
59  friend class ExtensionManagerImpl;
60 
61  void setArchiver(
62  const std::string& moduleName,
63  const std::string& objectName,
64  std::function<bool(Archive&)> storeFunction,
65  std::function<void(const Archive&)> restoreFunction);
66 
67  void resetArchivers(const std::string& moduleName);
68 };
69 
70 }
71 
72 #endif
cnoid::ExtensionManager
Definition: ExtensionManager.h:23
cnoid::Archive
Definition: Archive.h:22
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::Item
Definition: Item.h:29
ItemList.h
cnoid::ProjectManager
Definition: ProjectManager.h:18
cnoid::SignalProxy
Definition: Signal.h:470