Fusion Model

The Fusion environment is modeled using one or more model elements defined as follows.

Structures

The basic model element within Fusion is defined as a structure, which defines a group of named properties. Each property is in turn a typed name-value pair, where property types can be any of the property types defined in Data Types. For example, a structure could be defined as:

Structure schema_structureName {
String pname = "pValue";
Sint32 [] ivector = {2, 4, 3};
Boolean bName;
};

The keyword Structure indicates that a definition of a structure follows. The definition starts with the name of the structure, followed by properties within that structure enclosed by curly braces, followed by a semicolon to indicate the end of the definition. By convention, structure names are defined in the form schemaName '_' structureName, with all related definitions within a schema sharing the name of the schema. Within the definition of a structure, properties are declared (again separated by semicolons). In the example above pname is a string valued property, whose default value is the string "pValue", and ivector is an array of 32-bit signed integers whose default value is the array {2, 4, 3}. The boolean property bName is declared without a default value associated with it.

Structure values are represented using the keywords value of of followed by the name of the structure with property values enclosed in curly braces.

Value of schema_structureName {
pname = "property value";
};

Note that in the example, the value of the property pname is defined as the string "property value", but the value of the property ivector is retained as {2, 4, 3} as a default from the definition, even though it is not given in the value declaration. In contrast, the boolean property bName does not have a value in this example (the property value is not provided within the structure value, and it does not have a default).

Within the modeling framework, data values may be thus be defined with explicit values, may have implicit values defined as defaults within the definition declaration, or may have no values associated with them (as in the case of bname above). Note that it is possible to explicitly assign NULL values to properties using the syntax:

pname = null;

The modeling framework thus differentiates a NULL value (which indicates an explicitly declared no value) from one where the value is absent (it is not declared, and has no default specified).

A structure may extend another structure, by referencing it as part of its definition.

Structure schema_childStructure : schema_structureName {
String childProperty;
};

Here, childStructure inherits all properties from its super-class schema_structureName but includes an additional string-valued property named childProperty as part of its definition.

Classes

A class is a structure that declares one or more methods in addition to properties. The keyword Class is used to define a class. For example,

Class schema_className {
 String stringProperty;
 String methodName(Sint32 parameter1, String parameter2);
};

defines a class containing a property stringProperty and a method methodName that takes an integer parameter parameter1 and a string parameter parameter2 and returns a string value as its output. Just like structures, the notation : parentClassOrStructure can be used to extend classes to subclasses. A class can extend a structure (but not vice versa) to allow properties defined within the parent structure to be extended to the class.

An instance of a class can be declared using the keywords instance of followed by the name of the class which is being instantiated. Thus, for example,

Instance of schema_className {
 stringProperty = "property value";
};

defines a new instance of the class schema_className. Note that while the instance declaration specifies property values within the class, it does not redefine the method—that is implicit within the instance. Language bindings provide mechanisms to invoke methods defined in classes.

Interfaces

The Fusion metamodel supports single inheritence, namely each class or structure can only extend one other class or structure. For notational convenience, a class can be declared as an interface using the keyword Interface. Thus,


Interface schema_interface {
 String interfaceProperty = "property name";
 String interfaceMethod(String parameter);
};

declares that schema_interface is the definition of an interface. As with classes and structures, an interface can be extended from one other interface. However, it cannot extend classes or structures. Another class (or structure) can then declare that it implements one or more interfaces using the qualifier implements as follows.


 [Implements{"schema_interface"}]
Class schema_class2 : schema_className {
 String class2Property;
};

Here, schema_class2 declares a new property classProperty. It extends schema_className, and thus inherits the property stringProperty and the method methodName from its parent. In addition, it also declares that it implements all properties and methods defined in schema_interface (thus it also implements the property interfaceProperty as well as the method interfaceMethod.

Enumerations

Enumerations are special structures consisting of a finite number of string or integer typed properties that have constant values. They provide a convenient mechanism for referencing a related group of constant values without having to re-declare them. For example:


Enumeration schema_enum1 : UInt16 {
 E1 = 3;
 E2 = 4;
};

defines an enumeration schema_enum1 with two constants E1 and E2, with unsigned 16-bit integer values 3 and 4 respectively. Note that enumerations are not instantiated (they are predefined constants within the model). The name of the enumeration serves as its type name, and values within an enumeration can be referenced using the notation EnumerationName.EnumerationValueName in properties. Similarly methods can return enumerated values by declaring the method as having a return type of the name of the enumeration. Note that all integer valued enumerations are required to provide values (as in the example above). String-valued enumerations may optionally define string values to be associated with enumeration value names. If not provided, the value corresponding to a value name is taken to be the same is the name of the value in that case.

Properties

Properties are declared in structures and classes using the notation

propertyType propertyName [ = defaultValue ];

where propertyType can be any of the types defined in Data Types, propertyName is the name of the property and defaultValue is an optional default value. Properties can be declared using complex types (e.g., structures or classes) using the name of the modeled type as the property type. Thus, schema_structureName s; declares that s is a property which can take any value of schema_structureName. Properties can also be declared as enumerations, thus schema_enum1 e; declares that e is a property, which can take on any value declared in the enumeration schema_enum.

References

Properties can also be declared as references to other modeled elements. Note that references refer to complex types (structures, classes and interfaces). Thus, schema_className ref foo; declares a that foo is a reference to a value of schema_className that is present elsewhere. A reference to an interface can hold a reference to any class that implements that interface.

Array Properties

Properties can have array values. This can be done by appending the propertyType or propertyName (but not both) by square brackets [], i.e., SInt32 [] p; or SInt32 p[] both declare that p is an array of 32-bit signed integers, and schema_className [] bar; declares bar to be an array of references to values taken on by schema_className.

Methods

Classes (but not structures) can declare methods on them. A method can optionally take on parameters, and optionally return a value. The type of the method is declared as the type of value it returns, and its parameters are declared using a comma-separated list of parameter definitions enclosed in parenthesis. Parameters use the same syntax as properties, with default values being used if the corresponding parameter is not present with the method is invoked. Thus

schema_className ref methodName (Sint32 p1 = 4, String p2);

declares a method methodName which takes two parameters (an integer parameter p1 and a string parameter p2) and returns a reference to a class schema_className. If the parameter p1 is not provided to the method when it is invoked, a default value of 4 is used.