Go to the documentation of this file. 1 #ifndef CNOID_BASE_ITEM_FILE_IO_H
2 #define CNOID_BASE_ITEM_FILE_IO_H
5 #include <cnoid/Referenced>
8 #include "exportdecl.h"
25 OptionPanelForLoading = 1 << 2,
27 OptionPanelForSaving = 1 << 4,
35 bool isFormat(
const std::string& format)
const;
37 bool hasApi(
int api)
const;
38 const std::string& caption()
const;
39 const std::string& fileTypeCaption()
const;
40 void addFormatAlias(
const std::string& format);
41 [[deprecated(
"Use addFormatAlias")]]
43 addFormatAlias(format);
49 void setExtensionFunction(std::function<std::string()> func);
51 std::vector<std::string> extensions()
const;
53 int interfaceLevel()
const;
57 void setCurrentInvocationType(
int type);
61 const std::string& filename,
62 Item* parentItem =
nullptr,
bool doAddition =
true,
Item* nextItem =
nullptr,
63 const Mapping* options =
nullptr);
66 Item* item,
const std::string& filename,
67 Item* parentItem =
nullptr,
bool doAddition =
true,
Item* nextItem =
nullptr,
68 const Mapping* options =
nullptr);
71 bool saveItem(
Item* item,
const std::string& filename,
const Mapping* options =
nullptr);
74 virtual void resetOptions();
75 virtual void storeOptions(
Mapping* options);
76 virtual bool restoreOptions(
const Mapping* options);
79 virtual QWidget* getOptionPanelForLoading();
80 virtual void fetchOptionPanelForLoading();
88 virtual QWidget* getOptionPanelForSaving(
Item* item);
89 virtual void fetchOptionPanelForSaving();
92 int currentInvocationType()
const;
94 bool isRegisteredForSingletonItem()
const;
95 Item* findSingletonItemInstance()
const;
100 static std::vector<std::string> separateExtensions(
const std::string& multiExtString);
103 ItemFileIO(
const std::string& format,
int api);
108 void setApi(
int apiSet);
109 void setCaption(
const std::string& caption);
110 void setFileTypeCaption(
const std::string& caption);
111 void setExtension(
const std::string& extension);
112 void setExtensions(
const std::vector<std::string>& extensions);
113 void setInterfaceLevel(InterfaceLevel level);
116 virtual bool load(
Item* item,
const std::string& filename);
117 virtual Item* createItem();
120 virtual bool save(
Item* item,
const std::string& filename);
123 void putWarning(
const std::string& message);
124 void putError(
const std::string& message);
131 void setActuallyLoadedItem(
Item* item);
141 template<
class ItemType>
154 virtual bool load(
Item* item,
const std::string& filename)
override final {
155 if(
auto derived =
dynamic_cast<ItemType*
>(item)){
156 return load(derived, filename);
160 virtual bool load(ItemType* ,
const std::string& ) {
163 virtual bool save(
Item* item,
const std::string& filename)
override final {
164 if(
auto derived =
dynamic_cast<ItemType*
>(item)){
165 return save(derived, filename);
169 virtual bool save(ItemType* ,
const std::string& ) {
Definition: ItemFileIO.h:19
Definition: ValueTree.h:253
Definition: ItemFileIO.h:142
InterfaceLevel
Definition: ItemFileIO.h:29
bool isRegisteredForSingletonItem() const
Definition: ItemManager.cpp:382
Item * findSingletonItemInstance() const
Definition: ItemManager.cpp:391
virtual QWidget * getOptionPanelForSaving(ItemType *item)
Definition: ItemFileIO.h:175
ItemFileIoBase(const std::string &format, int api)
Definition: ItemFileIO.h:145
virtual bool load(Item *item, const std::string &filename) override final
Definition: ItemFileIO.h:154
Definition: ItemFileDialog.h:11
Definition: Referenced.h:103
virtual Item * createItem() override
Definition: ItemFileIO.h:148
void addFormatIdAlias(const std::string &format)
Definition: ItemFileIO.h:42
virtual bool save(Item *item, const std::string &filename) override final
Definition: ItemFileIO.h:163
virtual QWidget * getOptionPanelForSaving(Item *item) override final
Definition: ItemFileIO.h:172
API
Definition: ItemFileIO.h:22
virtual bool load(ItemType *, const std::string &)
Definition: ItemFileIO.h:160
Definition: AbstractSceneLoader.h:11
virtual bool save(ItemType *, const std::string &)
Definition: ItemFileIO.h:169
@ Standard
Definition: ItemFileIO.h:29
Definition: Referenced.h:54
ref_ptr< ItemFileIO > ItemFileIOPtr
Definition: ItemFileIO.h:139
Definition: ItemManager.h:59
int api() const
Definition: ItemFileIO.cpp:129
InvocationType
Definition: ItemFileIO.h:30