OOF2: The Manual
Name
ElementData — Additional data that can be assigned to an Element
Synopses
C++ Synopsis
#include "engine/element.h"
class ElementData {ElementData(const std::string& name);virtual const std::string& classname() = 0;const std::string& name() const;
}
Description
ElementData is an abstract base class
for data that can be stored in an Element. A Property or
other OOF2 extension can define a subclass of
ElementData, and use it to store and
retrieve arbitrary data from an Element. The data object is
given a name in its constructor argument and can be retrieved
by passing that name to Element::getDataByName.
Names must be unique, but uniqueness is not checked.
Derived classes must redefine
classname, which is used when
converting a C++ pointer to a Python object. See PythonExportable.
ElementData::name() returns the name assigned to
an ElementData object in its
constructor.
Other than name and
classname, all of the functionality
of an ElementData must be provided by
the derived class.
![]() |
Note |
|---|---|
|
This class is not quite complete in OOF2 2.4.0. In
particular, if an instance of a subclass of
|
For more infomation on using
ElementData, see
Element::appendData— add anElementDataobject.Element::setDataByName— add or replace anElementDataobject with the given name.Element::setData— replace data at a given index.Element::getData— retrieve data at a given index.Element::getDataByName— retrieve data with a given name.Element::getIndexByName— retrieve the index of the data with the given name.Element::delData— delete the data with the given index.Element::delDataByName— delete the data with the given name.
While the Element methods for handling
ElementData objects are available in
Python, and ElementData subclasses can
be defined in Python, currently the OOF2 infrastructure does not
handle reference counting correctly for them. It's safer to define,
construct, use, and delete ElementData
objects only in C++. If it's necessary to use a Python
subclass of ElementData, make sure to
retain a reference to all instances of it in Python.


![[Note]](IMAGES/note.png)

