|
| SerializableObjectList () noexcept |
|
| SerializableObjectList (const SerializableObjectList< T, P, OnEditedArgs... > &other) noexcept |
|
| SerializableObjectList (SerializableObjectList< T, P, OnEditedArgs... > &&other) noexcept |
|
| SerializableObjectList (std::initializer_list< std::shared_ptr< T > > elements) noexcept |
|
| SerializableObjectList (const SExpression &node) |
|
virtual | ~SerializableObjectList () noexcept |
|
bool | isEmpty () const noexcept |
|
int | count () const noexcept |
|
const QVector< std::shared_ptr< T > > & | values () noexcept |
|
std::vector< Uuid > | getUuids () const noexcept |
|
QSet< Uuid > | getUuidSet () const noexcept |
|
int | indexOf (const T *obj) const noexcept |
|
int | indexOf (const Uuid &key) const noexcept |
|
int | indexOf (const QString &name, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept |
|
bool | contains (int index) const noexcept |
|
bool | contains (const T *obj) const noexcept |
|
bool | contains (const Uuid &key) const noexcept |
|
bool | contains (const QString &name) const noexcept |
|
std::shared_ptr< T > | value (int index) noexcept |
|
std::shared_ptr< const T > | value (int index) const noexcept |
|
std::shared_ptr< T > | find (const T *obj) noexcept |
|
std::shared_ptr< T > | find (const Uuid &key) noexcept |
|
std::shared_ptr< const T > | find (const Uuid &key) const noexcept |
|
std::shared_ptr< T > | find (const QString &name, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept |
|
std::shared_ptr< const T > | find (const QString &name, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept |
|
std::shared_ptr< const T > | at (int index) const noexcept |
|
std::shared_ptr< T > & | first () noexcept |
|
std::shared_ptr< const T > | first () const noexcept |
|
std::shared_ptr< T > & | last () noexcept |
|
std::shared_ptr< const T > | last () const noexcept |
|
std::shared_ptr< T > | get (const T *obj) |
|
std::shared_ptr< T > | get (const Uuid &key) |
|
std::shared_ptr< const T > | get (const Uuid &key) const |
|
std::shared_ptr< T > | get (const QString &name) |
|
std::shared_ptr< const T > | get (const QString &name) const |
|
const_iterator | begin () const noexcept |
|
const_iterator | end () const noexcept |
|
const_iterator | cbegin () noexcept |
|
const_iterator | cend () noexcept |
|
iterator | begin () noexcept |
|
iterator | end () noexcept |
|
int | loadFromSExpression (const SExpression &node) |
|
void | swap (int i, int j) noexcept |
|
int | insert (int index, const std::shared_ptr< T > &obj) noexcept |
|
int | append (const std::shared_ptr< T > &obj) noexcept |
|
void | append (SerializableObjectList &list) noexcept |
|
std::shared_ptr< T > | take (int index) noexcept |
|
std::shared_ptr< T > | take (const T *obj) noexcept |
|
std::shared_ptr< T > | take (const Uuid &uuid) noexcept |
|
std::shared_ptr< T > | take (const QString &name) noexcept |
|
void | remove (int index) noexcept |
|
void | remove (const T *obj) noexcept |
|
void | remove (const Uuid &uuid) noexcept |
|
void | remove (const QString &name) noexcept |
|
void | clear () noexcept |
|
void | serialize (SExpression &root) const |
| Serialize into librepcb::SExpression node. More...
|
|
template<typename Compare > |
SerializableObjectList< T, P, OnEditedArgs... > | sorted (Compare lessThan) const noexcept |
|
SerializableObjectList< T, P, OnEditedArgs... > | sortedByUuid () const noexcept |
|
std::shared_ptr< T > | operator[] (int i) noexcept |
|
std::shared_ptr< const T > | operator[] (int i) const noexcept |
|
bool | operator== (const SerializableObjectList< T, P, OnEditedArgs... > &rhs) const noexcept |
|
bool | operator!= (const SerializableObjectList< T, P, OnEditedArgs... > &rhs) const noexcept |
|
SerializableObjectList< T, P, OnEditedArgs... > & | operator= (const SerializableObjectList< T, P, OnEditedArgs... > &rhs) noexcept |
|
SerializableObjectList< T, P, OnEditedArgs... > & | operator= (SerializableObjectList< T, P, OnEditedArgs... > &&rhs) noexcept |
|
template<typename T, typename P, typename... OnEditedArgs>
class librepcb::SerializableObjectList< T, P, OnEditedArgs >
The SerializableObjectList class implements a list of serializable objects.
This template class lets you hold a list of serializable objects and provides some useful features:
- Template Parameters
-
T | The type of the list items. The type must provide following functionality:
- Optional: A nothrow copy constructor (to make the list copyable). For polymorphic objects, implement a method
std::shared_ptr<T> cloneShared() const noexcept
- Optional: A constructor with one parameter of type
const SExpression&
- Optional: A method
void serialize(SExpression&) const
- Optional: Comparison operator overloadings
- Optional: A method
Uuid getUuid() const noexcept
- Optional: A method
QString getName() const noexcept
|
P | A class which provides the S-Expression node tag name of the list items. Example: struct MyNameProvider {static constexpr const char* tagname = "item";}; |
- Note
- Instead of directly storing elements of type
T
, elements are always wrapped into a std::shared_ptr<T>
before adding them to the list. This is done to ensure that elements never have to be copied or moved for adding or removing them to/from the list. Otherwise it would not be possible to use this list in undo commands as references/pointers to elements would become invalid. Using pointers ensures that the objects are located at the same address over the whole lifetime. To still minimize the risk of memory leaks, std::shared_ptr
is used instead of raw pointers.
- Warning
- Using Qt's
foreach
keyword on a librepcb::SerializableObjectList is not recommended because it always creates a deep copy of the list! You should use range based for loops (since C++11) instead.