Accelerated Computation Engine
|
#include <ace_metadatamodel_node.h>
Public Member Functions | |
Node (EMetadata::Type type=EMetadata::Null, QObject *parent=nullptr) | |
Node (const EMetadata &meta, QObject *parent=nullptr) | |
Node (const Node &object) | |
bool | isBytes () const |
bool | isEditable () const |
bool | isContainer () const |
bool | isArray () const |
bool | isObject () const |
int | size () const |
MetadataModel::Node * | parent () const |
QString | key () const |
bool | setKey (const QString &newKey) |
QString | type () const |
QByteArray | bytes () const |
EMetadata | meta () const |
QVariant | value () const |
bool | setValue (const QVariant &value) |
QList< MetadataModel::Node * >::const_iterator | arrayBegin () const |
QList< MetadataModel::Node * >::const_iterator | arrayEnd () const |
QMap< QString, MetadataModel::Node * >::const_iterator | objectBegin () const |
QMap< QString, MetadataModel::Node * >::const_iterator | objectEnd () const |
MetadataModel::Node * | get (int index) const |
int | indexOf (const Node *pointer) const |
bool | contains (const QString &key) const |
int | getFutureIndex (const QString &key) const |
std::unique_ptr< MetadataModel::Node > | copy (int index) |
std::unique_ptr< MetadataModel::Node > | cut (int index) |
void | insertArray (int index, std::unique_ptr< Node > &&node) |
void | insertObject (const QString &key, std::unique_ptr< Node > &&node) |
void | remove (int index) |
This class represents a single metadata node within the metadata model. The reason this class must exist as a wrapper around the metadata class is because the model must work with pointers for arrays and objects while the metadata classes do not use pointers. The node can be any possible metadata class. If it is an array or object it uses its own custom qt containers that hold pointers instead of metadata arrays or objects. The nodes are also Qt Objects to allow for easy memory cleanup.
|
explicit |
Constructs a new node object with the given qt object as its parent, if any.
type | The metadata type of this new node. |
parent | The parent of this new node, if any. |
|
explicit |
Constructs a new node object with the given metadata value and the given qt object as its parent, if any. If the metadata given is an array or object then the metadata values contained within are not copied. This is because nodes store their values in an entirely different manner than the metadata class.
meta | The metadata value of this new node. |
parent | The parent of this new node, if any. |
MetadataModel::Node::Node | ( | const Node & | object | ) |
Constructs a new node object as a copy of the given object.
object | The other node object that is copied to this one. |
QList< MetadataModel::Node * >::const_iterator MetadataModel::Node::arrayBegin | ( | ) | const |
Returns first constant iterator to node pointer in this node's internal array of pointers. If this node is not an array type this list will always be empty.
QList< MetadataModel::Node * >::const_iterator MetadataModel::Node::arrayEnd | ( | ) | const |
Returns end of list constant iterator in this node's internal array of pointers. If this node is not an array type this list will always be empty.
QByteArray MetadataModel::Node::bytes | ( | ) | const |
Returns the byte array of this node. If this node is not a bytes type then an empty byte array is returned.
bool MetadataModel::Node::contains | ( | const QString & | key | ) | const |
Tests whether this node's internal mapping of node pointers already contains the given key. If this node is not an object type false is always returned.
key | The given key to be tested if it already exists within this node's mapping. |
std::unique_ptr< MetadataModel::Node > MetadataModel::Node::copy | ( | int | index | ) |
Creates a copy of this node's child at the given index. If the given index does not exist or this node is not a container type then a null pointer is returned.
index | Index of child node that is copied. |
std::unique_ptr< MetadataModel::Node > MetadataModel::Node::cut | ( | int | index | ) |
Cuts this node's child at the given index, returning its pointer and removing it form this node's list of children. If the given index does not exist or this node is not a container type then a null pointer is returned.
index | Index of child node that is cut. |
MetadataModel::Node * MetadataModel::Node::get | ( | int | index | ) | const |
Returns the node pointer contains in this node's internal container, map or array, with the given index. If this node is not a container type or the index is out of range then null is returned.
index | The index of the requested node pointer. |
int MetadataModel::Node::getFutureIndex | ( | const QString & | key | ) | const |
This will return the index a new node would be inserted into this node's internal map with the given key if this is an object type. If this node is not an object then -1 is returned.
key | The given key to test for indexing position within the map. |
int MetadataModel::Node::indexOf | ( | const Node * | pointer | ) | const |
Finds what index the given node pointer exists within this node if at all. If this node is not a container or the pointer is not matched to any of its children then -1 is returned.
pointer | The node pointer that will be matched against any children this node contains. |
void MetadataModel::Node::insertArray | ( | int | index, |
std::unique_ptr< Node > && | node | ||
) |
Inserts a new node with the given pointer into this node's internal array at the given index if this node is an array type. If this node is not an array type this does nothing but free then given node pointer. If the index is less than 0 the new node is prepended to the array. If the index is greater than or equal to its size it is appended to the array.
index | Index where the new node is inserted. |
node | Pointer to the new node that is inserted. |
void MetadataModel::Node::insertObject | ( | const QString & | key, |
std::unique_ptr< Node > && | node | ||
) |
Inserts a new node with the given pointer into this node's internal mapping with the given key. If the key already exists the node pointer is overwritten with the new node pointer, freeing the old node's memory. If this node is not an object type this does nothing but free the given node pointer.
key | The key where the new node that is inserted to in the map. |
node | The pointer to the new node that is inserted into the map. |
bool MetadataModel::Node::isArray | ( | ) | const |
Tests if this node is an array.
bool MetadataModel::Node::isBytes | ( | ) | const |
Tests if this node is a bytes type.
bool MetadataModel::Node::isContainer | ( | ) | const |
Tests if this node is either an array or an object.
bool MetadataModel::Node::isEditable | ( | ) | const |
Tests if this node's metadata is editable as a string.
bool MetadataModel::Node::isObject | ( | ) | const |
Tests of this node is an object.
QString MetadataModel::Node::key | ( | ) | const |
Returns the key or name for this node in relation to its parent. If its parent is an array the index is returned as a string.
EMetadata MetadataModel::Node::meta | ( | ) | const |
This returns the metadata value for this node.
QMap< QString, MetadataModel::Node * >::const_iterator MetadataModel::Node::objectBegin | ( | ) | const |
Returns first constant iterator to node pointer in this node's internal map of pointers. If this node is not an object type this list will always be empty.
QMap< QString, MetadataModel::Node * >::const_iterator MetadataModel::Node::objectEnd | ( | ) | const |
Returns end of list constant iterator in this node's internal mapping of pointers. If this node is not an object type this list will always be empty.
MetadataModel::Node * MetadataModel::Node::parent | ( | ) | const |
Returns this node's parent. If this is the root node then null is returned.
void MetadataModel::Node::remove | ( | int | index | ) |
Removes and deletes this node's child with the given index. This will work if the node is an array or an object type. If this node is not a container type or the index is out of range this does nothing.
index | Index of the child node to be removed and deleted. |
bool MetadataModel::Node::setKey | ( | const QString & | newKey | ) |
This sets the key of this node to a new value. If this node's parent is not an object type or the key already exists then false is returned.
newKey | The new key for this node. |
bool MetadataModel::Node::setValue | ( | const QVariant & | value | ) |
Sets the metadata value of this node if it is not a container type. If it is a container or null type then this will do nothing and return immediately.
value | New value this node's metadata will be set to if it is not a container type. |
int MetadataModel::Node::size | ( | ) | const |
Returns the number of children this node contains. This works for any metadata type. If this node is not a container type then 0 is always returned.
QString MetadataModel::Node::type | ( | ) | const |
Returns the metadata type for this node as a string.
QVariant MetadataModel::Node::value | ( | ) | const |
Returns the metadata value of this node if it is not a container or bytes type. If this node is a container type then a string reporting the number of nodes it holds is returned. If this node is a bytes type then a string informing the user this is an image is returned.