The SavepointVector manages the registered savepoints and their mapping to the stored fields. More...
#include <SavepointVector.h>
Public Types | |
| using | savepoint_vector_type = std::vector< std::shared_ptr< SavepointImpl > > |
| Vector of savepoints. | |
| using | fields_per_savepoint_type = std::unordered_map< std::string, unsigned int > |
| Map of fields per savepoint. | |
| using | fields_per_savepoint_vector_type = std::vector< fields_per_savepoint_type > |
| Vector of map of fields per savepoint. | |
| using | iterator = savepoint_vector_type::iterator |
A random access iterator to std::shared_ptr<Savepoint> | |
| using | const_iterator = savepoint_vector_type::const_iterator |
A random access iterator to const std::shared_ptr<Savepoint> | |
Public Member Functions | |
| SavepointVector () | |
| Default constructor (empty) | |
| SavepointVector (const SavepointVector &)=default | |
| Copy constructor. | |
| SavepointVector (SavepointVector &&)=default | |
| Move constructor. | |
| SavepointVector (const json::json &jsonNode) | |
| Construct from JSON. | |
| SavepointVector & | operator= (const SavepointVector &)=default |
| Copy assignment. | |
| SavepointVector & | operator= (SavepointVector &&)=default |
| Move assignment. | |
| bool | exists (const SavepointImpl &savepoint) const noexcept |
| Check if savepoint exists. More... | |
| int | find (const SavepointImpl &savepoint) const noexcept |
| Find savepoint. More... | |
| int | insert (const SavepointImpl &savepoint) noexcept |
| Insert savepoint in savepoint vector. More... | |
| bool | addField (const SavepointImpl &savepoint, const FieldID &fieldID) noexcept |
| Add a field to the savepoint. More... | |
| bool | addField (int idx, const FieldID &fieldID) noexcept |
Add a field to the savepoint given a valid savepoint index idx More... | |
| bool | hasField (const SavepointImpl &savepoint, const std::string &field) noexcept |
Check if savepoint has field field More... | |
| bool | hasField (int idx, const std::string &field) noexcept |
Check if savepoint has field field given a valid savepoint index idx More... | |
| FieldID | getFieldID (const SavepointImpl &savepoint, const std::string &field) const |
Get the FielID of field field at savepoint savepoint More... | |
| FieldID | getFieldID (int idx, const std::string &field) const |
Get the FielID of field field given a valid savepoint index idx More... | |
| const fields_per_savepoint_type & | fieldsOf (const SavepointImpl &savepoint) const |
| Access fields of savepoint. More... | |
| const fields_per_savepoint_type & | fieldsOf (int idx) const noexcept |
Access fields of savepoint given a valid savepoint index idx | |
| bool | empty () const noexcept |
| Returns a bool value indicating whether the savepoint vector is empty. | |
| std::size_t | size () const noexcept |
| Returns the number of savepoints in the vector. | |
| void | clear () noexcept |
| All the elements Savepoints are dropped: their destructors are called, and they are removed from the container, leaving it with a size of 0. | |
| void | swap (SavepointVector &other) noexcept |
| Swap with other. | |
| iterator | begin () noexcept |
| Returns an iterator pointing to the first savepoint in the vector. | |
| const_iterator | begin () const noexcept |
| iterator | end () noexcept |
| Returns an iterator pointing to the past-the-end savepoint in the vector. | |
| const_iterator | end () const noexcept |
| SavepointImpl & | operator[] (int idx) noexcept |
| Get savepoint. | |
| const SavepointImpl & | operator[] (int idx) const noexcept |
| std::shared_ptr< SavepointImpl > & | back () noexcept |
| Returns a reference to the last element in the savepoint vector. | |
| const std::shared_ptr< SavepointImpl > & | back () const noexcept |
| const savepoint_vector_type & | savepoints () const noexcept |
| Access the savepoints. | |
| savepoint_vector_type & | savepoints () noexcept |
| json::json | toJSON () const |
| Convert to JSON. | |
| void | fromJSON (const json::json &jsonNode) |
| Construct from JSON node. More... | |
Friends | |
| std::ostream & | operator<< (std::ostream &stream, const SavepointVector &s) |
| Convert to stream. | |
The SavepointVector manages the registered savepoints and their mapping to the stored fields.
The savepoints are ordered in the sequence they were registred.
Definition at line 35 of file SavepointVector.h.
|
noexcept |
Add a field to the savepoint.
Definition at line 31 of file SavepointVector.cpp.
|
noexcept |
Add a field to the savepoint given a valid savepoint index idx
Definition at line 38 of file SavepointVector.cpp.
|
noexcept |
Check if savepoint exists.
Definition at line 74 of file SavepointVector.cpp.
| const SavepointVector::fields_per_savepoint_type & serialbox::SavepointVector::fieldsOf | ( | const SavepointImpl & | savepoint | ) | const |
Access fields of savepoint.
| Exception | Savepoint does not exists |
Definition at line 89 of file SavepointVector.cpp.
|
noexcept |
Find savepoint.
savepoint in the savepoint-vector or -1 if savepoint does not exist Definition at line 78 of file SavepointVector.cpp.
| void serialbox::SavepointVector::fromJSON | ( | const json::json & | jsonNode | ) |
Construct from JSON node.
| Exception | JSON node is ill-formed |
Definition at line 125 of file SavepointVector.cpp.
| FieldID serialbox::SavepointVector::getFieldID | ( | const SavepointImpl & | savepoint, |
| const std::string & | field | ||
| ) | const |
Get the FielID of field field at savepoint savepoint
| Exception | Savepoint or field at savepoint do not exist |
Definition at line 60 of file SavepointVector.cpp.
| FieldID serialbox::SavepointVector::getFieldID | ( | int | idx, |
| const std::string & | field | ||
| ) | const |
Get the FielID of field field given a valid savepoint index idx
| Exception | Savepoint or field at savepoint do not exist |
Definition at line 53 of file SavepointVector.cpp.
|
noexcept |
Check if savepoint has field field
field exists at savepoint Definition at line 42 of file SavepointVector.cpp.
|
noexcept |
Check if savepoint has field field given a valid savepoint index idx
field exists at savepoint Definition at line 49 of file SavepointVector.cpp.
|
noexcept |
Insert savepoint in savepoint vector.
Definition at line 21 of file SavepointVector.cpp.