10.9. Classes

All managed classes defined in the C++ must be described in the IDL. This section documents class description (also reffered to as class definition) syntax.

10.9.1. Forward Declaration

As in C++, classes in IDL can be forward declared using the following syntax:


(25)            <class_fwd> ::= "class"
                                <identifier>
                                ";"

Class attributes are not specified in a forward declaration.

10.9.2. Class Definition

Class definition consists of a class header and a class body. Classes are defined (or described) using the following syntax:


(26)            <class_dcl> ::= <class_header>
                                "{" <class_body> "}"
(27)         <class_header> ::= "class"
                                [ "<" [ <classattr_vals> ] ">" ]
                                <identifier>
                                [ <class_inheritance> ]
(35)           <class_body> ::= <in_class>*
(36)             <in_class> ::= <enum>
                              | <attr_default>
                              | <class>
                              | <property>
                              | <method>
                              | ";"

The class header specifies an optional list of class attribute values, the class name and an optional class inheritance specification.

The class body can contain definitions of enumeration types and subclasses, attribute default overrides and declarations of class properties and methods.

10.9.3. Class Attributes

Class attribute value assignments satisfy the following syntax:


(28)       <classattr_vals> ::= <classattr_val>
                                { "," <classattr_val> }*
(29)        <classattr_val> ::= <boolclassattr_name>
                              | <classattr_name> "=" <const_expr>
(30)   <boolclassattr_name> ::= <scoped_name>
(31)       <classattr_name> ::= <scoped_name>

The following table lists all class attributes defined in src/core/object/object.idl:

Table 10.3. Class attributes defined in the Core IDL
NameTypeDefaultDescription
abstractboolfalse If true, the class is abstract and can't be instantiated.
assignableboolfalse If true, the class implements the assignment operator.
client_server_migrateboolfalse If true, the client can migrate objects of this type to servers.
comparableboolfalse If true, the class implements the == operator.
has_strong_pointerboolfalse If true, the class contains a strong pointer. This attribute is automatically set by the factgen, you should not assign it a value. However, you can query its value at run-time.
kind[a]ClassKindSHARED Kind of the class. It can be SHARED, SERVER or CLIENT. See Section 4.3.7, “Class Kinds” for more info.
no_archive[a]boolfalse If true, the instances of the class won't be archived. Class Massiv::Core::Lib::NodeObjectInterface has this attribute set to true. You should not change value of this attribute: all node objects should be non-archivable, other objects should be archivable.
no_balance[a]boolfalse If true, objects of this class will not be migrated by the load balancer.
no_migrate[a]boolfalse If true, the instances of the class won't be allowed to migrate. Class Massiv::Core::Lib::NodeObjectInterface has this attribute set to true. You should not change the value.
node_object[a]boolfalse Specifies whether the class true is a node object class. Class Massiv::Core::Lib::NodeObjectInterface has this attribute set to true. You should not change the value.
root[a]boolfalse If true, the instances of the class will be permanent GC roots. See Section 5.4, “Garbage Collector” for more information about the garbage collector.
simulation_startup_notify[a]boolfalse

If true, the instances of the class will be notified when the simulation is restored from an archive. The object_updated() will be called, with reason set to SIMULATION_STARTUP.

Setting this attribute to true is useful when an object needs to perform special initialization on simulation startup. For example, active account objects probably contain information about the connected client. Because account objects are archived as any other objects, this information is stored in the archive. When a new simulation is started, no clients are connected, but account objects that were active when the startup archive was created may contain obsolete information about clients. Therefore the class Massiv::Core::Lib::AccountObjectInterface has this attribute set to true.

The system ensures that all server nodes are running when the object_updated() is called. The order of object notifications is undefined. You must not use the synchronous RPC from the object_updated() callback.

throwable[a]boolfalse If true, the instances of the class can be thrown as an exception using the C++ throw.
trackedboolfalse If true, the instances of the class will be tracked by their object provider. This will make migrations of objects to the instances, including remote class to the instances, more efficient, and migration of the instances themselves a bit less efficient.
value_type[a]boolfalse If true, the instances of the class are value types. You should not set this attribute directly. Inherit the class Massiv::Core::Lib::ValueType which sets the attribute automatically instead. Value types are described in Section 4.3.4, “ValueTypes”.

[a] This class attribute has the “inherit” attribute flag set. Different attribute value lookup rules apply it the value is not specified in the class definition. See Section 10.8.6, “Attribute Value Lookup”.

10.9.4. Class Inheritance Specification

Class inheritance is specified using the following syntax:


(32)    <class_inheritance> ::= ":"
                                <base_class_name>
                                { "," <base_class_name> }*
(33)      <base_class_name> ::= [ "virtual" ] <class_name>
(34)           <class_name> ::= <scoped_name>

All base classes must be defined at the scope of the definition of the derived classes. Forward declaration won't suffice. All base classes must be inherited as public in the C++ definition of the class.

Each managed class must inherit Massiv::Core::Object exactly once.