![]() |
ImFusion SDK 4.3
|
Extends ImFusion::Data with custom information in a type-safe fashion. More...
Collaboration diagram for DataComponent API:Extends ImFusion::Data with custom information in a type-safe fashion.
In order to support generic data-specific information (metadata) in a type-safe fashion, the ImFusion library provides the DataComponent API. Data and StreamData are the two main classes that hold a DataComponentList, allowing custom information (for example optional data or configuration settings) to be attached to instances of these classes. DataComponents are meant to be used for information that is bound to a specific Data instance and that can not be represented by the usual ImFusion data types. When implementing DataComponents, you should not implement any heavy evaluation logic. This is the domain of Algorithms or other classes accessing DataComponents.
DataComponents are stored in DataComponentLists. They are identified by their C++ type, which makes them a type-safe alternative to Properties.
Examples of DataComponent uses in the main ImFusion library include:
You are encouraged to use DataComponents to enrich your data with custom information that would not easily be covered by other ImFusion types. They provide an orthogonal approach to subclassing (classic "composition vs. inheritance" trade-off in software engineering). When the use case consists of storing information while providing little to no functionality, DataComponents should be considered the more lightweight option.
The DataComponentBase interface consists of 6 pure virtual functions that need to be implemented:
clone(), assign(), and equals() are required so that DataComponents can be stored in a DataComponentList and copied/assigned/compared between multiple data sets.id(), configure(), and configuration() are required to make DataComponents serializable, so that they can be saved to/restored from workspace or ImFusion files for instance.Since the manual implementation of this interface is cumbersome and often repetetive, we provide the following specializations:
Although technically possible, DataComponent inheritance (as in, subclassing a subclass of one of the base DataComponent types) is no longer supported. If you need to create multiple DataComponent types with overlapping members, consider making use of composition instead.
Since DataComponents inherit from the Configurable interface, they come with the serialization functionality included. In order for a DataComponent to be persistent, it must:
configure() and configuration() methods;DataComponent::id() method, returning a unique string identifier for your type (to avoid conflicts, make sure to include potential plugin names into this ID);If a DataComponent implements these three methods and is registered, it will be save to and restored from both ImFusion files and Workspace files. Other, non-serializable DataComponents should instead inherit from TemporaryDataComponent.
Classes | |
| class | DataComponentBase |
| Data components provide a way to generically attach custom information objects. More... | |
| class | DataComponent< T > |
| Main specialization of DataComponentBase for regular types. More... | |
| class | TemporaryDataComponent |
| Specialization of DataComponentBase that disables serialization, copying and assignment. More... | |
| class | DataComponentFactory |
| Factory singleton for creating DataComponents from string IDs. More... | |
| class | DataComponentList |
| Class for holding a collection of DataComponents. More... | |
| class | DataComponentWithParentInterface |
| Interface to augment a DataComponent with a parent of type Data. More... | |
| class | ElementwiseDataComponentData |
| Class for augmenting Data classes with an ElementwiseDataComponentList. More... | |
| class | ElementwiseDataComponentList |
| Class for managing multiple DataComponentLists for individual elements. More... | |
| class | LazyInstantiatedDataComponent< ComponentType, DataType > |
| Extended interface for DataComponents that support lazy instantiation / lazy retrieval. More... | |