5 #ifndef CNOID_BASE_ARCHIVE_H
6 #define CNOID_BASE_ARCHIVE_H
8 #include <cnoid/ValueTree>
11 #include "exportdecl.h"
19 class FilePathVariableProcessor;
20 class ArchiveSharedData;
29 void initSharedInfo(
const std::string& projectFile,
bool isSubProject);
30 void inheritSharedInfoFrom(
Archive& archive);
32 void addProcessOnSubTreeRestored(
const std::function<
void()>& func)
const;
33 void addPostProcess(
const std::function<
void()>& func,
int priority = 0)
const;
34 void addFinalProcess(
const std::function<
void()>& func)
const;
36 Archive* findSubArchive(
const std::string& name);
37 const Archive* findSubArchive(
const std::string& name)
const;
38 bool forSubArchive(
const std::string& name, std::function<
bool(
const Archive& archive)> func)
const;
39 Archive* openSubArchive(
const std::string& name);
45 int getViewId(
const View* view)
const;
46 View* findView(
int id)
const;
51 return dynamic_cast<ItemType*
>(findItem(
id));
54 void writeItemId(
const std::string& key,
Item* item);
56 template<
class ItemType>
inline ItemType*
findItem(
const std::string& key)
const {
58 return id->isValid() ? findItem<ItemType>(
id) : 0;
61 std::string resolveRelocatablePath(
const std::string& relocatable,
bool doAbsolutize =
true)
const;
62 bool readRelocatablePath(
const std::string& key, std::string& out_value)
const;
63 std::string readItemFilePath()
const;
66 [[deprecated(
"Use resolveRelocatablePath(path, false).")]]
68 return resolveRelocatablePath(path,
false);
71 bool loadFileTo(
Item* item)
const;
72 bool loadFileTo(
Item* item,
const std::string& filepath)
const;
74 std::string getRelocatablePath(
const std::string& path)
const;
75 bool writeRelocatablePath(
const std::string& key,
const std::string& path);
76 bool writeFileInformation(
Item* item);
79 [[deprecated(
"Use loadFileTo(Item* item, const std::string& filepath)")]]
81 return loadFileTo(item, filepath);
85 bool loadItemFile(
Item* item,
const std::string& fileNameKey,
const std::string& fileFormatKey = std::string())
const;
87 Item* currentParentItem()
const;
89 std::string projectDirectory()
const;
96 Item* findItem(
int id)
const;
97 void setCurrentParentItem(
Item* parentItem);
98 static Archive* invalidArchive();
99 void registerItemId(
const Item* item,
int id);
100 void registerViewId(
const View* view,
int id);
103 void setPointerToProcessesOnSubTreeRestored(std::vector<std::function<
void()>>* pfunc);
104 void callPostProcesses();
105 static void callFinalProcesses();