Skip to main content

src/DataObjects/DigitalTimeSeries/storage/DigitalEventStorageCache.hpp

src/DataObjects/DigitalTimeSeries/storage/DigitalEventStorageCache.hpp

Cache and enum types for digital event storage backends.

Classes

Name
struct DigitalEventStorageCache
Cache structure for fast-path access to contiguous digital event storage.

Types

Name
enum class DigitalEventTimeDomain { TimeFrameIndex, RelativeClockTicks}
Time coordinate domain for digital event storage.
enum class DigitalEventStorageType { Owning, View, Lazy, RelativeOwning}
Storage type enumeration for digital event storage.

Types Documentation

enum DigitalEventTimeDomain

Enumerator Value Description
TimeFrameIndex Event times stored as TimeFrameIndex (absolute index space).
RelativeClockTicks Event times stored as relative ClockTicks.

Time coordinate domain for digital event storage.

enum DigitalEventStorageType

Enumerator Value Description
Owning Owns the data in SoA layout.
View References another storage via indices.
Lazy Lazy-evaluated transform.
RelativeOwning Immutable owning storage of relative ClockTicks.

Storage type enumeration for digital event storage.

Source code



#ifndef DIGITAL_EVENT_STORAGE_CACHE_HPP
#define DIGITAL_EVENT_STORAGE_CACHE_HPP

#include "Entity/EntityId.hpp"         // EntityId
#include "TimeFrame/ClockTicks.hpp"    // ClockTicks
#include "TimeFrame/TimeFrameIndex.hpp"// TimeFrameIndex

#include <cassert>
#include <cstddef>

enum class DigitalEventTimeDomain {
    TimeFrameIndex,   
    RelativeClockTicks
};

enum class DigitalEventStorageType {
    Owning,       
    View,         
    Lazy,         
    RelativeOwning
};

// =============================================================================
// Cache Optimization Structure
// =============================================================================

struct DigitalEventStorageCache {
    DigitalEventTimeDomain time_domain = DigitalEventTimeDomain::TimeFrameIndex;
    TimeFrameIndex const * events_ptr = nullptr;
    ClockTicks const * relative_events_ptr = nullptr;
    EntityId const * entity_ids_ptr = nullptr;
    size_t cache_size = 0;
    bool is_contiguous = false;

    [[nodiscard]] constexpr bool isValid() const noexcept {
        return is_contiguous;
    }

    [[nodiscard]] TimeFrameIndex getEvent(size_t idx) const noexcept {
        assert(time_domain == DigitalEventTimeDomain::TimeFrameIndex);
        return events_ptr[idx];
    }

    [[nodiscard]] ClockTicks getRelativeEvent(size_t idx) const noexcept {
        assert(time_domain == DigitalEventTimeDomain::RelativeClockTicks);
        return relative_events_ptr[idx];
    }

    [[nodiscard]] EntityId getEntityId(size_t idx) const noexcept {
        return entity_ids_ptr[idx];
    }
};

#endif// DIGITAL_EVENT_STORAGE_CACHE_HPP

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