FolderProjectStore.h header

#include <ew/app/FolderProjectStore.h>

Namespace ew::app

FolderProjectStore class

class ew::app::FolderProjectStore

The on-disk folder-of-text store (DESIGN.md section 6.1): each content object is one file, so revisions diff and merge cleanly in Perforce/Git. A store location is a filesystem directory – which is why these overrides name that parameter directory where the interface calls it a location – and it is created if needed on write.

This is the store the product ships with, and it is why the desktop build opens and saves a project with no account, no network and no server anywhere in the path. It holds no state: one instance serves any number of projects and instances are interchangeable, so each client constructs one at its composition root and hands out references.

Members

ew::app::persistence::FolderProjectStore::FolderProjectStore()=default

Constructs the store. Touches no disk.

ew::core::foundation::Result< void > ew::app::persistence::FolderProjectStore::save(const ew::core::project::Project &project, const QString &directory) override

Writes project into directory (created if needed), one file per object.

ew::core::foundation::Result< std::unique_ptr< ew::core::project::Project > > ew::app::persistence::FolderProjectStore::load(const QString &directory, const ew::core::foundation::OperationContext &operation) override

Loads a project from directory; an absent object folder yields an empty project rather than an error. Reports one step per object file read and polls operation for cancellation; see ProjectStore::load for why a cancelled load errors rather than returning what it managed to read.

ew::core::foundation::Result< void > ew::app::persistence::FolderProjectStore::saveSubset(const ew::core::project::Project &project, const std::vector< ew::core::foundation::ContentId > &objectIds, const std::vector< ew::core::foundation::CategoryId > &categoryIds, const QString &directory) override

Writes the subset named by objectIds and categoryIds from project into directory.

bool ew::app::persistence::FolderProjectStore::exists(const QString &directory) const override

Whether directory holds a project.json, which is what makes a folder a project in this format.

Functions

std::unique_ptr< ew::core::content::ContentObject > ew::app::persistence::cloneObject(const ew::core::content::ContentObject &object)

Returns a deep copy of object with a freshly generated identity, produced by round-tripping it through the same per-object JSON serialization used to persist the project. Because the copy is reconstructed from the object's full serialized form, every stored field is duplicated and the clone stays complete as new fields are added – so it is safe to build "Duplicate" actions on. The returned object is not yet part of any project; the caller adds it (e.g. via AddObjectCommand) and adjusts placement fields (title, parent, sort order) as needed.

Deliberately NOT on the ProjectStore interface: it moves nothing to or from a location, so asking a backend to duplicate an in-memory object would be meaningless. It lives beside this store because the serialization it round-trips through is this format's.

bool ew::app::persistence::isManagedProjectFile(const QString &relativePath)

Whether relativePath (a forward-slash, project-relative path, as produced by readTextSnapshot) is a file this store owns: project.json, or a *.json directly under the objects/ or taxonomy/ subfolder. save() writes exactly these and prunes only within those two subfolders, so every other file in the folder – a user's README.md, a nested library, an export – is foreign. The external-change reconcile uses this to consider only store-owned files: a foreign file, being absent from the project's own serialization, would otherwise look "deleted locally" and be removed. Case-sensitive on the .json suffix per the on-disk convention.