Skip to main content

DigitalIntervalStorageBase

DigitalIntervalStorageBase

CRTP base class for digital interval storage implementations. More…

#include <DigitalIntervalStorageBase.hpp>

Public Functions

Name
size_t size() const
Get total number of intervals.
bool empty() const
Check if storage is empty.
TimeFrameInterval const & getInterval(size_t idx) const
Get the interval at a flat index.
EntityId getEntityId(size_t idx) const
Get the EntityId at a flat index.
std::optional< size_t > findByInterval(TimeFrameInterval const & interval) const
Find the index of an interval by its exact start/end times.
std::optional< size_t > findByEntityId(EntityId id) const
Find the index of an interval by its EntityId.
bool hasIntervalAtTime(TimeFrameIndex time) const
Check if any interval contains the specified time.
std::pair< size_t, size_t > getOverlappingRange(TimeFrameIndex start, TimeFrameIndex end) const
Get range of indices for intervals overlapping [start, end].
std::pair< size_t, size_t > getContainedRange(TimeFrameIndex start, TimeFrameIndex end) const
Get range of indices for intervals fully contained in [start, end].
DigitalIntervalStorageType getStorageType() const
Get the storage type identifier.
bool isView() const
Check if this is a view (doesn’t own data).
bool isLazy() const
Check if this is lazy storage.
DigitalIntervalStorageCache tryGetCache() const
Try to get cached pointers for fast-path access.

Protected Functions

Name
~DigitalIntervalStorageBase() =default

Detailed Description

template <typename Derived >
class DigitalIntervalStorageBase;

CRTP base class for digital interval storage implementations.

Template Parameters:

  • Derived The concrete storage implementation type

Uses Curiously Recurring Template Pattern to eliminate virtual function overhead while maintaining a polymorphic interface. Intervals are stored as Interval values (representing start/end times) with associated EntityIds.

The SoA (Structure of Arrays) layout stores parallel vectors:

  • Interval intervals[] - sorted by start time
  • EntityId entity_ids[] - corresponding entity identifiers

Public Functions Documentation

function size

inline size_t size() const

Get total number of intervals.

function empty

inline bool empty() const

Check if storage is empty.

function getInterval

inline TimeFrameInterval const & getInterval(
    size_t idx
) const

Get the interval at a flat index.

Parameters:

  • idx Flat index in [0, size())

function getEntityId

inline EntityId getEntityId(
    size_t idx
) const

Get the EntityId at a flat index.

Parameters:

  • idx Flat index in [0, size())

function findByInterval

inline std::optional< size_t > findByInterval(
    TimeFrameInterval const & interval
) const

Find the index of an interval by its exact start/end times.

Parameters:

Return: Index of the interval, or std::nullopt if not found

function findByEntityId

inline std::optional< size_t > findByEntityId(
    EntityId id
) const

Find the index of an interval by its EntityId.

Parameters:

Return: Index of the interval, or std::nullopt if not found

function hasIntervalAtTime

inline bool hasIntervalAtTime(
    TimeFrameIndex time
) const

Check if any interval contains the specified time.

Parameters:

  • time The time to check

Return: true if any interval contains the time

function getOverlappingRange

inline std::pair< size_t, size_t > getOverlappingRange(
    TimeFrameIndex start,
    TimeFrameIndex end
) const

Get range of indices for intervals overlapping [start, end].

Parameters:

  • start Start time (inclusive)
  • end End time (inclusive)

Return: Pair of (start_idx, end_idx) where end is exclusive

Note: Returns intervals where interval.start <= end && interval.end >= start. Implementation strategy depends on storage backend; see OwningDigitalIntervalStorage::getOverlappingRangeImpl(), ViewDigitalIntervalStorage::getOverlappingRangeImpl(), and LazyDigitalIntervalStorage::getOverlappingRangeImpl().

function getContainedRange

inline std::pair< size_t, size_t > getContainedRange(
    TimeFrameIndex start,
    TimeFrameIndex end
) const

Get range of indices for intervals fully contained in [start, end].

Parameters:

  • start Start time (inclusive)
  • end End time (inclusive)

Return: Pair of (start_idx, end_idx) where end is exclusive

Note: Returns intervals where interval.start >= start && interval.end <= end

function getStorageType

inline DigitalIntervalStorageType getStorageType() const

Get the storage type identifier.

function isView

inline bool isView() const

Check if this is a view (doesn’t own data).

function isLazy

inline bool isLazy() const

Check if this is lazy storage.

function tryGetCache

inline DigitalIntervalStorageCache tryGetCache() const

Try to get cached pointers for fast-path access.

Return: DigitalIntervalStorageCache with valid pointers if contiguous, invalid otherwise

Protected Functions Documentation

function ~DigitalIntervalStorageBase

~DigitalIntervalStorageBase() =default

Updated on 2026-11-13 at 20:25:41 +0000