Workspace 7.0.2
Classes | Namespaces | Macros | Functions
datafactorytraits.h File Reference
#include <QByteArray>
#include <QDate>
#include <QDateTime>
#include <QList>
#include <QMap>
#include <QMetaType>
#include <QString>
#include <QStringList>
#include <QTime>
#include <QVector>
#include "Workspace/Application/LanguageUtils/errorchecks.h"
#include "Workspace/Application/LanguageUtils/classconstraints.h"
#include "Workspace/Application/LanguageUtils/typet.h"
#include "Workspace/api_workspace.h"
Include dependency graph for datafactorytraits.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  AssignDataType< T >
 Traits class defining whether a class T supports assignment. More...
 
struct  CloneDataType< T >
 Traits class defining whether a class T supports cloning. More...
 
struct  CompareDataType< T >
 Traits class defining whether a class T supports comparison. More...
 
struct  CompareDataTypeImpl< T, operatorEqualsAvailable >
 
struct  CompareDataTypeImpl< T, false >
 
class  DataFactoryTraits< T >
 Traits class for data objects of type T. More...
 
struct  DeclaredAsWorkspaceDataType< T >
 Traits class defining whether a class T is or isn't a Workspace data type. This will have Is set to 0 unless a DECLARE_WORKSPACE_DATA_TYPE macro has been used to declare the type as a Workspace-compatible type. More...
 
struct  DeclaredAsWorkspaceDataType< bool >
 
struct  DeclaredAsWorkspaceDataType< char >
 
struct  DeclaredAsWorkspaceDataType< double >
 
struct  DeclaredAsWorkspaceDataType< float >
 
struct  DeclaredAsWorkspaceDataType< int >
 
struct  DeclaredAsWorkspaceDataType< long >
 
struct  DeclaredAsWorkspaceDataType< long double >
 
struct  DeclaredAsWorkspaceDataType< QByteArray >
 
struct  DeclaredAsWorkspaceDataType< QDate >
 
struct  DeclaredAsWorkspaceDataType< QDateTime >
 
struct  DeclaredAsWorkspaceDataType< QPointF >
 
struct  DeclaredAsWorkspaceDataType< QQuaternion >
 
struct  DeclaredAsWorkspaceDataType< QStringList >
 
struct  DeclaredAsWorkspaceDataType< QTime >
 
struct  DeclaredAsWorkspaceDataType< QVariant >
 
struct  DeclaredAsWorkspaceDataType< QVector< int > >
 
struct  DeclaredAsWorkspaceDataType< signed char >
 
struct  DeclaredAsWorkspaceDataType< uchar >
 
struct  DeclaredAsWorkspaceDataType< uint >
 
struct  DeclaredAsWorkspaceDataType< ulong >
 
struct  DeclaredAsWorkspaceDataType< ushort >
 
struct  SerializeDataType< T >
 Traits class defining whether detection of serialization support for class T is permitted. More...
 
struct  SortDataType< T >
 Traits class defining whether a class T can be sorted. This is important for some comparison operations. More...
 
struct  SortDataTypeImpl< T, isSortable >
 
struct  SortDataTypeImpl< T, false >
 

Namespaces

namespace  CSIRO
 Top level namespace for all Workspace code.
 
namespace  CSIRO::DataExecution
 Base workspace functionality not requiring a user interface.
 

Macros

#define DECLARE_WORKSPACE_DATA_FACTORY(T, WORKSPACE_EXPORT_SYMBOL)
 
#define DECLARE_WORKSPACE_DATA_FACTORY_COMMON(T, WORKSPACE_EXPORT_SYMBOL)
 
#define DECLARE_WORKSPACE_DATA_FACTORY_NO_QMETATYPE(T, WORKSPACE_EXPORT_SYMBOL)    DECLARE_WORKSPACE_DATA_FACTORY_COMMON(T, WORKSPACE_EXPORT_SYMBOL)
 

Functions

template<typename T >
QMap< int, QString > getEnumMap ()
 
template<typename T >
void getEnumMap (QMap< int, QString > &map)
 
template<typename T >
QStringList getEnumNames ()
 
template<typename T >
void getEnumNames (QStringList &names)
 
template<typename T >
bool isType (const DataFactory &factory)
 
 Q_DECLARE_METATYPE (long double) namespace CSIRO
 
 Q_DECLARE_METATYPE (QList< double >) namespace CSIRO
 
 Q_DECLARE_METATYPE (QList< int >) namespace CSIRO
 
 Q_DECLARE_METATYPE (QVector< bool >) namespace CSIRO
 
 Q_DECLARE_METATYPE (QVector< double >) namespace CSIRO
 
 Q_DECLARE_METATYPE (QVector< int >) namespace CSIRO
 
 Q_DECLARE_METATYPE (QVector< QDateTime >) namespace CSIRO
 
 Q_DECLARE_METATYPE (signed char) namespace CSIRO
 
 Q_DECLARE_METATYPE (wchar_t) namespace CSIRO
 

Macro Definition Documentation

◆ DECLARE_WORKSPACE_DATA_FACTORY

#define DECLARE_WORKSPACE_DATA_FACTORY (   T,
  WORKSPACE_EXPORT_SYMBOL 
)
Value:
DECLARE_WORKSPACE_DATA_FACTORY_COMMON(T, WORKSPACE_EXPORT_SYMBOL) \
Q_DECLARE_METATYPE(T)
#define DECLARE_WORKSPACE_DATA_FACTORY_COMMON(T, WORKSPACE_EXPORT_SYMBOL)
Definition: datafactorytraits.h:681
Parameters
TThe type that the data factory provides. It must be the fully qualified name of the type, ie you must not omit any namespace scoping (or class scoping for nested types defined within classes).
WORKSPACE_EXPORT_SYMBOLA token that controls whether to export or import symbols for this factory.
Note
Do not use this macro if the type T does not support cloning. For such classes, use the DECLARE_WORKSPACE_DATA_FACTORY_NO_QMETATYPE macro instead.

In order to ensure that data factories used across plugins are portable (ie will work on all platforms), there are cases where the code must prevent the compiler from having the chance to inline certain functions. In particular, the TypedObject template cannot know how itself and objects of type T are created and destroyed. In order to do that and still allow TypedObject instances to be instantiated on demand, the TypedDataFactory template implementation must not be visible to TypedObject. The only exception to this is in the one file which instantiates the TypedDataFactory for a given type. Even then, the TypedDataFactory class should not be instantiated directly by client code, but rather the DEFINE_WORKSPACE_DATA_FACTORY or DEFINE_WORKSPACE_DATA_FACTORY_NAMED macros should be used in an implementation file.

It would be tempting to think that this DECLARE_WORKSPACE_DATA_FACTORY macro is not necessary, and instead that the DataFactoryTraits class could be fully defined as an ordinary C++ template class. If this were done, however, the C++ standard then requires (see clause 14.7.1.6) that the function definitions be visible anywhere that they will be implicitly instantiated (ie anywhere they are called and an explicit specialisation has not been provided). But making the function definitions visible is exactly what we are trying to avoid. The way we work around this is to declare (but not define) explicit specializations of the member functions of DataFactoryTraits. This allows us to call the functions but hide their implementations in another file (see the DEFINE_WORKSPACE_DATA_FACTORY_NAMED macro for details). The C++ standard allows this:

"...An implicit instantiation is never generated for an explicit specialization that is declared but not defined." - clause 14.7.3.6

"A template-id that names a class template explicit specialization that has been declared but not defined can be used exactly like the names of other incompletely-defined classes" - clause 14.7.3.10

Data types made available to the workspace with this macro can be exported from the plugin, as controlled by the WORKSPACE_EXPORT_SYMBOL directive. Most platforms and compilers now employ some form of symbol export control where special directives are needed to indicate classes and data to be made visible outside of a DLL or shared library. The interested reader may wish to have a look at the Windows SDK help entries for the __cdecl, dllimport and dllexport directives. There are also some comments and most of what you need already implemented in the file Workspace/api_workspace.h. If you do not want to make the data type publicly available (which should rarely be the case for a workspace data type), pass a symbol which the pre-processor expands to nothing.

See also
DECLARE_WORKSPACE_DATA_FACTORY_NO_QMETATYPE, DEFINE_WORKSPACE_DATA_FACTORY

◆ DECLARE_WORKSPACE_DATA_FACTORY_COMMON

#define DECLARE_WORKSPACE_DATA_FACTORY_COMMON (   T,
  WORKSPACE_EXPORT_SYMBOL 
)

◆ DECLARE_WORKSPACE_DATA_FACTORY_NO_QMETATYPE

#define DECLARE_WORKSPACE_DATA_FACTORY_NO_QMETATYPE (   T,
  WORKSPACE_EXPORT_SYMBOL 
)     DECLARE_WORKSPACE_DATA_FACTORY_COMMON(T, WORKSPACE_EXPORT_SYMBOL)

This macro is similar to DECLARE_WORKSPACE_DATA_FACTORY except that no QMetaType support is added for the type T. This macro must be used if T refers to a type for which Qt already provides QMetaType support (ie built in C++ types and Qt classes). It must also be used if T does not support cloning, since the QMetaType system requires types to be clonable (more correctly, to be copyable).

See also
DECLARE_WORKSPACE_DATA_FACTORY, DEFINE_WORKSPACE_DATA_FACTORY_NO_QMETATYPE

Function Documentation

◆ Q_DECLARE_METATYPE() [1/9]

Q_DECLARE_METATYPE ( long double  )

◆ Q_DECLARE_METATYPE() [2/9]

Q_DECLARE_METATYPE ( QList< double >  )

◆ Q_DECLARE_METATYPE() [3/9]

Q_DECLARE_METATYPE ( QList< int >  )

◆ Q_DECLARE_METATYPE() [4/9]

Q_DECLARE_METATYPE ( QVector< bool >  )

◆ Q_DECLARE_METATYPE() [5/9]

Q_DECLARE_METATYPE ( QVector< double >  )

◆ Q_DECLARE_METATYPE() [6/9]

Q_DECLARE_METATYPE ( QVector< int >  )

◆ Q_DECLARE_METATYPE() [7/9]

Q_DECLARE_METATYPE ( QVector< QDateTime >  )

◆ Q_DECLARE_METATYPE() [8/9]

Q_DECLARE_METATYPE ( signed char  )

◆ Q_DECLARE_METATYPE() [9/9]

Q_DECLARE_METATYPE ( wchar_t  )