Workspace 6.21.5
Classes | Namespaces | Macros
enumtointadaptor.h File Reference
#include <QtGlobal>
#include "Workspace/Application/LanguageUtils/errorchecks.h"
#include "Workspace/Application/LanguageUtils/typet.h"
#include "Workspace/api_workspace.h"
#include "datafactorytraits.h"
#include "dataobject.h"
#include "typeadaptor.h"
#include "typeadaptorfactory.h"
Include dependency graph for enumtointadaptor.h:
This graph shows which files directly or indirectly include this file:

Classes

class  EnumToIntAdaptor< T >
 A TypeAdaptor class for converting a derived class to a base class. More...
 
class  EnumToIntAdaptorFactory< T >
 A TypeAdaptorFactory class for an adaptor converting an enum to an int. More...
 

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_ENUMTOINTADAPTOR(T, WORKSPACE_EXPORT_SYMBOL)
 
#define DEFINE_WORKSPACE_ENUMTOINTADAPTOR(T, P)
 

Macro Definition Documentation

◆ DECLARE_WORKSPACE_ENUMTOINTADAPTOR

#define DECLARE_WORKSPACE_ENUMTOINTADAPTOR (   T,
  WORKSPACE_EXPORT_SYMBOL 
)
Value:
namespace CSIRO \
{ \
namespace DataExecution \
{ \
template<> \
WORKSPACE_EXPORT_SYMBOL const EnumToIntAdaptorFactory<T>& EnumToIntAdaptorFactory<T>::getInstance(); \
template<> \
WORKSPACE_EXPORT_SYMBOL \
TypeAdaptor* \
EnumToIntAdaptorFactory<T>::create() const; \
template<> \
WORKSPACE_EXPORT_SYMBOL void EnumToIntAdaptorFactory<T>::destroy(TypeAdaptor* a) const; \
template<> \
WORKSPACE_EXPORT_SYMBOL const Application::WorkspacePlugin& EnumToIntAdaptorFactory<T>::getPlugin() const; \
} \
}
void destroy(TypeAdaptor *a) const override
static const EnumToIntAdaptorFactory & getInstance()
const Application::WorkspacePlugin & getPlugin() const override
Top level namespace for all Workspace code.
Definition: applicationsupportplugin.cpp:32

This macro is analogous to the DECLARE_WORKSPACE_DATA_FACTORY macro. See its detailed description for why we also need a similar macro for enum to int type adaptor factories.

◆ DEFINE_WORKSPACE_ENUMTOINTADAPTOR

#define DEFINE_WORKSPACE_ENUMTOINTADAPTOR (   T,
 
)
Value:
namespace CSIRO \
{ \
namespace DataExecution \
{ \
template<> \
CSIRO_EXPORTSPEC \
TypeAdaptor* \
EnumToIntAdaptorFactory<T>::create() const \
{ \
return new EnumToIntAdaptor<T>; \
} \
template<> \
CSIRO_EXPORTSPEC void EnumToIntAdaptorFactory<T>::destroy(TypeAdaptor* adaptor) const \
{ \
delete adaptor; \
} \
template<> \
CSIRO_EXPORTSPEC const EnumToIntAdaptorFactory<T>& EnumToIntAdaptorFactory<T>::getInstance() \
{ \
static EnumToIntAdaptorFactory<T> instance; \
return instance; \
} \
template<> \
CSIRO_EXPORTSPEC const Application::WorkspacePlugin& EnumToIntAdaptorFactory<T>::getPlugin() const \
{ \
return P; \
} \
template class EnumToIntAdaptor<T>; \
} \
}
#define CSIRO_EXPORTSPEC
Definition: api_workspace.h:80
Parameters
TThe enum type being adapted. Compilation will fail if it is not an enum type.
PA reference to the plugin that provides the adaptor. This would normally be the same plugin that provides the data factory for the type T.

A macro for explicitly instantiating an EnumToIntAdaptor and its factory. The use of this macro is the preferred method of instantiating such an adaptor and its factory for a particular type. It should only ever be used in an implementation file and never in a header file. It would normally be used in the file that implements the type T, typically at the end of that file.