RaggedAnalogTimeSeries
RaggedAnalogTimeSeries
Ragged analog time series data structure. More…
#include <RaggedAnalogTimeSeries.hpp>
Inherits from ObserverData
Public Classes
| Name | |
|---|---|
| struct | DataTraits Type traits for RaggedAnalogTimeSeries. |
| struct | TimeValueEntry Entry structure for iteration. |
| struct | FlatElement Entry structure for flat element iteration. |
| class | Iterator Iterator for range-based iteration over time-value pairs. |
Public Functions
| Name | |
|---|---|
| RaggedAnalogTimeSeries() =default | |
| virtual | ~RaggedAnalogTimeSeries() =default |
| template <std::ranges::input_range R> |
RaggedAnalogTimeSeries(R && time_value_pairs) |
| RaggedAnalogTimeSeries(RaggedAnalogTimeSeries const & ) =delete | |
| RaggedAnalogTimeSeries & | operator=(RaggedAnalogTimeSeries const & ) =delete |
| RaggedAnalogTimeSeries(RaggedAnalogTimeSeries && ) =default | |
| RaggedAnalogTimeSeries & | operator=(RaggedAnalogTimeSeries && ) =default |
| std::shared_ptr< RaggedAnalogTimeSeries > | materialize() const Materialize lazy storage into owning storage. |
| bool | isLazy() const Check if this series uses lazy storage. |
| bool | isView() const Check if this series uses view storage. |
| void | setTimeFrame(std::shared_ptr< TimeFrame > time_frame) Set the time frame for this data structure. |
| std::shared_ptr< TimeFrame > | getTimeFrame() const Get the current time frame. |
| std::span< float const > | getDataAtTime(TimeFrameIndex time) const Get the data at a specific time. |
| std::span< float const > | getDataAtTime(TimeIndexAndFrame const & time_index_and_frame) const Get the data at a specific time with timeframe conversion. |
| std::vector< float > | getValuesAtTimeVec(TimeFrameIndex time) const Get the data at a specific time as a vector (works with lazy storage). |
| bool | hasDataAtTime(TimeFrameIndex time) const Check if data exists at a specific time. |
| size_t | getCountAtTime(TimeFrameIndex time) const Get the number of values at a specific time. |
| std::vector< TimeFrameIndex > | getTimeIndices() const Get all time indices that have data. |
| size_t | getNumTimePoints() const Get the total number of time points with data. |
| size_t | getTotalValueCount() const Get total number of float values across all times. |
| void | setDataAtTime(TimeFrameIndex time, std::vector< float > const & data, NotifyObservers notify) Add or replace data at a specific time (by copying). |
| void | setDataAtTime(TimeFrameIndex time, std::vector< float > && data, NotifyObservers notify) Add or replace data at a specific time (by moving). |
| void | setDataAtTime(TimeIndexAndFrame const & time_index_and_frame, std::vector< float > const & data, NotifyObservers notify) Add or replace data at a specific time with timeframe conversion (by copying). |
| void | setDataAtTime(TimeIndexAndFrame const & time_index_and_frame, std::vector< float > && data, NotifyObservers notify) Add or replace data at a specific time with timeframe conversion (by moving). |
| void | appendAtTime(TimeFrameIndex time, std::vector< float > const & data, NotifyObservers notify) Append values to existing data at a specific time (by copying). |
| void | appendAtTime(TimeFrameIndex time, std::vector< float > && data, NotifyObservers notify) Append values to existing data at a specific time (by moving). |
| bool | clearAtTime(TimeFrameIndex time, NotifyObservers notify) Clear data at a specific time. |
| bool | clearAtTime(TimeIndexAndFrame const & time_index_and_frame, NotifyObservers notify) Clear data at a specific time with timeframe conversion. |
| void | clearAll(NotifyObservers notify) Clear all data from the time series. |
| Iterator | begin() const Get iterator to the beginning of the time series. |
| Iterator | end() const Get iterator to the end of the time series. |
| auto | view() const Get a view over the entire time series. |
| auto | elements() const Get a flattened view of (TimeFrameIndex, float) pairs. |
| auto | elementsView() const Get a flattened view of FlatElement objects (concept-compliant). |
| auto | time_slices() const Get a view of (TimeFrameIndex, std::span |
| RaggedAnalogStorageCache | getStorageCache() const Get storage cache for fast-path iteration. |
| template <std::ranges::random_access_range ViewType> std::shared_ptr< RaggedAnalogTimeSeries > |
createFromView(ViewType view, std::shared_ptr< TimeFrame > time_frame) |
Additional inherited members
Public Classes inherited from ObserverData
| Name | |
|---|---|
| struct | ObserverEntry Entry in the observer map. |
Public Types inherited from ObserverData
| Name | |
|---|---|
| using std::function< void()> | ObserverCallback Type alias for observer callback functions. |
| using int | CallbackID Type alias for callback identifiers. |
Public Functions inherited from ObserverData
| Name | |
|---|---|
| ObserverData(std::string name =“UnnamedObservable”) | |
| CallbackID | addObserver(ObserverCallback callback, std::string name =“Anonymous”) Register a new observer callback. |
| void | notifyObservers() Notify all registered observers. |
| void | removeObserver(CallbackID id) Remove a previously registered observer. |
Detailed Description
class RaggedAnalogTimeSeries;Ragged analog time series data structure.
RaggedAnalogTimeSeries stores time series data where each TimeFrameIndex can have a variable-length vector of float values. Unlike regular AnalogTimeSeries, the number of samples at each time point need not be constant.
This class manages:
- Time series storage via type-erased storage wrapper (supports owning, view, and lazy)
- TimeFrame association for time-based operations
- Observer pattern integration for data change notifications
- Range-based iteration interface
- Cache optimization for fast-path iteration over contiguous storage
Storage Backends:
- OwningRaggedAnalogStorage: Default, owns data in SoA layout
- ViewRaggedAnalogStorage: Zero-copy filtered view of another storage
- LazyRaggedAnalogStorage: On-demand computation from a transform view
Use cases include:
- Spike trains with varying numbers of detected events per time bin
- Multi-unit recordings where channel count varies over time
- Feature vectors with time-varying dimensionality
Public Functions Documentation
function RaggedAnalogTimeSeries
RaggedAnalogTimeSeries() =defaultfunction ~RaggedAnalogTimeSeries
virtual ~RaggedAnalogTimeSeries() =defaultfunction RaggedAnalogTimeSeries
template <std::ranges::input_range R>
inline explicit RaggedAnalogTimeSeries(
R && time_value_pairs
)function RaggedAnalogTimeSeries
RaggedAnalogTimeSeries(
RaggedAnalogTimeSeries const &
) =deletefunction operator=
RaggedAnalogTimeSeries & operator=(
RaggedAnalogTimeSeries const &
) =deletefunction RaggedAnalogTimeSeries
RaggedAnalogTimeSeries(
RaggedAnalogTimeSeries &&
) =defaultfunction operator=
RaggedAnalogTimeSeries & operator=(
RaggedAnalogTimeSeries &&
) =defaultfunction materialize
inline std::shared_ptr< RaggedAnalogTimeSeries > materialize() constMaterialize lazy storage into owning storage.
Return: New RaggedAnalogTimeSeries with owning storage
If this series has lazy storage, creates a new series with all values computed and stored in owning storage. Useful when:
- The source data for a lazy view is about to be destroyed
- Random access patterns would cause repeated computation
- The data needs to be saved to disk
function isLazy
inline bool isLazy() constCheck if this series uses lazy storage.
Return: true if underlying storage is LazyRaggedAnalogStorage
function isView
inline bool isView() constCheck if this series uses view storage.
Return: true if underlying storage is ViewRaggedAnalogStorage
function setTimeFrame
void setTimeFrame(
std::shared_ptr< TimeFrame > time_frame
)Set the time frame for this data structure.
Parameters:
- time_frame Shared pointer to the TimeFrame to associate with this data
function getTimeFrame
std::shared_ptr< TimeFrame > getTimeFrame() constGet the current time frame.
Return: Shared pointer to the associated TimeFrame, or nullptr if none is set
function getDataAtTime
std::span< float const > getDataAtTime(
TimeFrameIndex time
) constGet the data at a specific time.
Parameters:
- time The time to query
Return: std::span
Returns a span view over the float vector at the specified time. For lazy storage, this may return empty span; use getValuesAtTimeVec() instead.
function getDataAtTime
std::span< float const > getDataAtTime(
TimeIndexAndFrame const & time_index_and_frame
) constGet the data at a specific time with timeframe conversion.
Parameters:
- time_index_and_frame The time and timeframe to query
Return: std::span
function getValuesAtTimeVec
std::vector< float > getValuesAtTimeVec(
TimeFrameIndex time
) constGet the data at a specific time as a vector (works with lazy storage).
Parameters:
- time The time to query
Return: Vector of float values at the time, empty if no data exists
This method always works, including for lazy storage where getDataAtTime() might return empty span.
function hasDataAtTime
bool hasDataAtTime(
TimeFrameIndex time
) constCheck if data exists at a specific time.
Parameters:
- time The time to check
Return: true if data exists at the given time, false otherwise
function getCountAtTime
size_t getCountAtTime(
TimeFrameIndex time
) constGet the number of values at a specific time.
Parameters:
- time The time to query
Return: The number of float values at the given time, or 0 if no data exists
function getTimeIndices
std::vector< TimeFrameIndex > getTimeIndices() constGet all time indices that have data.
Return: Vector of TimeFrameIndex values where data exists
function getNumTimePoints
size_t getNumTimePoints() constGet the total number of time points with data.
Return: The number of time indices that have data
function getTotalValueCount
inline size_t getTotalValueCount() constGet total number of float values across all times.
Return: Total element count
function setDataAtTime
void setDataAtTime(
TimeFrameIndex time,
std::vector< float > const & data,
NotifyObservers notify
)Add or replace data at a specific time (by copying).
Parameters:
- time The time to add the data at
- data The vector of float values to add (will be copied)
- notify Whether to notify observers after the operation
If data already exists at the given time, it will be replaced.
function setDataAtTime
void setDataAtTime(
TimeFrameIndex time,
std::vector< float > && data,
NotifyObservers notify
)Add or replace data at a specific time (by moving).
Parameters:
- time The time to add the data at
- data The vector of float values to add (will be moved)
- notify Whether to notify observers after the operation
If data already exists at the given time, it will be replaced.
function setDataAtTime
void setDataAtTime(
TimeIndexAndFrame const & time_index_and_frame,
std::vector< float > const & data,
NotifyObservers notify
)Add or replace data at a specific time with timeframe conversion (by copying).
Parameters:
- time_index_and_frame The time and timeframe to add at
- data The vector of float values to add (will be copied)
- notify Whether to notify observers after the operation
function setDataAtTime
void setDataAtTime(
TimeIndexAndFrame const & time_index_and_frame,
std::vector< float > && data,
NotifyObservers notify
)Add or replace data at a specific time with timeframe conversion (by moving).
Parameters:
- time_index_and_frame The time and timeframe to add at
- data The vector of float values to add (will be moved)
- notify Whether to notify observers after the operation
function appendAtTime
void appendAtTime(
TimeFrameIndex time,
std::vector< float > const & data,
NotifyObservers notify
)Append values to existing data at a specific time (by copying).
Parameters:
- time The time to append data at
- data The vector of float values to append (will be copied)
- notify Whether to notify observers after the operation
If no data exists at the given time, creates a new entry.
function appendAtTime
void appendAtTime(
TimeFrameIndex time,
std::vector< float > && data,
NotifyObservers notify
)Append values to existing data at a specific time (by moving).
Parameters:
- time The time to append data at
- data The vector of float values to append (will be moved)
- notify Whether to notify observers after the operation
If no data exists at the given time, creates a new entry.
function clearAtTime
bool clearAtTime(
TimeFrameIndex time,
NotifyObservers notify
)Clear data at a specific time.
Parameters:
- time The time to clear
- notify Whether to notify observers after the operation
Return: true if data was found and cleared, false otherwise
function clearAtTime
bool clearAtTime(
TimeIndexAndFrame const & time_index_and_frame,
NotifyObservers notify
)Clear data at a specific time with timeframe conversion.
Parameters:
- time_index_and_frame The time and timeframe to clear at
- notify Whether to notify observers after the operation
Return: true if data was found and cleared, false otherwise
function clearAll
void clearAll(
NotifyObservers notify
)Clear all data from the time series.
Parameters:
- notify Whether to notify observers after the operation
function begin
inline Iterator begin() constGet iterator to the beginning of the time series.
function end
inline Iterator end() constGet iterator to the end of the time series.
function view
inline auto view() constGet a view over the entire time series.
Returns a view compatible with std::ranges that can be used with range-based for loops and range algorithms.
function elements
inline auto elements() constGet a flattened view of (TimeFrameIndex, float) pairs.
See: elementsView() for concept-compliant iteration with FlatElement
Return: A lazy range view of (TimeFrameIndex, float) pairs
This creates a lazy view that flattens the ragged structure into individual (time, value) pairs. This is the analog of RaggedTimeSeries
Returns std::pair<[TimeFrameIndex](/api_generated/Classes/structTimeFrameIndex.md), float> for backward compatibility with existing code that uses .first, .second, and structured bindings.
Usage: for (auto [time, value] : ragged_analog.elements()) { ... }
function elementsView
inline auto elementsView() constGet a flattened view of FlatElement objects (concept-compliant).
See:
- FlatElement
- TimeSeriesConcepts.hpp for concept definitions
Return: A lazy range view of FlatElement objects
This creates a lazy view that flattens the ragged structure into individual FlatElement objects. Each element satisfies the TimeSeriesElement and ValueElement
Use this method when you need concept-compliant elements for generic algorithms. Use elements() when you need backward-compatible pair iteration.
Usage: ```cpp
for (auto elem : ragged_analog.elementsView()) { auto t = elem.time(); auto v = elem.value(); }
### function time_slices
```cpp
inline auto time_slices() const
Get a view of (TimeFrameIndex, std::span
Return: A lazy range view of (TimeFrameIndex, span) pairs
Similar to RaggedTimeSeries
Note: For lazy storage, the spans may be empty. Use time_slices_vec() instead if you need guaranteed access.
Usage: for (auto [time, values_span] : ragged_analog.time_slices()) { … }
function getStorageCache
inline RaggedAnalogStorageCache getStorageCache() constGet storage cache for fast-path iteration.
Returns cached pointers if storage is contiguous, otherwise invalid cache.
function createFromView
template <std::ranges::random_access_range ViewType>
static inline std::shared_ptr< RaggedAnalogTimeSeries > createFromView(
ViewType view,
std::shared_ptr< TimeFrame > time_frame
)Updated on 2026-11-13 at 20:25:40 +0000