Project

General

Profile

Data type and constant definitions

All data types manipulated by Genom are described with a subset of the OMG IDL syntax. Those types map into traditional programming languages types using the specific mappings described in the GenoM IDL mappings section.

Type specification

The following set of type specifiers to represent typed values is available:

(56) type-spec ::=

simple-type-spec
| constructed-type-spec

(57) simple-type-spec ::=

base-type-spec
| template-type-spec
| named-type

(92) constructed-type-spec ::=

constructed-type

Subtopics

Type declaration

Type defined with the following syntax can then be used in the component interface definition and anywhere a type value is expected.

(58) type-dcl ::=

"typedef" type-declarator ";"
| "native" identifier ";"
| "exception" exception-list ";"
| constructed-type ";"
| forward-dcl ";"

(93) constructed-type ::=

struct-type
| union-type
| enum-type

(59) type-declarator ::=

( type-spec
| type-declarator "," ) declarator

Typedef

Types are most often given a unique name thanks to a typedef declaration; a name is also associated with a data type via the struct, union, enum, native and exception declarations.

Native types

It is possible to hide the actual definition of a data type from Genom (and its IDL parser) when it will never be directly used in the interface of the component, but can nevertheless be needed by codels. These types can be declared using the native attribute.

For example: native foo;

Exceptions

Exceptions are thrown by services in case of error. The exception keyword declares an exception, which is an identifier with an optional associated data type.

(60) exception-list ::=

{ exception-dcl "," } exception-dcl

(61) exception-dcl ::=

exception-name opt-member-list

(62) opt-member-list ::=

[ "{" ( "}"
| member-list "}" ) ]

A simple exception declaration would be :

exception INVALID_SPEED;

or with an associated type (to store the actual value for instance):

exception INVALID_SPEED {
  double speed;
};

Constant declaration

Constants define read-only values that are used by the component, like the maximal speed allowed for a motor or the physical bounds of a process that will be controlled. The syntax is again very similar to C or C++:

(68) const-dcl ::=

"const" const-type identifier "=" const-expr ";"

(69) const-type ::=

integer-type
| char-type
| boolean-type
| floating-pt-type
| octet-type
| string-type
| named-type

For example: const double max_speed = 72.0;