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:
{
public:
{
}
};
[datatypes_datatype_declaration]
Definition: custom_datatype.h:25
maxon::Int _a
Definition: custom_datatype.h:29
maxon::Int _c
Definition: custom_datatype.h:31
maxon::Int _b
Definition: custom_datatype.h:30
IntegerTriplet()
Definition: custom_datatype.h:27
maxon::String ToString(const maxon::FormatStatement *formatStatement) const
Definition: custom_datatype.h:33
Definition: string.h:1235
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
#define MAXON_DATATYPE(type, id)
Definition: datatype.h:295
#define FormatString(...)
Definition: string.h:2100
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:411
Usage
An instance of a class registered as a MAXON API data type can be stored in a maxon::Data container:
Definition: datatypebase.h:1199
Result< void > Set(T &&data)
Definition: datatypebase.h:1393
#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:1404
Result< void > Init(const DataType &type)
Definition: datatypebase.h:1213
Definition: datatypebase.h:772
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.
{
public:
{
};
{
}
{
return false;
return false;
return false;
return true;
}
{
}
{
}
{
}
{
}
};
[datatypes_datatype_declaration]
Definition: custom_datatype.h:54
maxon::Int _a
Definition: custom_datatype.h:62
maxon::Int _c
Definition: custom_datatype.h:66
maxon::Result< void > CopyFrom(const AdvancedIntegerTriplet &src)
Definition: custom_datatype.h:71
maxon::Int _b
Definition: custom_datatype.h:65
static maxon::Result< void > DescribeIO(const maxon::DataSerializeInterface &stream)
Definition: custom_datatype.h:106
MAXON_DISALLOW_COPY_AND_ASSIGN(AdvancedIntegerTriplet) public
Definition: custom_datatype.h:55
maxon::Int GetMemorySize() const
Definition: custom_datatype.h:118
MAXON_OPERATOR_MOVE_ASSIGNMENT(AdvancedIntegerTriplet)
maxon::UInt GetHashCode() const
Definition: custom_datatype.h:91
AdvancedIntegerTriplet(AdvancedIntegerTriplet &&src)=default
maxon::Bool operator==(const AdvancedIntegerTriplet &other) const
Definition: custom_datatype.h:79
maxon::String ToString(const maxon::FormatStatement *formatStatement) const
Definition: custom_datatype.h:101
UInt32 GetCrc() const
Definition: crc32c.h:66
MAXON_ATTRIBUTE_FORCE_INLINE void UpdateInt(Int i)
Definition: crc32c.h:543
static constexpr ValueType NONE
Default.
Definition: dataserialize.h:136
Definition: dataserialize.h:207
PyObject * stream
Definition: codecs.h:186
PyObject * src
Definition: abstract.h:305
PyObject * other
Definition: dictobject.h:70
#define Describe(name, memberName, type, flags)
Definition: dataserialize.h:294
#define PrepareDescribe(streamClass, className)
Definition: dataserialize.h:268
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:181
UInt64 UInt
unsigned 32/64 bit int, size depends on the platform
Definition: apibase.h:189
return OK
Definition: apibase.h:2667
#define SIZEOF(...)
Calculates the size of a datatype or element.
Definition: apibasemath.h:205
#define iferr_scope
Definition: resultbase.h:1374
maxon::Id fileID(
"net.maxonexample.triplet");
maxon::DataFormatWriterRef outputStream = maxon::DataFormatWriterFactories::Binary().Create(url)
iferr_return;
maxon::DataFormatReaderRef inputStream = maxon::DataFormatReaderFactories::Binary().Create(url)
iferr_return;
HashInt GetHashCode() const
Definition: collection.h:894
Definition: basearray.h:412
Int GetMemorySize() const
Definition: basearray.h:1623
MAXON_ATTRIBUTE_FORCE_INLINE ResultRef< T > Append(ARG &&x)
Definition: basearray.h:677
ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
Definition: basearray.h:1369
Definition: datatypebase.h:1800
Definition: datatypebase.h:2070
Definition: apibaseid.h:253
Py_ssize_t size
Definition: bytesobject.h:86
Further Reading