6 Directives
There are a number of directives like register
which can appear in a space delimited list inside double angled brackets. For example:
$class GCRoots <<register>> isa IObject
{
};
Generally speaking the directives are boolean properties.
Prefixing the directive with minus (-) as for example -register is used to
disable the directive.
This is important in those cases where the directive defaults to true.
We say a class or struct is persistable if it implements the IPersistable interface.
Otherwise we say it is non-persistable.
The following directives are supported:
| directive | default | description |
|---|---|---|
| abstract | false | This is only an abstract base class |
| ser |
Helps determine whether both
exist for serialisation of this type Serialisation functions are reflected if and only if:
| |
| os | false | Generate operator<<() for xostream in terms of MyClass::Write()
A class has "access to a model" if any of the following are true
operator<<() is generated
|
| ar | Generate operator<<(),operator>>() for Archive in terms of MyClass::Serialise() | |
| extern | false | Class definition is provided elsewhere, and therefore this definition
should be elided.
This is used to reflect pre-existing classes, such as the Guid datatype
which is predefined in the cxUtils library. |
| passbyvalue | false | Allow pass by value in ABI
This sets the bit flag EReflectedClassBits::RCF_ALLOW_PASS_BY_VALUE
when the class is reflected |
| returnbyvalue | false | Allow return by value in ABI
This sets the bit flag EReflectedClassBits::RCF_ALLOW_RETURN_BY_VALUE
when the class is reflected |
| multiline | false | Auto generated function to write model to an xostream uses the
multiline format |
| traits | true | Generate type traits information |
| reflected |
Indicates whether the class should be reflected.
reflected cannot be specified for a nested type.
| |
| registered |
Indicates whether the reflected class should be registered.
registered cannot be specified for a nested type.
| |
| nested | ||
| genop | ||
| traits | ||
| rod | false | Indicates that instances of the class are Replicate On Demand (ROD) objects |
Destructor
The destructor of a reflected class or struct is reflected if and only if
- The class or struct is not marked as abstract using the
<<abstract>>directive AND - NOT (it is a
$adtthat doesn't implementIPersistable)
Embebbed model
In the following examples we say the class has an embedded model:
| example | |
|---|---|
| pure model | $model M {}; |
| base model |
$class X : model {} {};
$mixin X : model {} {}; |
| nested model |
$class X { $model{} };
$mixin X { $model{} }; |
In the following cases there isn't an embedded model:
| example | |
|---|---|
| no model |
$class X {};
$mixin X {}; |
| referenced base model |
$class X : model M {};
$mixin X : model M {}; |
| embedded mixin model |
$class X : mixin [model{}] {};
$mixin X : mixin [model{}] {}; |
| referenced mixin model |
$class X : mixin [M] {};
$mixin X : mixin [M] {}; |
Warnings from redundant directives
If any of the directives
ser,
passbyvalue,
returnbyvalue
is applied to a non-reflected class then a warning is produced by the Xcpp compiler.
For example, the following produces the warning
$class X is not reflected and has redundant << >> directives
// generates warning
$class X <<passbyvalue>> {};