Switchboard SDK
Loading...
Searching...
No Matches
switchboard::ObjectStore< T > Class Template Reference

A simple object store that stores objects by ID. More...

#include <ObjectStore.hpp>

Public Member Functions

void addObject (const std::string &id, const T &object)
 Adds an object to the store.
 
bool deleteObject (const std::string &id)
 Deletes an object from the store.
 
std::vector< std::string > getObjectIds () const
 Gets the IDs of all objects in the store.
 
std::optional< T > getObjectById (const std::string &id) const
 Gets an object by ID.
 
bool contains (const std::string &id) const
 Checks if the store contains an object with the given ID.
 

Detailed Description

template<typename T>
class switchboard::ObjectStore< T >

A simple object store that stores objects by ID.

Member Function Documentation

◆ addObject()

template<typename T>
void switchboard::ObjectStore< T >::addObject ( const std::string & id,
const T & object )
inline

Adds an object to the store.

Parameters
idThe ID of the object.
objectThe object to add.

◆ contains()

template<typename T>
bool switchboard::ObjectStore< T >::contains ( const std::string & id) const
inline

Checks if the store contains an object with the given ID.

Parameters
idThe ID of the object.
Returns
True if the store contains an object with the given ID, false otherwise.

◆ deleteObject()

template<typename T>
bool switchboard::ObjectStore< T >::deleteObject ( const std::string & id)
inline

Deletes an object from the store.

Parameters
idThe ID of the object.
Returns
True if the object was deleted, false otherwise.

◆ getObjectById()

template<typename T>
std::optional< T > switchboard::ObjectStore< T >::getObjectById ( const std::string & id) const
inline

Gets an object by ID.

Parameters
idThe ID of the object.
Returns
The object if found, std::nullopt otherwise.

◆ getObjectIds()

template<typename T>
std::vector< std::string > switchboard::ObjectStore< T >::getObjectIds ( ) const
inline

Gets the IDs of all objects in the store.

Returns
The IDs of all objects in the store.