OperationJournal.h header

#include <ew/core/OperationJournal.h>

Namespace ew::core

OperationJournal class

class ew::core::OperationJournal

An append-only record of the changes made to a project.

Deliberately a plain container with no I/O, no clock and no threading of its own: what is recorded, when it is written, and where it is stored are the caller's decisions. That keeps the journal usable from libs/core, which may depend on neither UI nor networking, and keeps it testable without a filesystem.

Purely local, and required by nothing. The app runs identically whether or not anything ever reads this. It exists so an audit trail and a "what changed since" view can be built on it later; it is not a synchronization log and has no remote counterpart.

Members

ew::core::journal::OperationJournal::OperationJournal()=default

Creates an empty journal.

void ew::core::journal::OperationJournal::append(JournalEntry entry)

Appends entry. Entries are never rewritten or removed, so this is the only way the journal grows and the order of entries is the order changes were applied.

const std::vector< JournalEntry > & ew::core::journal::OperationJournal::entries() const

The entries, oldest first.

std::size_t ew::core::journal::OperationJournal::size() const

The number of entries recorded.

bool ew::core::journal::OperationJournal::isEmpty() const

Whether nothing has been recorded yet.

std::vector< JournalEntry > ew::core::journal::OperationJournal::entriesInGroup(OperationGroupId group) const

Every entry belonging to group, oldest first, so the several mutations of one user action can be shown together. Empty when no entry carries that group.

QJsonArray ew::core::journal::OperationJournal::toJson() const

Serializes the whole journal to a JSON array, oldest entry first.

static std::optional< OperationJournal > ew::core::journal::OperationJournal::fromJson(const QJsonArray &json)

Parses a journal from json. Returns std::nullopt if ANY entry is malformed, rather than silently returning the entries that happened to survive: a partially-read audit trail that looks complete is worse than a refusal the caller can report.