Skip to main content

DataManager

DataManager

#include <DataManager.hpp>

Public Types

Name
using std::function< void(TableEvent const &)> TableObserver
using std::function< void()> ObserverCallback

Public Functions

Name
DataManager()
~DataManager()
TableRegistry * getTableRegistry()
Get the centralized TableRegistry owned by this DataManager.
TableRegistry const * getTableRegistry() const
int addTableObserver(TableObserver callback)
Subscribe to table events.
bool removeTableObserver(int callback_id)
Unsubscribe from table events.
bool setTime(TimeKey const & key, std::shared_ptr< TimeFrame > timeframe, bool overwrite =false)
Register a new temporal coordinate system with a unique key.
std::shared_ptr< TimeFrame > getTime()
Get the default time frame object.
std::shared_ptr< TimeFrame > getTime(TimeKey const & key)
Get the time frame object for a specific key.
bool removeTime(TimeKey const & key)
bool setTimeKey(std::string const & data_key, TimeKey const & time_key)
Set the time key for a specific data key.
TimeKey getTimeKey(std::string const & data_key)
Get the time key for a specific data key.
std::vector< TimeKey > getTimeFrameKeys()
Get all registered TimeFrame keys.
void reset()
Clear all data and reset DataManager to initial state.
int addCallbackToData(std::string const & key, ObserverCallback callback)
Add a callback function to a specific data object.
bool removeCallbackFromData(std::string const & key, int callback_id)
Remove a callback from a specific data object.
int addObserver(ObserverCallback callback, std::string name =“Anonymous”)
Register a callback function for DataManager state changes.
void removeObserver(int callback_id)
std::vector< std::string > getAllKeys() const
template <typename T >
std::vector< std::string >
getKeys() const
std::optional< DataTypeVariant > getDataVariant(std::string const & key)
Get data as a variant type.
template <typename T >
std::shared_ptr< T >
getData(std::string const & key)
template <typename T >
void
setData(std::string const & key, TimeKey const & time_key)
void setData(std::string const & key, DataTypeVariant data, TimeKey const & time_key)
template <typename T >
void
setData(std::string const & key, std::shared_ptr< T > data, TimeKey const & time_key)
bool deleteData(std::string const & key)
Delete data associated with the specified key.
DM_DataType getType(std::string const & key) const
void setOutputPath(std::string const & output_path)
std::string const & getOutputPath() const
void notifyTableObservers(TableEvent const & ev)
EntityId ensureTimeEntityId(TimeKey const & time_key, TimeFrameIndex index)
Register (or retrieve) an EntityId for a specific time point on a clock.
std::vector< EntityId > ensureTimeEntityIds(TimeKey const & time_key, TimeFrameIndex start, TimeFrameIndex end)
Batch-register EntityIds for a contiguous range of time points [start, end].
std::optional< std::pair< TimeKey, TimeFrameIndex > > resolveTimeEntity(EntityId id) const
Resolve a TimeEntity’s EntityId back to its (TimeKey, TimeFrameIndex).
std::vector< TimeFrameIndex > getTimeIndicesInGroup(GroupId group_id, TimeKey const & time_key) const
Get all TimeFrameIndex values in a group for a specific clock.
std::vector< TimeFrameIndex > getTimeIndicesInGroupConverted(GroupId group_id, TimeKey const & target_key) const
Get all TimeFrameIndex values in a group, converted to a target clock.
EntityRegistry * getEntityRegistry() const
Access the session-scoped EntityRegistry.
EntityGroupManager * getEntityGroupManager() const
Access the session-scoped EntityGroupManager.
Neuralyzer::Entity::Lineage::LineageRegistry * getLineageRegistry() const
Access the session-scoped LineageRegistry.

Public Types Documentation

using TableObserver

using DataManager::TableObserver =  std::function<void(TableEvent const &)>;

using ObserverCallback

using DataManager::ObserverCallback =  std::function<void()>;

Public Functions Documentation

function DataManager

DataManager()

function ~DataManager

~DataManager()

function getTableRegistry

TableRegistry * getTableRegistry()

Get the centralized TableRegistry owned by this DataManager.

function getTableRegistry

TableRegistry const * getTableRegistry() const

function addTableObserver

int addTableObserver(
    TableObserver callback
)

Subscribe to table events.

Return: Subscription id (>=1) or -1 on failure

function removeTableObserver

bool removeTableObserver(
    int callback_id
)

Unsubscribe from table events.

function setTime

bool setTime(
    TimeKey const & key,
    std::shared_ptr< TimeFrame > timeframe,
    bool overwrite =false
)

Register a new temporal coordinate system with a unique key.

Parameters:

Return: bool True if the TimeFrame was successfully registered, false otherwise

Note: If the key already exists or timeframe is nullptr, a warning message will be printed to std::cerr and the function will return false

This function stores a TimeFrame object in the DataManager under the provided key. The TimeFrame specifies the temporal coordinate system that can be assigned to data objects.

function getTime

std::shared_ptr< TimeFrame > getTime()

Get the default time frame object.

Return: A shared pointer to the default TimeFrame object

Note: This function always returns a valid pointer since the default TimeFrame is created in the constructor

Returns the TimeFrame associated with the default “time” key.

function getTime

std::shared_ptr< TimeFrame > getTime(
    TimeKey const & key
)

Get the time frame object for a specific key.

Parameters:

Return: A shared pointer to the TimeFrame if the key exists, nullptr otherwise

function removeTime

bool removeTime(
    TimeKey const & key
)

function setTimeKey

bool setTimeKey(
    std::string const & data_key,
    TimeKey const & time_key
)

Set the time key for a specific data key.

Parameters:

  • data_key The data key to set the time key for
  • time_key The time key to associate with the data

Return: bool True if the time frame was successfully set, false otherwise

Note: If data_key or time_key doesn’t exist, an error message will be printed to std::cerr and the function will return false

Associates a data object with a specific temporal coordinate system.

function getTimeKey

TimeKey getTimeKey(
    std::string const & data_key
)

Get the time key for a specific data key.

Parameters:

  • data_key The data key to get the time frame for

Return: The TimeKey, or empty string if an error occurred

Note: If data_key doesn’t exist or doesn’t have an associated TimeFrame, an error message will be printed to std::cerr and an empty string will be returned

Retrieves the TimeFrame key associated with a particular data object.

function getTimeFrameKeys

std::vector< TimeKey > getTimeFrameKeys()

Get all registered TimeFrame keys.

Return: A vector of strings containing all TimeFrame keys

Note: The default “time” key will always be included in the returned vector

Retrieves a vector of all keys used for TimeFrame objects in the DataManager.

function reset

void reset()

Clear all data and reset DataManager to initial state.

Note: The default “time” TimeFrame and “media” data key are preserved but reset to empty state

This function removes all loaded data objects, TimeFrame objects (except the default “time” frame), and clears all mappings between data keys and time frame keys. This is useful for batch processing where you want to load different datasets with the same configuration.

The function will:

  • Remove all data objects from _data
  • Remove all TimeFrame objects except the default “time” frame
  • Clear all data-to-timeframe mappings
  • Remove all TimeFrameV2 objects and mappings
  • Reset media data to default empty state
  • Notify observers of the state change

function addCallbackToData

int addCallbackToData(
    std::string const & key,
    ObserverCallback callback
)

Add a callback function to a specific data object.

Parameters:

  • key The data key to attach the callback to
  • callback The function to call when the data changes

Return: int A unique identifier for the callback (>= 0) or -1 if registration failed

Note: If the data key doesn’t exist, the function returns -1

Registers a callback function that will be invoked when the specified data object changes.

function removeCallbackFromData

bool removeCallbackFromData(
    std::string const & key,
    int callback_id
)

Remove a callback from a specific data object.

Parameters:

  • key The data key from which to remove the callback
  • callback_id The unique identifier of the callback to remove

Return: bool True if the callback was successfully removed, false if the key doesn’t exist

Note: If the data key doesn’t exist, the function returns false. The underlying removeObserver implementation determines what happens if the callback_id is invalid.

Removes a previously registered callback using its unique identifier.

function addObserver

int addObserver(
    ObserverCallback callback,
    std::string name ="Anonymous"
)

Register a callback function for DataManager state changes.

Parameters:

  • callback The function to call when the DataManager state changes
  • name The name of the observer. This is used for debugging and logging.

Return: int A unique identifier for the observer registration. Use this ID to remove the observer later via removeObserver().

Adds a callback function that will be invoked when the DataManager’s state changes, such as when data is added or modified.

function removeObserver

void removeObserver(
    int callback_id
)

function getAllKeys

std::vector< std::string > getAllKeys() const

function getKeys

template <typename T >
inline std::vector< std::string > getKeys() const

function getDataVariant

std::optional< DataTypeVariant > getDataVariant(
    std::string const & key
)

Get data as a variant type.

Parameters:

  • key The key associated with the data to retrieve

Return: An optional containing the data variant if the key exists, empty optional otherwise

Retrieves data associated with the specified key as a variant wrapper, allowing access without knowing the concrete type at compile time.

function getData

template <typename T >
inline std::shared_ptr< T > getData(
    std::string const & key
)

function setData

template <typename T >
inline void setData(
    std::string const & key,
    TimeKey const & time_key
)

function setData

void setData(
    std::string const & key,
    DataTypeVariant data,
    TimeKey const & time_key
)

function setData

template <typename T >
inline void setData(
    std::string const & key,
    std::shared_ptr< T > data,
    TimeKey const & time_key
)

function deleteData

bool deleteData(
    std::string const & key
)

Delete data associated with the specified key.

Parameters:

  • key The key of the data to delete

Return: bool True if the data was successfully deleted, false if the key doesn’t exist

Note: This method will:

  • Remove the data from the internal storage
  • Remove the time frame mapping for this data
  • Notify all observers of the change
  • The shared_ptr will be automatically cleaned up when no other references exist

Removes the data object and its associated time frame mapping from the DataManager. All observers are notified of the change, allowing dependent widgets to clean up.

function getType

DM_DataType getType(
    std::string const & key
) const

function setOutputPath

inline void setOutputPath(
    std::string const & output_path
)

function getOutputPath

inline std::string const & getOutputPath() const

function notifyTableObservers

void notifyTableObservers(
    TableEvent const & ev
)

function ensureTimeEntityId

EntityId ensureTimeEntityId(
    TimeKey const & time_key,
    TimeFrameIndex index
)

Register (or retrieve) an EntityId for a specific time point on a clock.

Parameters:

Return: The EntityId for this time point

Uses the TimeKey string as the entity’s data_key and EntityKind::TimeEntity. The local_index is always 0 since a TimeFrameIndex uniquely identifies a time point within a clock.

function ensureTimeEntityIds

std::vector< EntityId > ensureTimeEntityIds(
    TimeKey const & time_key,
    TimeFrameIndex start,
    TimeFrameIndex end
)

Batch-register EntityIds for a contiguous range of time points [start, end].

Parameters:

Return: Vector of EntityIds, one per index in [start, end]

Inclusive on both ends. Iterates the range and calls ensureTimeEntityId for each.

function resolveTimeEntity

std::optional< std::pair< TimeKey, TimeFrameIndex > > resolveTimeEntity(
    EntityId id
) const

Resolve a TimeEntity’s EntityId back to its (TimeKey, TimeFrameIndex).

Parameters:

Return: A pair of (TimeKey, TimeFrameIndex) if the entity is a TimeEntity, std::nullopt otherwise (including if the id is not registered)

function getTimeIndicesInGroup

std::vector< TimeFrameIndex > getTimeIndicesInGroup(
    GroupId group_id,
    TimeKey const & time_key
) const

Get all TimeFrameIndex values in a group for a specific clock.

Parameters:

  • group_id The group to query
  • time_key The clock to filter by

Return: Vector of TimeFrameIndex values (unordered), empty if group doesn’t exist

Iterates the group’s entities, filters to TimeEntity entries whose data_key matches the given TimeKey, and returns their TimeFrameIndex values. Non-TimeEntity members and TimeEntities from other clocks are skipped.

function getTimeIndicesInGroupConverted

std::vector< TimeFrameIndex > getTimeIndicesInGroupConverted(
    GroupId group_id,
    TimeKey const & target_key
) const

Get all TimeFrameIndex values in a group, converted to a target clock.

Parameters:

  • group_id The group to query
  • target_key The target clock to convert indices into

Return: Vector of converted TimeFrameIndex values (unordered), empty if group doesn’t exist or target TimeFrame is not registered

For each TimeEntity in the group (regardless of its source clock), converts its index to the target clock using convert_time_index(). TimeEntities already on the target clock are included without conversion. Non-TimeEntity members are skipped. Requires that both the source and target TimeFrames are registered.

function getEntityRegistry

inline EntityRegistry * getEntityRegistry() const

Access the session-scoped EntityRegistry.

function getEntityGroupManager

inline EntityGroupManager * getEntityGroupManager() const

Access the session-scoped EntityGroupManager.

function getLineageRegistry

inline Neuralyzer::Entity::Lineage::LineageRegistry * getLineageRegistry() const

Access the session-scoped LineageRegistry.

The LineageRegistry tracks relationships between derived data containers and their source containers, enabling entity propagation.


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