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:

directivedefaultdescription
abstractfalseThis is only an abstract base class
ser Helps determine whether both
 
InputArchive& operator>>(InputArchive& ar, T& x);
OutputArchive& operator<<(OutputArchive& ar, const T& x);

exist for serialisation of this type T and therefore can be reflected.

Serialisation functions are reflected if and only if:

  • The class is not marked as abstract using the <<abstract>> directive AND
  • Either
    • <<ser>> is used OR
    • Both the following are true:
      • <<-ser>> isn't used AND
      • operator<<() and operator<<() serialisation operations are auto generated
osfalseGenerate operator<<() for xostream in terms of MyClass::Write() A class has "access to a model" if any of the following are true
  • it is a pure model
  • it references a pure model
  • it embeds an anonymous model
In that case by default operator<<() is generated

operator<<() is auto generated if and only if

  • The class is not marked as abstract using the <<abstract>> directive AND
  • Either
    • <<os>> is used OR
    • All the following are true:
      • <<-os>> isn't used AND
      • The class is not a $mixin AND
      • The class is either a pure model or it references a model or it has a base model or it has a referenced base model
arGenerate operator<<(),operator>>() for Archive in terms of MyClass::Serialise()
externfalseClass 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.
passbyvaluefalseAllow pass by value in ABI This sets the bit flag EReflectedClassBits::RCF_ALLOW_PASS_BY_VALUE when the class is reflected
returnbyvaluefalseAllow return by value in ABI This sets the bit flag EReflectedClassBits::RCF_ALLOW_RETURN_BY_VALUE when the class is reflected
multilinefalseAuto generated function to write model to an xostream uses the multiline format
traitstrueGenerate 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
rodfalseIndicates 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

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>> {};