The following example illustrates how complex configurations with substructures can be declared in a declarative way. You define the data members and a description for introspection:
class MyConfigSubstruct
{
public:
public:
int identifier;
std::string filename;
};
class MyConfig
{
public:
public:
std::vector<MyConfigSubstruct> files;
int classifier;
std::string name;
MyConfig()
:_Wolframe::serialize::DescriptiveConfiguration( "MyConfig", "MyClass", "MyApp", getStructDescription())
{
}
{
{
}
else
{
return false;
}
}
virtual bool check()
const
{
}
{
}
virtual void print( std::ostream& os,
size_t indent = 0 )
{
}
};
{
{
ThisDescription()
{
(*this)
(
"identifier", &MyConfigSubstruct::identifier) .
mandatory()
(
"file", &MyConfigSubstruct::filename) .
mandatory()
;
}
};
static const ThisDescription rt;
return &rt;
}
{
{
ThisDescription()
{
(*this)
( "files", &MyConfig::files)
(
"classifier", &MyConfig::classifier) .
optional()
;
}
};
static const ThisDescription rt;
return &rt;
}