A class template that store a list of elements that can be accessed by their names and serialized.
More...
|
| SerializableWithNameList (const SerializableWithNameList< T > &) |
|
SerializableWithNameList< T > & | operator= (const SerializableWithNameList< T > &rhs) |
|
T & | Insert (const T &element, size_t position=(size_t) -1) |
| Insert the specified element to the list. More...
|
|
void | Insert (const SerializableWithNameList< T > &otherEvents, size_t begin, size_t end, size_t position=(size_t) -1) |
| Copy elements from another list.
|
|
T & | InsertNew (const gd::String &name, size_t position=(size_t) -1) |
| Insert a new element (constructed from its default constructor) with the given name. More...
|
|
size_t | GetCount () const |
| Return the number of elements.
|
|
T & | Get (const gd::String &name) |
| Return a reference to the element with the specified name.
|
|
const T & | Get (const gd::String &name) const |
| Return a reference to the element with the specified name.
|
|
T & | Get (size_t index) |
| Return a reference to the element at position index in the elements list.
|
|
const T & | Get (size_t index) const |
| Return a reference to the element at position index in the elements list.
|
|
void | Remove (const gd::String &name) |
| Remove the element with the specified name, destroying it.
|
|
void | Remove (size_t index) |
| Remove the element at the specified index in the list, destroying it.
|
|
bool | IsEmpty () const |
| Return true if there isn't any element in the list.
|
|
void | Clear () |
| Clear the list of elements, destroying all of them.
|
|
void | Move (std::size_t oldIndex, std::size_t newIndex) |
| Move element at position oldIndex to position newIndex . More...
|
|
bool | Has (const gd::String &name) const |
| Return true if an element with the specified name exists.
|
|
std::size_t | GetPosition (const T &element) const |
| Get the position of an element in the list.
|
|
|
These functions ensure that the class can be used just like a std::vector for iterations.
|
size_t | size () const |
| Alias for GetCount() More...
|
|
bool | empty () const |
| Alias for IsEmpty() More...
|
|
T & | operator[] (size_t index) |
| Alias for Get() More...
|
|
const T & | operator[] (size_t index) const |
| Alias for Get() More...
|
|
T & | at (size_t index) |
| Alias for Get() More...
|
|
const T & | at (size_t index) const |
| Alias for Get() More...
|
|
|
const std::vector< std::unique_ptr< T > > & | GetInternalVector () const |
| Provide a raw access to the vector containing the elements.
|
|
std::vector< std::unique_ptr< T > > & | GetInternalVector () |
| Provide a raw access to the vector containing the elements.
|
|
|
void | SerializeElementsTo (const gd::String &elementName, SerializerElement &element) const |
|
void | UnserializeElementsFrom (const gd::String &elementName, gd::Project &project, const SerializerElement &element) |
|
void | UnserializeElementsFrom (const gd::String &elementName, const SerializerElement &element) |
|
void | ProgressivelyUnserializeElementsFrom (const gd::String &elementName, gd::Project &project, const SerializerElement &element) |
|
template<typename T>
class gd::SerializableWithNameList< T >
A class template that store a list of elements that can be accessed by their names and serialized.
The type T is supposed to have a method GetName
, returning the gd::String
representing the name of the object, and SerializeTo/UnserializeFrom.
- Note
- Invariant: each element in the list has a unique name.
-
Invalidation: Elements can be re-ordered without invalidating them. Insertion/removal does not invalidate other elements. Remove/Clear delete elements from memory.