About
Dedicated resource IDs are used to the define the ID of a key used with a maxon::DataDictionary and the type of the associated stored value (see DataDictionary Manual).
IDs
Within a given namespace one can use the attribute MAXON_ATTRIBUTE to declare resource IDs. This attribute can only be used in a header file since the source processor will create additional code in the included hxx
files.
{
}
Definition: string.h:1235
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:181
[data_resourceid_declare]
Definition: resource_id.h:14
MAXON_ATTRIBUTE(maxon::Bool, SETTING_A, "net.maxonexample.setting_a")
maxon::DataDictionary data;
data.Set(CUSTOMSETTINGS::SETTING_B,
"Hello World"_s)
iferr_return;
const maxon::Bool optionA = data.Get(CUSTOMSETTINGS::SETTING_A,
false);
const maxon::String optionB = data.Get(CUSTOMSETTINGS::SETTING_B,
""_s);
#define iferr_return
Definition: resultbase.h:1465
In contrast the attribute MAXON_ATTRIBUTE_LOCAL has to be used in a source code file to define IDs that are only relevant within the scope of that source code file.
namespace LOCALSETTINGS
{
}
{
}
#define MAXON_ATTRIBUTE_LOCAL(TYPE, NAME, RID,...)
Definition: fid.h:192
return OK
Definition: apibase.h:2667
#define iferr_scope
Definition: resultbase.h:1374
Switch
To use IDs defined with MAXON_ATTRIBUTE in a switch-case
statement one must use these macros:
- ID_SWITCH: Allows to use an ID in a
switch
statement.
- ID_CASE: Allows to use an ID in a
case
statement.
{
{
case ID_CASE(CUSTOMSETTINGS::SETTING_A):
{
}
case ID_CASE(CUSTOMSETTINGS::SETTING_B):
{
}
}
}
PyObject * key
Definition: abstract.h:289
#define ID_SWITCH(key)
Definition: fid.h:341
#define ID_CASE(key)
Definition: fid.h:354
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
Class IDs
Resource IDs can also be defined within a C++ class using the MAXON_ATTRIBUTE_CLASS attribute. This way the class name is used instead of a namespace to group the IDs.
{
public:
};
[data_resourceid_declare]
Definition: resource_id.h:28
MAXON_INTERFACE(SomeDataBaseInterface, MAXON_REFERENCE_CONST, "net.maxonexample.interface.somedatabase")
MAXON_INTERFACE_SINGLE_IMPLEMENTATION
Definition: resource_id.h:30
static MAXON_METHOD void SetData(maxon::DataDictionary &data)
MAXON_ATTRIBUTE_CLASS(maxon::Int, VALUE_A, "net.maxonexample.value_a")
static MAXON_METHOD void PrintData()
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
#define MAXON_REFERENCE_CONST(FREEIMPL)
Definition: interfacebase.h:1195
#define MAXON_METHOD
Definition: interfacebase.h:1001
#define MAXON_INTERFACE_BASES(...)
Definition: objectbase.h:1062
maxon::DataDictionary data;
data.Set(SomeDataBaseInterface::VALUE_B,
"Hello World"_s)
iferr_return;
Further Reading