![]() |
Workspace 6.21.5
|
A TypeAdaptor class for adapting T to a DataSeries where T is like a std::vector
or QVector
.
More...
#include <DataAnalysis/DataStructures/dataseriesadaptor.h>
Public Member Functions | |
bool | adapt (DataExecution::DataObject &src, DataExecution::DataObject &dest, bool copy) override |
const DataExecution::TypeAdaptorFactory & | getFactory () const override |
![]() | |
~TypeAdaptor () override=default | |
virtual bool | adapt (DataObject &src, DataObject &dest, bool copy)=0 |
bool | canSerialize () const override |
virtual bool | connectConversionAction (QAction &action) |
virtual const TypeAdaptorFactory & | getFactory () const =0 |
bool | load (const SerializedItem &item) override |
bool | save (SerializedItem &item) const override |
![]() | |
virtual | ~Serialize ()=default |
virtual bool | canSerialize () const =0 |
virtual bool | load (const SerializedItem &item)=0 |
virtual bool | save (SerializedItem &item) const =0 |
The type T must provide the following:
bool empty() const
int size() const
double operator[](int) const
The return types of the above can be different as long as they automatically convert to the types shown. Since size() is frequently implemented to return an unsigned rather than an int, there is an explicit static_cast<int>() used on the return value. This is not done for empty() or operator[](int) so that compiler warnings will highlight likely suspect conversions.
Client code should not need to do much with DataSeriesAdaptor directly. Under normal circumstances, it is easier to use the DECLARE_WORKSPACE_DATASERIESADAPTOR and DEFINE_WORKSPACE_DATASERIESADAPTOR macros and then let the workspace itself handle conversion from an array-like type T to a DataSeries subclass that is created automatically by the macros.
Adaptors for QVector<int>
and QVector<double>
are defined already by the DataAnalysis plugin, since these can be used for the vast majority of cases where a DataSeries is used. They are particularly useful when employed within a DataCollection.
|
inlineoverridevirtual |
Performs the conversion between DataObjects.
src | The DataObject that will be converted and stored in dest. |
dest | The destination of the converted DataObject |
copy | Whether a copy should occur regardless of whether or not a copy can be avoided. |
Some adapt() calls will always effectively make a copy, since they create a different data type from the source. Some, however, are able to make the destination data object re-use the source, such as when the destination is a base class of the source' data type.
All TypeAdaptor subclasses are required to override this function and must respect the copy flag.
Implements TypeAdaptor.
|
inlineoverridevirtual |
Implements TypeAdaptor.