About
With the MAXON API, 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");
MAXON_DATATYPE(GeData, "net.maxon.data.gedata")
maxon::String ToString(const Filename &val, const maxon::FormatStatement *formatStatement, maxon::Bool checkDatatype=false)
Definition: string.h:1226
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:190
#define FormatString(...)
Definition: string.h:2082
Additionally, the data type must also be registered in a source code file using one of these macros:
#define MAXON_DATATYPE_REGISTER_STRUCT(type,...)
Definition: datatype.h:405
Usage
An instance of a class registered as a MAXON API data type can be stored in a maxon::Data container:
IntegerTriplet triplet;
triplet._a = 1;
triplet._b = 4;
triplet._c = 9;
Definition: datatypebase.h:1179
Result< void > Set(T &&data)
Definition: datatypebase.h:1373
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
#define iferr_return
Definition: resultbase.h:1465
The data type class can also be identified with a maxon::DataType object. This maxon::DataType can be obtained with maxon::GetDataType().
Result< typename std::conditional< GetCollectionKind< T >::value==COLLECTION_KIND::ARRAY, T, typename ByValueParam< T >::type >::type > Get() const
Definition: datatypebase.h:1384
Result< void > Init(const DataType &type)
Definition: datatypebase.h:1193
Definition: datatypebase.h:754
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 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");
Bool operator==(const BaseTime &t1, const BaseTime &t2)
Definition: c4d_basetime.h:254
UInt32 GetCrc() const
Definition: crc32c.h:66
MAXON_ATTRIBUTE_FORCE_INLINE void UpdateInt(Int i)
Definition: crc32c.h:543
static const ValueType NONE
Default.
Definition: dataserialize.h:136
Definition: dataserialize.h:206
#define Describe(name, memberName, type, flags)
Definition: dataserialize.h:293
#define PrepareDescribe(streamClass, className)
Definition: dataserialize.h:267
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:183
UInt64 UInt
unsigned 32/64 bit int, size depends on the platform
Definition: apibase.h:191
Result< void > DescribeIO(const T &s, const DataSerializeInterface &dsi)
Definition: datatypefunctions.h:21
const T & src
Definition: apibase.h:2613
return OK
Definition: apibase.h:2620
#define MAXON_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: classhelpers.h:317
#define MAXON_OPERATOR_MOVE_ASSIGNMENT(TypeName)
Definition: classhelpers.h:346
#define SIZEOF(x)
Calculates the size of a datatype or element.
Definition: apibasemath.h:205
#define iferr_scope
Definition: resultbase.h:1374
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;
HashInt GetHashCode() const
Definition: collection.h:894
Definition: basearray.h:413
Int GetMemorySize() const
Definition: basearray.h:1378
MAXON_ATTRIBUTE_FORCE_INLINE ResultRef< T > Append()
Definition: basearray.h:616
ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
Definition: basearray.h:1124
Definition: datatypebase.h:1768
Definition: datatypebase.h:2026
Definition: apibaseid.h:251
Further Reading