41 template <
typename T>
bool process(
const std::string& dirname, T method)
46 for (
auto model :
models()) {
49 std::invoke(method, document,
filename);
66 return p_impl->m_project_dir;
85 return p_impl->m_change_controller.hasChanged();
virtual void load(const std::string &file_name)=0
virtual void save(const std::string &file_name) const =0
Tracks changes in all models.
void resetChanged()
Reset controller to initial state, pretending that no changes has been registered.
std::string projectDir() const override
Returns the full path to a project directory.
Project(const ProjectContext &context)
bool load(const std::string &dirname) override
Loads all models from the given directory.
bool save(const std::string &dirname) const override
Saves all models to a given directory.
bool isModified() const override
std::unique_ptr< ProjectImpl > p_impl
std::string filename(const std::string &path)
Returns path without directory part ("Foo/Bar/Doz.int.gz" -> "Doz.int.gz")
MVVM_MODEL_EXPORT std::string SuggestFileName(const SessionModel &model)
Suggests file name which can be used to store json content of given model.
MVVM_MODEL_EXPORT std::string join(const std::string &part1, const std::string &part2)
Joins two path elements into the path.
MVVM_MODEL_EXPORT bool exists(const std::string &fileName)
Returns true if file exists.
materialitems.h Collection of materials to populate MaterialModel.
std::unique_ptr< ModelDocumentInterface > CreateJsonDocument(const std::vector< SessionModel * > &models)
Creates JsonDocument to save and load models.
Provides necessary information for Project construction.
models_callback_t m_models_callback
ProjectChangedController m_change_controller
ProjectImpl(const ProjectContext &context)
bool process(const std::string &dirname, T method)
Processes all models one by one and either save or load them to/from given directory.
std::string m_project_dir
std::vector< SessionModel * > models() const
Returns list of models which are subject to save/load.