Fractal | Fractal ADL | Cecilia Examples | Minus


The purpose of thinkMC is to abstract the C programmer from the conventions and the definition of data structures while implementing primitive components for Cecilia. Although allowing the programmer to manipulate concepts alien to standard C language, thinkMC is not however a new language, and promotes the use of standard C and related standard C compilation chains as available with target processors.

See the Helloworld example for a concrete basic example of the thinkMC language.

Grammar Specifications

Following subsections provide the specification of the thinkMC language constructs.

Implementation file

The implementation file must be called with the name that has been used in the specification of the component in ADL. The extension of the file must be ".c". The content of the file must follow the below structure.


Instance data declaration

The declaration of instance data of components is made using the DECLARE_DATA construct whose structure is given below. This declaration must be done even if the component does not have any instance data. Instance data of a component is formed by a set of fields (The content of the DECLARE_DATA construct is equivalent to the definition of a C structure).


Constructor/Destructor implementation

A primitive component may provide a constructor and/or a destructor method. Constructor is called automatically when the component instance is initialized and before its client interfaces are bound. A constructor cannot invoke methods of its client interfaces. Similarly, a destructor is called just before the instance is destroyed and cannot invoke methods of its client interfaces.

If a primitive component provides a constructor and/or a destructor, the content element of the ADL of the component must specify it (see ADL documentation for details).

CONSTRUCTOR ::= "void CONSTRUCTOR(void *_this)"  
DESTRUCTOR ::= "void DESTRUCTOR(void *_this)"  

Method implementation

A primitive component implementation file must contain the implementations of each method of each interface that is provided by the component. There are two issues to consider for method implementations:

  • declaring the signature of the method with a specific construct called METHOD,
  • must accept as first parameter of the method a void pointer which is called _this. The structure of the method implementation is given below.
METHOD ::= returnType "METHOD(" interfaceName "," methodName ") (void *_this," 
                   ("," argument)* ")"  

Method invocation

Components can invoke methods that are provided by other components through their client interfaces. To this end, a CALL construct has been defined whose structure is given below.

"CALL(" interfacePointer "," methodName ("," parameter)* ");"

The first argument of the CALL construct is an interface reference (i.e. a pointer to an interface). See next section to know how to get references to client interfaces.

WARNING: Because of limitations in the C pre-processor, the CALL construct is NOT RECURSIVE. It means that the parameter list cannot contains inner usage of CALL.

Access to client interfaces

Components can access their client interfaces using the REQUIRED construct. The structure of this construct is given below.

"REQUIRED." interfaceName

To invoke a method of on a client interface the construct is

CALL(REQUIRED.interfaceName, methodName, parameters...)

Access to instance data

Components can access the instance data that has been declared in the DECLARE_DATA construct, using the DATA construct. The structure of this construct is given below.

"DATA." fieldName

Access to attributes

Components can access their attributes using the ATTRIBUTES construct. The structure of this construct is given below.

"ATTRIBUTES." fieldName

Invocation of self method

Components can invoke their own server interface using the CALLMINE construct. The structure of this construct is given below.

"CALLMINE(" serverInterfaceName "," methodName ("," parameter)* ");"

This construct only works on server interfaces that are actually implemented by the implementation code (i.e. functional code). To invoke methods on a controller interface use the GET_MY_INTERFACE and the CALL constructs.

Access to server interfaces

Components can retrieve a reference to their server interfaces using the GET_MY_INTERFACE construct. The structure of this construct is given below.

"GET_MY_INTERFACE(" interfaceName ")"

For instance to invoke the bindFc method of the binding-controller interface of the component itself, use the following code:

CALL(GET_MY_INTERFACE(binding_controller), bindFc, ... );
2007-2009 © ObjectWeb Consortium  | Last Published: 2009-04-21 13:48  | Version: 2.1.0