Workspace 6.21.5
Public Types | List of all members
CompareDataType< T > Struct Template Reference

Traits class defining whether a class T supports comparison. More...

#include <Workspace/DataExecution/DataObjects/datafactorytraits.h>

Inheritance diagram for CompareDataType< T >:
[legend]

Public Types

enum  { Supported = Application::HasOperatorEqual<T>::value }
 

Additional Inherited Members

- Public Member Functions inherited from CompareDataTypeImpl< T, Application::HasOperatorEqual< T >::value >
bool compare (const T &lhs, const T &rhs)
 

Detailed Description

template<typename T>
struct CSIRO::DataExecution::CompareDataType< T >

By default, Supported will be specified as true (1) or false (0) based on whether the operator== is defined. To force no comparison supported, then in the same header that defines T, specialize this class template as follows:

namespace CSIRO
{
namespace DataExecution
{
template<> struct CompareDataType<MyClass>
{
enum { Supported = 0 };
};
}}
Top level namespace for all Workspace code.
Definition: applicationsupportplugin.cpp:32
Traits class defining whether a class T supports comparison.
Definition: datafactorytraits.h:511

If T supports comparison but it does not use the default comparison operator, then specialize this class template in the header containing the DECLARE_WORKSPACE_DATA_FACTORY for T to explicitly perform a comparison.

namespace CSIRO
{
namespace DataExecution
{
template<> struct CompareDataType<MyClass>
{
enum { Supported = 1 };
bool compare(const T& a, const T& b)
{
return customComparisonFunction(a, b);
}
};
}}

By doing this, the compareDataObjects() function in TypedDataFactory will also automatically be given an appropriate function body without any further changes.

See also
AssignDataType, SerializeDataType, CloneDataType

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Supported