About
With the MAXON API ALIASES, every class or structure can be registered as a data type. Objects of such a data type can be stored in a maxon::Data container or can be shared as published objects.
Declaration and Registration
A data type is declared in a header file using the attribute MAXON_DATATYPE :
class IntegerTriplet
{
public :
IntegerTriplet() : _a(1), _b(1), _c(1) {}
{
}
};
MAXON_DATATYPE (IntegerTriplet,
"net.maxonexample.datatype.integertriplet" );
Additionally, the data type must also be registered in a source code file using one of these macros:
Usage
An instance of a class registered as a MAXON API ALIASES data type can be stored in a maxon::Data container:
IntegerTriplet triplet;
triplet._a = 1;
triplet._b = 4;
triplet._c = 9;
The data type class can also be identified with a maxon::DataType object. This maxon::DataType can be obtained with maxon::GetDataType() .
Functions
A custom data type class may define and implement these utility functions. These functions may be called by other parts of the MAXON API ALIASES when using an instance of the data type:
Note To add generic functions see also Classes and Functions .
To copy internal data of a data type one has multiple options:
implementing a copy constructor and operator.
implementing a CopyFrom()
function. This is recommended when copying can fail.
class AdvancedIntegerTriplet
{
public :
AdvancedIntegerTriplet()
{
_a = 1;
_b = 1;
_c = 1;
};
AdvancedIntegerTriplet(AdvancedIntegerTriplet&&
src ) =
default ;
{
}
{
if (_a != other._a)
return false ;
if (_b != other._b)
return false ;
if (_c != other._c)
return false ;
return true ;
}
{
}
{
}
{
}
{
return SIZEOF (AdvancedIntegerTriplet);
}
};
MAXON_DATATYPE (AdvancedIntegerTriplet,
"net.maxonexample.datatype.advancedintegertriplet" );
AdvancedIntegerTriplet triplet;
triplet._a = 100;
triplet._b = 200;
triplet._c = 300;
const AdvancedIntegerTriplet newTriplet;
maxon::Id fileID(
"net.maxonexample.triplet" );
maxon::DataFormatWriterRef outputStream = maxon::DataFormatWriterFactories::Binary().Create(url)
iferr_return ;
AdvancedIntegerTriplet loadedTriplet;
maxon::DataFormatReaderRef inputStream = maxon::DataFormatReaderFactories::Binary().Create(url)
iferr_return ;
Further Reading
Definition: dataserialize.h:205
Result< void > DescribeIO(const T &s, const DataSerializeInterface &dsi)
Definition: datatypefunctions.h:21
#define Describe(name, memberName, type, flags)
Definition: dataserialize.h:293
MAXON_ATTRIBUTE_FORCE_INLINE void UpdateInt(Int i)
Definition: crc32c.h:543
Definition: datatypebase.h:735
Result< void > Init(const DataType &type)
Definition: datatypebase.h:1165
Definition: string.h:1213
Definition: datatypebase.h:1147
Definition: datatypebase.h:1985
return OK
Definition: apibase.h:2546
static const ValueType NONE
Default.
Definition: dataserialize.h:136
ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
Definition: basearray.h:1077
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:179
#define PrepareDescribe(streamClass, className)
Definition: dataserialize.h:267
Definition: apibaseid.h:250
#define iferr_return
Definition: resultbase.h:1465
Definition: datatypebase.h:1734
Result< typename std::conditional< GetCollectionKind< T >::value==COLLECTION_KIND::ARRAY, T, typename ByValueParam< T >::type >::type > Get() const
Definition: datatypebase.h:1356
maxon::String ToString(const Filename &val, const maxon::FormatStatement *formatStatement, maxon::Bool checkDatatype=false)
Result< void > Set(T &&data)
Definition: datatypebase.h:1345
Definition: basearray.h:366
HashInt GetHashCode() const
Definition: collection.h:885
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:167
UInt32 GetCrc() const
Definition: crc32c.h:66
#define MAXON_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: classhelpers.h:293
const T & src
Definition: apibase.h:2539
MAXON_ATTRIBUTE_FORCE_INLINE ResultRef< T > Append()
Definition: basearray.h:569
#define SIZEOF(x)
Calculates the size of a datatype or element.
Definition: apibasemath.h:205
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:186
#define iferr_scope
Definition: resultbase.h:1374
#define MAXON_OPERATOR_MOVE_ASSIGNMENT(TypeName)
Definition: classhelpers.h:322
MAXON_DATATYPE(GeData, "net.maxon.data.gedata")
#define FormatString(...)
Definition: string.h:2052
#define MAXON_DATATYPE_REGISTER_STRUCT(type,...)
Definition: datatype.h:399
UInt64 UInt
unsigned 32/64 bit int, size depends on the platform
Definition: apibase.h:187
Bool operator==(const BaseTime &t1, const BaseTime &t2)
Definition: c4d_basetime.h:254
Int GetMemorySize() const
Definition: basearray.h:1318