MUSX Document Model
|
A pool that manages collections of OthersBase
objects, organized by XML node names and Cmper
values.
More...
#include <ObjectPool.h>
Classes | |
struct | ObjectKey |
key type for storing in pool More... | |
Public Types | |
using | ObjectPtr = std::shared_ptr< ObjectBaseType > |
shared pointer to ObjectBaseType | |
Public Member Functions | |
virtual | ~ObjectPool ()=default |
virtual destructor | |
void | add (const ObjectKey &key, ObjectPtr object) |
Adds an OthersBase object to the pool. | |
template<typename T > | |
std::vector< std::shared_ptr< T > > | getArray (const ObjectKey &key) const |
Retrieves a vector of objects of a specific type from the pool. | |
template<typename T > | |
std::vector< std::shared_ptr< T > > | getArrayForPart (const ObjectKey &key) const |
Retrieves a vector of objects of a specific type from the pool. | |
template<typename T > | |
std::shared_ptr< T > | get (const ObjectKey &key) const |
Retrieves the first (and usually only) object of a specific type from the pool. | |
template<typename T > | |
std::shared_ptr< T > | getEffectiveForPart (const ObjectKey &key) const |
Retrieves the first (and usually only) object of a specific type from the pool for a part. | |
A pool that manages collections of OthersBase
objects, organized by XML node names and Cmper
values.
This class provides functionality to store and retrieve objects derived from a Base
object type, It supports dynamic retrieval of objects cast to their specific derived types.
ObjectBaseType | the base type for the objects in the pool |
|
inline |
Adds an OthersBase
object to the pool.
key | The key with which to store the object |
object | A shared pointer to the ObjectBaseType object to add. |
|
inline |
Retrieves the first (and usually only) object of a specific type from the pool.
Many types are scalar values with only one instance per key. Use this function to retrieve them.
T | The derived type of OthersBase to retrieve. Must have a constexpr static std::string_view XmlNodeName member. |
key | The key value used to filter the objects. |
|
inline |
Retrieves a vector of objects of a specific type from the pool.
This function may be used to
T | The derived type of OthersBase to retrieve. |
key | The key value used to filter the objects. |
T
.
|
inline |
Retrieves a vector of objects of a specific type from the pool.
This function may be used to
T | The derived type of OthersBase to retrieve. |
key | The key value used to filter the objects. |
T
.
|
inline |
Retrieves the first (and usually only) object of a specific type from the pool for a part.
If no part item exists, returns the score item.
T | The derived type of OthersBase to retrieve. Must have a constexpr static std::string_view XmlNodeName member. |
key | The key value used to filter the objects. |