IDL is the key for interoperability in CORBA. IDL is the neutral intermediate language which specifies a component's boundaries, interfaces with potential clients or any description of any resource or service that the server component wants to expose to its client. The CORBA IDL is declarative i.e., it separates interfaces from implementation details. IDL specified methods can be written in and invoked from any language that provides CORBA bindings (C, C++ and smalltalk at present). It basically acts as an intermediate neutral interface which allows client and server objects written in different languages to interoperate across networks and operating systems.
IDL is necessarily used by clients for two purposes:
IDL can be used to specify component's attributes, the parent classes it inherits from, the exceptions it raises, typed events, interfaces and the methods an interface supports -- including the input and output parameters and their data types.
IDL grammar is a subset of C++ with additional keywords to support distributed concepts. It supports C++ like syntax for constants, type and operation declarations. IDL provides a direct path between its interfaces and the compiled code that implements it. IDL precompiler can directly generate client header files and server implementation skeletons.
The following code shows a typical IDL representation of a component [ Orfali ]
module <identifier>
{
<type declarations>;
<constant declarations>;
<exception declarations>;
interface <identifier> [:<inheritance>]
{
<type declarations>
<constant declarations>;
<exception declarations>;
<attribute declarations>;
{<op_type>] <identifier> (<parameters>)
[ raises exception][context]
.
[<op_type>] <identifier> (<parameters>)
[ raises exception] [ context]
.
}
interface <identifier> [:<inheritance>}
.
}
Modules are a set of interfaces (class descriptions) grouped together under a common name. It basically gives an additional level of hierarchy in the IDL namespace. A module is identified by the keyword module.
Interfaces define a set of operations (methods) that a client can invoke on an object. It is nothing but a class definition, which describes the methods, parameters to be passed to the methods, data types and exceptions but does without implementation section. Interface defines eexceptions which handles errors. An interface may also have attributes (private variables) and each of these attributes should have get and set methods created automatically during implementation. IDL defines inheritance relationships using a syntax similar to C++ syntax.
Operation is a method that a client can invoke. The operation's signature is the method's parameters and the results it returns. A parameter has a mode which gives the direction of passing of values (ie) from server to client or client to server or both. The op_type is the type of the return value. An optional context expression contains a set of attribute values that describe a client's context. It lets a client pass information about its local environment.
Data Types are used to describe the accepted values of parameters,
attributes and the return values. Data types are CORBA objects that are
used across multiple platforms, languages and operating systems. CORBA
supports two categories of data types: basic and constructed.
CORBA's basic type include short, long, unsigned short, unsigned long,
float, double, char, boolean
and octet
. CORBA's constructed type include
enum, string, struct, union, sequence
and any. The sequence type lets
to pass a variable size array of objects. The any data type represents
both basic and constructed data types dynamically.
Fig 2: IDL Example
From Fig 2 it is clear that the class Dog inherits from classes Pet and Animals. Class Cat inherits from Class Animals. Bark(), Sit() and Growl() are the methods in Class Dog. Eat(), Herekitty() and Bye() are the methods in Class Cat(). The following code shows how these classes and their methods can be described using IDL [ Orfali ].
module Dog::Animals
{ /* Class Definitions of Dog */
interface Dog:Pet, Animal
{
attribute integer age;
exception NotInterested{string explanation}
void Bark ( in short how_long)
raises (NotInterested);
void Sit ( in String where)
raises (NotInterested);
void Growl ( in String at_whom)
raises (NotInterested);
}
interface Cat:Animal{ /* similar to Dog */ }
Copyright © 1996 Virginia Polytechnic Institute & State University
All Rights Reserved
Padmapriya Vasudevan
priya@csgrad.cs.vt.edu
Last modified: Sun Sep 22 21:16:15 1996