Class BaseContainer#
Defined in File BaseContainer.h
Class Documentation#
-
class BaseContainer#
Container class that holds all the Base objects.
The BaseContainer provides named storage and access to Base objects using unique IDs. It supports range-based iteration and is designed to allow insertion and erasure by friend class Base.
Public Types
-
using iterator = std::map<id_t, class Base*>::iterator#
Iterator type for non-const forward iteration.
-
using const_iterator = std::map<id_t, class Base*>::const_iterator#
Iterator type for const forward iteration.
Public Functions
-
BaseContainer(std::string_view name)#
Constructs a BaseContainer with the given name.
- Parameters:
name – The name of the container.
-
~BaseContainer()#
Destroys the BaseContainer.
This also calls the at_exit_fns CallbackRegistry in reverse order.
-
std::string_view name() const#
Gets the name of the container.
- Returns:
A const reference to the container’s name.
-
bool contains(id_t id) const#
Checks whether the container has an entry with the given ID.
- Parameters:
id – The ID to check for.
- Returns:
True if the ID is present; otherwise, false.
-
const_iterator begin() const#
Returns a const iterator to the beginning.
- Returns:
Const iterator to the beginning.
-
const_iterator end() const#
Returns a const iterator to the end.
- Returns:
Const iterator to the end.
-
const_iterator cbegin() const#
Returns a const iterator to the beginning.
- Returns:
Const iterator to the beginning.
-
const_iterator cend() const#
Returns a const iterator to the end.
- Returns:
Const iterator to the end.
-
reverse_iterator rbegin()#
Returns a reverse iterator to the beginning.
- Returns:
Reverse iterator to the beginning.
-
reverse_iterator rend()#
Returns a reverse iterator to the end.
- Returns:
Reverse iterator to the end.
-
const_reverse_iterator rbegin() const#
Returns a const reverse iterator to the beginning.
- Returns:
Const reverse iterator to the beginning.
-
const_reverse_iterator rend() const#
Returns a const reverse iterator to the end.
- Returns:
Const reverse iterator to the end.
-
const_reverse_iterator crbegin() const#
Returns a const reverse iterator to the beginning.
- Returns:
Const reverse iterator to the beginning.
-
const_reverse_iterator crend() const#
Returns a const reverse iterator to the end.
- Returns:
Const reverse iterator to the end.
Public Members
-
CallbackRegistry<void> at_exit_fns#
Callback registry that is executed in reverse when the BaseContainer is destroyed. This can be used to cleanup simulations.
-
bool check_all_destroyed = true#
Used to enable/disable allDestroyed check at cleanup.
Public Static Functions
-
static ks_ptr<BaseContainer> create(std::string_view name)#
Creates a new BaseContainer with the given name.
- Parameters:
name – The name of the container.
- Returns:
A shared pointer to the created BaseContainer.
-
static void discard(ks_ptr<BaseContainer> &bc)#
Destroys the given BaseContainer.
- Parameters:
bc – A shared pointer to the BaseContainer to be discarded.
-
static const ks_ptr<BaseContainer> singleton()#
Gets the singleton BaseContainer instance.
- Returns:
A shared pointer to the singleton BaseContainer.
Protected Static Functions
-
static void _atExit()#
This is the master at_exit method that calls the registries of all the BaseContainers at exit if they still exist.
This exists on the BaseContainer under protected so that we may hoist it up to public in pybind11, so this can be called if the sim is running from Python.
-
using iterator = std::map<id_t, class Base*>::iterator#