Cerata
A library to generate structural hardware designs
|
A pool to share ownership of objects. More...
#include <pool.h>
Public Member Functions | |
void | Add (const std::shared_ptr< T > &object) |
Add an object to the pool, taking shared ownership. Object may not already exist in the pool. | |
std::optional< T * > | Get (const std::string &name) |
Retrieve a component from the pool by name, if it exists. Returns empty option otherwise. | |
void | Clear () |
Release ownership of all components. | |
Protected Attributes | |
std::vector< std::shared_ptr< T > > | objects_ |
A list of objects that this pool owns. | |
A pool to share ownership of objects.
Useful if these objects that are often used (e.g. integer literals), to be able to prevent unnecessary duplicates.