Workspace 6.21.5
|
Class for relating a group of DataObject instances together. More...
#include <Workspace/DataExecution/DataObjects/objectgroup.h>
Public Member Functions | |
~ObjectGroup () override | |
bool | add (const QString &name, DataObject &obj) |
bool | canSerialize () const override |
ObjectGroup * | clone () const override=0 |
bool | empty () const |
void | ensureGroupHasData () |
void | erase (int index) |
DataObject * | getChild (const QString &name) |
const DataObject * | getChild (const QString &name) const |
DataObject & | getDataObject (int index) |
const DataObject & | getDataObject (int index) const |
int | getIndex (const QString &name) const |
const QString & | getName (int index) const |
virtual QString | getPreferedWidget (const QString &name) const |
bool | hasData () const |
bool | haveName (const QString &name) const |
bool | insert (const QString &name, DataObject &obj, int index=-1) |
bool | load (const QJsonDocument &doc) |
bool | load (const SerializedItem &item) override |
bool | save (QJsonDocument &doc) const |
bool | save (SerializedItem &item) const override |
unsigned | size () const |
Public Member Functions inherited from Clonable | |
virtual | ~Clonable ()=default |
virtual Clonable * | clone () const =0 |
Public Member Functions inherited from Serialize | |
virtual | ~Serialize ()=default |
virtual bool | canSerialize () const =0 |
virtual bool | load (const SerializedItem &item)=0 |
virtual bool | save (SerializedItem &item) const =0 |
Protected Member Functions | |
ObjectGroup () | |
void | clear () |
ObjectGroup & | operator= (const ObjectGroup &rhs) |
bool | operator== (const ObjectGroup &rhs) const |
void | swap (ObjectGroup &rhs) |
The main purpose of the ObjectGroup class is to automate the serialization of a group of objects (possibly a whole hierarchy of objects). It holds no data of its own, but instead it retrieves what it needs on demand from the subclass via the getObjects() virtual function, which is the only function subclasses need to provide.
The most common way to use the class is to make it a base of a class and add objects using push_back in the subclass' constructor. If an empty object group is needed for some purpose, the ObjectGroup class can be instantiated as is.
|
protected |
Constructs an empty object group.
|
overridedefault |
Cleans up the private implementation.
bool add | ( | const QString & | name, |
DataObject & | obj | ||
) |
name | The name for the object. This must be unique among all the immediate children of this object group and it cannot be changed once the object has been added. |
obj | The object to append into the group. |
This function is entirely equivalent to calling insert() with the optional index parameter omitted.
|
overridevirtual |
Implements Serialize.
|
protected |
Clear the group. This call is not recursive, so any data objects that the group previously contained will be left unmodified.
|
overridepure virtual |
We redeclare this function only so that the more derived return type is available without casting.
Implements Clonable.
Implemented in ColorScale, DimensionInfo, NamedDimensionRange, DiscreteNamedDimensionRangeFilter, NullNamedDimensionRangeFilter, InvalidSqlBoundObjectGroup, TypedSqlBoundObjectGroup< Derived, PrimaryKeyType >, ImageOverlay, AxisSettings, MeshFeatureIdentifier, GeometricPlaneFilter, NullOperationMeshModelFilter, ScalarNodeStateFilter, BoundingBox, BoundingCylinder, BoundingPlane, BoundingSphere, TransformGroup, TruncatedCone, Vector3dGroup, LinuxDesktopIcon, StartMenuItem, PythonObjectGroupBase, PythonObjectGroup< T >, CameraInteractionOptions, LightAttenuationFactors, PlotGrid3dRenderOptions, RenderSettings, SceneOverlay, PickFilter, RenderFilter, AnchorDifference, AttributeDifference, ConnectionDifference, DisplayDifference, ElementDifference, FeatureDifference, InputDifference, ItemDifference, NoteDifference, OperationDifference, OutputDifference, PluginDifference, ViewDifference, ValidationData, DirIteratorFlags, EmptyGroup, FileFilter, FileSortFlags, NamedDimensionRangeFilter, SqlBoundObjectGroup, and MeshModelFilter.
bool empty | ( | ) | const |
void ensureGroupHasData | ( | ) |
Recursively ensures that all children of this group have valid data.
void erase | ( | int | index | ) |
index | The index of the child to remove from the group. |
Erases the child at the specified index.
DataObject * getChild | ( | const QString & | name | ) |
name | The name to look for among the immediate children of the group. |
const DataObject * getChild | ( | const QString & | name | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
DataObject & getDataObject | ( | int | index | ) |
index | The index of the object to retrieve. |
const DataObject & getDataObject | ( | int | index | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
int getIndex | ( | const QString & | name | ) | const |
name | The name to look for among the immediate children of the group. |
const QString & getName | ( | int | index | ) | const |
index | The index of the name to retrieve. |
|
virtual |
bool hasData | ( | ) | const |
return True if all children of this group have valid data.
bool haveName | ( | const QString & | name | ) | const |
name | The name to look for among the immediate children of the group. |
bool insert | ( | const QString & | name, |
DataObject & | obj, | ||
int | index = -1 |
||
) |
name | The name for the object. This must be unique among all the immediate children of this object group and it cannot be changed once the object has been added. |
obj | The object to insert into the group. |
index | The index before which to insert the object. If this is negative, then obj will be appended to the group. |
Object groups can themselves be part of a group, so it is possible to define a whole hierarchy of data object relationships with the ObjectGroup class by passing an ObjectGroup as the obj parameter.
bool load | ( | const QJsonDocument & | doc | ) |
|
overridevirtual |
item | Supplies the state to be loaded into this object group. |
This function will load the state of this object group from item. It will usually be called by an implementation of Serialize::load.
Implements Serialize.
|
protected |
rhs | The other object group being assigned to this one. |
Assigns the matching members of one object group to this object group. Does not add new members to the object group. Note that this operator is only accessible by derived classes who must explicitly invoke it. If your derived class contains members that are not assignable, you will probably want to define your own assignment operator implementation rather than using this one.
|
protected |
rhs | The second operand in the comparison |
bool save | ( | QJsonDocument & | doc | ) | const |
|
overridevirtual |
item | Where to save the state of this object group. |
This function will serialise the object group by saving each object it contains to item.
This function is the reason why the group's children must all have unique tag names. If they didn't, there would be no way to re-load the data we save here into the right children again.
Implements Serialize.
unsigned size | ( | ) | const |
|
protected |
Swaps one object group with another one.