XJ music engine  1.9.6
In-game runtime engine for XJ music.
Public Member Functions | Static Public Member Functions | List of all members
XJ::SegmentEntityStore Class Reference

#include <SegmentEntityStore.h>

Public Member Functions

 SEGMENT_STORE_CORE_HEADERS (SegmentMeta, SegmentMetas)
 
 SegmentEntityStore ()=default
 
Chainput (const Chain &c)
 
const Segmentput (const Segment &segment)
 
std::optional< Chain * > readChain ()
 
std::optional< const Segment * > readSegment (int segmentId)
 
std::optional< const Segment * > readSegmentAtChainMicros (const unsigned long long int chainMicros)
 
std::vector< const Segment * > readAllSegments ()
 
std::vector< const Segment * > readAllSegmentsInState (Segment::State segmentState)
 
std::vector< const Segment * > readSegmentsFromToOffset (int fromOffset, int toOffset)
 
std::set< const SegmentEntity * > readAllSegmentEntities (const std::set< int > &segmentIds)
 
std::vector< const Segment * > readAllSegmentsSpanning (const unsigned long long int fromChainMicros, const unsigned long long int toChainMicros)
 
int readLastSegmentId () const
 
std::optional< const Segment * > readSegmentLast ()
 
std::optional< const SegmentChoice * > readChoice (int segmentId, Program::Type programType)
 
std::string readChoiceHash (const Segment &segment)
 
std::set< const SegmentChoiceArrangementPick * > readAllSegmentChoiceArrangementPicks (const std::vector< const Segment * > &forSegments)
 
std::set< const SegmentChoiceArrangementPick * > readAllSegmentChoiceArrangementPicks (const SegmentChoice *segmentChoice)
 
std::vector< const SegmentChord * > readOrderedSegmentChords (int segmentId)
 
int getSegmentCount () const
 
bool empty () const
 
const SegmentupdateSegment (Segment &segment)
 
void deleteChain ()
 
void deleteSegment (int id)
 
void deleteSegmentsBefore (int lastSegmentId)
 
void deleteSegmentsAfter (int lastSegmentId)
 
void clear ()
 

Static Public Member Functions

static void protectSegmentStateTransition (Segment::State fromState, Segment::State toState)
 
static void onlyAllowSegmentStateTransitions (Segment::State toState, const std::set< Segment::State > &allowedStates)
 

Detailed Description

SegmentEntityStore segments and child entities partitioned by segment id for rapid addressing https://github.com/xjmusic/xjmusic/issues/276

XJ Lab Distributed Architecture https://github.com/xjmusic/xjmusic/issues/207 Chains, ChainBindings, TemplateConfigs, Segments and all Segment content sub-entities persisted in JSON:API record stored keyed by chain or segment id in memory

Constructor & Destructor Documentation

◆ SegmentEntityStore()

XJ::SegmentEntityStore::SegmentEntityStore ( )
default

Member Function Documentation

◆ clear()

void SegmentEntityStore::clear ( )

Delete all records in the store (e.g. during integration testing) @ on failure

◆ deleteChain()

void SegmentEntityStore::deleteChain ( )

Read a Chain by #

Returns
requested Chain

◆ deleteSegment()

void SegmentEntityStore::deleteSegment ( int  id)

Read a Segment by #

Returns
requested Segment

◆ deleteSegmentsAfter()

void SegmentEntityStore::deleteSegmentsAfter ( int  lastSegmentId)

Delete all segments after the given segment id

Parameters
lastSegmentIdsegment id

◆ deleteSegmentsBefore()

void SegmentEntityStore::deleteSegmentsBefore ( int  lastSegmentId)

Delete all segments before the given segment id

Parameters
lastSegmentIdsegment id

◆ empty()

bool SegmentEntityStore::empty ( ) const

Whether the segment manager is completely empty

Returns
true if there are zero segments

◆ getSegmentCount()

int SegmentEntityStore::getSegmentCount ( ) const

Get the total number of segments in the store

Returns
number of segments

◆ onlyAllowSegmentStateTransitions()

void SegmentEntityStore::onlyAllowSegmentStateTransitions ( Segment::State  toState,
const std::set< Segment::State > &  allowedStates 
)
static

Require state is in an array of states

Parameters
toStateto check
allowedStatesrequired to be in @ if not in required states

◆ protectSegmentStateTransition()

void SegmentEntityStore::protectSegmentStateTransition ( Segment::State  fromState,
Segment::State  toState 
)
static

Segment state transitions are protected, dependent on the state this segment is being transitioned of, and the intended state it is being transitioned to.

Parameters
fromStateto protect transition of
toStateto test transition to @ on prohibited transition

◆ put() [1/2]

Chain * SegmentEntityStore::put ( const Chain c)

Put the Chain in the entity store

Returns
stored Chain

◆ put() [2/2]

const Segment * SegmentEntityStore::put ( const Segment segment)

Put a Segment in the entity store

Returns
stored Segment

◆ readAllSegmentChoiceArrangementPicks() [1/2]

std::set< const SegmentChoiceArrangementPick * > SegmentEntityStore::readAllSegmentChoiceArrangementPicks ( const SegmentChoice segmentChoice)

Read all arrangement picks for the given segment choice

Parameters
segmentChoice
Returns

◆ readAllSegmentChoiceArrangementPicks() [2/2]

std::set< const SegmentChoiceArrangementPick * > SegmentEntityStore::readAllSegmentChoiceArrangementPicks ( const std::vector< const Segment * > &  forSegments)

Read all choices for the set of segments

Parameters
forSegmentsof segments
Returns
list of choices

◆ readAllSegmentEntities()

std::set< const SegmentEntity * > SegmentEntityStore::readAllSegmentEntities ( const std::set< int > &  segmentIds)

Read all sub-entities records for many parent segments by id

Parameters
segmentIdsfor which to read records.
Returns
collection of all sub entities of these parent segments, different classes that extend EntityUtils

◆ readAllSegments()

std::vector< const Segment * > SegmentEntityStore::readAllSegments ( )

Get all segments for a chain id

Returns
collection of segments @ on failure to retrieve the requested key

◆ readAllSegmentsInState()

std::vector< const Segment * > SegmentEntityStore::readAllSegmentsInState ( Segment::State  segmentState)

Get all segments for a chain id in a given state

Parameters
segmentStateto filter by
Returns
collection of segments
Exceptions
exceptionon failure to retrieve the requested key

◆ readAllSegmentsSpanning()

std::vector< const Segment * > SegmentEntityStore::readAllSegmentsSpanning ( const unsigned long long int  fromChainMicros,
const unsigned long long int  toChainMicros 
)

Get the segments that span the given instant

Parameters
fromChainMicrosfor which to get segments
toChainMicrosfor which to get segments
Returns
segments that span the given instant, empty if none found

◆ readChain()

std::optional< Chain * > SegmentEntityStore::readChain ( )

Read a Chain by #

Returns
requested Chain

◆ readChoice()

std::optional< const SegmentChoice * > SegmentEntityStore::readChoice ( int  segmentId,
Program::Type  programType 
)

Read a choice for a given segment id and program type

Parameters
segmentIdfor which to get choice
programTypeto get
Returns
main choice

◆ readChoiceHash()

std::string SegmentEntityStore::readChoiceHash ( const Segment segment)

Get a hash of all the choices for the given segment

Parameters
segmentfor which to get the choice hash
Returns
hash of all the ids of the choices for the given segment

◆ readLastSegmentId()

int SegmentEntityStore::readLastSegmentId ( ) const

Get the last known segment id

Returns
last segment id

◆ readOrderedSegmentChords()

std::vector< const SegmentChord * > SegmentEntityStore::readOrderedSegmentChords ( int  segmentId)

Read all segment chords in order of position for the given segmefnt

Parameters
segmentIdfor which to get chords
Returns
chords

◆ readSegment()

std::optional< const Segment * > SegmentEntityStore::readSegment ( int  segmentId)

Read a Segment by #

Returns
requested Segment

◆ readSegmentAtChainMicros()

std::optional< const Segment * > SegmentEntityStore::readSegmentAtChainMicros ( const unsigned long long int  chainMicros)

Get the segment at the given chain microseconds, if it is ready segment beginning <= chain microseconds <= end

Note this algorithm intends to get the latter segment when the lookup point is on the line between two segments

Parameters
chainMicrosthe chain microseconds for which to get the segment
Returns
the segment at the given chain microseconds, or an empty optional if the segment is not ready

◆ readSegmentLast()

std::optional< const Segment * > SegmentEntityStore::readSegmentLast ( )

Read the last segment in a Chain, Segments sorted by offset ascending

Returns
Last Segment in Chain

◆ readSegmentsFromToOffset()

std::vector< const Segment * > SegmentEntityStore::readSegmentsFromToOffset ( int  fromOffset,
int  toOffset 
)

Read all Segments that are accessible, by Chain ID, starting and ending at particular offsets

Parameters
fromOffsetto read segments form
toOffsetto read segments to
Returns
list of segments as JSON

◆ SEGMENT_STORE_CORE_HEADERS()

XJ::SegmentEntityStore::SEGMENT_STORE_CORE_HEADERS ( SegmentMeta  ,
SegmentMetas   
)

◆ updateSegment()

const Segment * SegmentEntityStore::updateSegment ( Segment segment)

Update a specified EntityUtils

Parameters
segmentfor the updated EntityUtils. @ on failure

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