Workspace 6.21.5
Public Types | Public Member Functions | List of all members
CloneDataType< T > Struct Template Reference

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

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

Public Types

enum  { Supported = 1 }
 

Public Member Functions

T * clone (const T &t)
 

Detailed Description

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

If T does not support cloning, then in the same header that defines T, specialize this class template as follows:

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

If T supports cloning but its copy constructor does not create an 'independent' instance (eg. uses shared data that isn't copy-on-write), then specialize this class template in the header containing the DECLARE_WORKSPACE_DATA_FACTORY for T to explicitly do a deep copy.

namespace CSIRO
{
namespace DataExecution
{
template<> struct CloneDataType<MyClass>
{
enum { Supported = 1 };
T* clone(const T& t)
{
return t.deepClone();
}
};
}}

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

See also
AssignDataType, SerializeDataType

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Supported 

Member Function Documentation

◆ clone()

T * clone ( const T &  t)
inline