Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::DocumentState Class Reference

Shared mutable state behind SVGDocument and SVGElement facades. More...

#include "donner/svg/DocumentState.h"

Public Member Functions

 DocumentState ()
 Create a new empty document state.
 DocumentState (std::shared_ptr< Registry > registry)
 Wrap an existing shared registry.
Registry & registry ()
 Get the underlying ECS registry.
const Registry & registry () const
 Get the underlying ECS registry.
std::shared_ptr< Registry > sharedRegistry () const
 Get the shared registry retained by this state.
const std::shared_ptr< xml::components::XMLSourceStoreHolder > & sourceStoreHolder () const
 The holder of the XML source store of a document built on an XML tree, or null for one built without an XML tree.
void setSourceStoreHolder (std::shared_ptr< xml::components::XMLSourceStoreHolder > sourceStoreHolder)
 Records the holder of the document's source store.
DocumentReadAccess read ()
 Acquire read access to the document.
DocumentWriteAccess write ()
 Acquire write access to the document.
std::optional< DocumentWriteAccess > tryWrite ()
 Try to acquire write access without waiting.
std::uint64_t revision () const
 Current document mutation revision.
std::uint64_t mutationSequence () const
 Latest mutation-log sequence number.
DocumentMutationLogSnapshot mutationRecordsSince (std::uint64_t afterSequence) const
 Return mutation records after a previously observed sequence.
DocumentAccessDiagnostics accessDiagnostics () const
 Current document access diagnostics.
void resetAccessDiagnostics ()
 Reset cumulative access diagnostics.
bool currentThreadHasWriteAccess () const
 Returns true if this thread currently holds write access to this document.
bool currentThreadHasAccess () const
 Returns true if this thread currently holds read or write access to this document.
void bumpMutationRevision ()
 Mark the document as mutated.
DetachedNodeState & detachedNodeState ()
 Detached-node collection state for this document.
const DetachedNodeState & detachedNodeState () const
 Detached-node collection state for this document.
DetachedNodeCollectionDeferral deferDetachedNodeCollection ()
 Defer detached-node collection while a render snapshot or observer epoch may use it.
bool hasActiveDetachedNodeCollectionDeferral () const
 Returns true when a render snapshot or observer epoch is deferring collection.
std::uint64_t activeDetachedNodeCollectionEpoch () const
 Current detached-node collection epoch high-water.
ThreadingMode threadingMode () const
 Current DOM threading policy.
void setThreadingMode (ThreadingMode mode)
 Set the DOM threading policy.

Friends

class DetachedNodeCollectionDeferral
class DocumentReadAccess
class DocumentMutationBatch
class DocumentWriteAccess

Detailed Description

Shared mutable state behind SVGDocument and SVGElement facades.

This currently owns the ECS registry and a mutation revision. It is intentionally a thin indirection layer so later phases can add reader/writer guards and render snapshots without changing the public DOM handles again.

Constructor & Destructor Documentation

◆ DocumentState()

donner::svg::DocumentState::DocumentState ( std::shared_ptr< Registry > registry)
inlineexplicit

Wrap an existing shared registry.

Parameters
registryRegistry to retain.

Member Function Documentation

◆ mutationRecordsSince()

DocumentMutationLogSnapshot donner::svg::DocumentState::mutationRecordsSince ( std::uint64_t afterSequence) const
inline

Return mutation records after a previously observed sequence.

This is a polling hook for renderers, editor integrations, scripting, and future mutation observers. It intentionally does not invoke callbacks while document write access is held.

Parameters
afterSequenceLast sequence number already observed by the caller.

◆ resetAccessDiagnostics()

void donner::svg::DocumentState::resetAccessDiagnostics ( )
inline

Reset cumulative access diagnostics.

Active lock state is not modified. Callers should only reset diagnostics between measured intervals when no access guard is held if they need a clean lock-hold sample.

◆ setSourceStoreHolder()

void donner::svg::DocumentState::setSourceStoreHolder ( std::shared_ptr< xml::components::XMLSourceStoreHolder > sourceStoreHolder)
inline

Records the holder of the document's source store.

Called once, while the document is being built and before any other thread can reach it. The holder itself is never replaced afterwards.

Parameters
sourceStoreHolderHolder from the document's XML context, or null.

◆ setThreadingMode()

void donner::svg::DocumentState::setThreadingMode ( ThreadingMode mode)
inline

Set the DOM threading policy.

Parameters
modeNew threading mode.

◆ sourceStoreHolder()

const std::shared_ptr< xml::components::XMLSourceStoreHolder > & donner::svg::DocumentState::sourceStoreHolder ( ) const
inline

The holder of the XML source store of a document built on an XML tree, or null for one built without an XML tree.

The holder's store is null while the document has no source text.

The holder's own home is the registry context, but finding it there reads the context's map, which a thread holding the document's write access, a render worker preparing a frame, can be reshaping at the same moment. This copy lives outside the registry, so a thread that only reads the source can reach the store without document access. It is the holder rather than the store because xml::XMLDocument::setSource replaces the store inside the holder.


The documentation for this class was generated from the following file: