IDL Interface Definition Language IDL products IDL interface

  • Slides: 14
Download presentation
IDL Interface Definition Language

IDL Interface Definition Language

IDL products IDL interface definition Client Dynam ic Interfa ce Server IDL stub s

IDL products IDL interface definition Client Dynam ic Interfa ce Server IDL stub s Static Dynami skeleto c ns skeleto Object adapter ns Object Request Broker Interface repositor y

Main IDL elements • • Modules Interfaces Data types Constants Attributes Operations Exceptions

Main IDL elements • • Modules Interfaces Data types Constants Attributes Operations Exceptions

IDL data types • Basic types • short long float boolean. . . •

IDL data types • Basic types • short long float boolean. . . • Derived types • using the typedef keyword • Structured types • enum struct union • Variable types: • dynamic arrays, string • The Any type array

Basic types and constants • • Integer: [unsigned] short long Reals: float double 8

Basic types and constants • • Integer: [unsigned] short long Reals: float double 8 bits: char octet boolean Generic: any const double Pi = 3. 1415926 ; const string Msg = “This is a message” ; const unsigned long Mask =(1<<5)|(1<<7) ;

Structured types enum Credit. Card {Master, Visa, none}; struct Person. Record { string name

Structured types enum Credit. Card {Master, Visa, none}; struct Person. Record { string name ; short age ; } union Customer switch (Credit. Card) { case Master: string card. Number ; . . . }

Arrays, sequences, and strings // arrays typedef long. Vect [30]; typedef long. Array [2][10];

Arrays, sequences, and strings // arrays typedef long. Vect [30]; typedef long. Array [2][10]; // sequences typedef sequence <short> short. Seq; typedef sequence <short, 20> short. Seq 20; // strings typedef string <1024> bounded. String;

Module declaration module <name> { <type declarations> <constant declarations> <exception declarations> <interface declarations> }

Module declaration module <name> { <type declarations> <constant declarations> <exception declarations> <interface declarations> }

Interface declaration interface <name> [: inheritance] { <type declarations> <constant declarations> <exception declarations> <attribute

Interface declaration interface <name> [: inheritance] { <type declarations> <constant declarations> <exception declarations> <attribute declarations> <method declarations> }

Method declaration <return type> <name> (<parameters>) [raises <exceptions>] [context] ; • Method parameters can

Method declaration <return type> <name> (<parameters>) [raises <exceptions>] [context] ; • Method parameters can be: – in: sent to the server – out: received from the server – inout: both directions

Attribute declaration attribute string name ; readonly attribute short age ; • Attributes: •

Attribute declaration attribute string name ; readonly attribute short age ; • Attributes: • are declared as variables • get and set methods are provided

An interface definition example module Animals { // Interface for a dog interface Dog

An interface definition example module Animals { // Interface for a dog interface Dog : Animal { // a public attribute integer age; // an exception that can be raised exception not. Interested (string why);

An interface definition example // public methods void Bark (in short duration) raises (not.

An interface definition example // public methods void Bark (in short duration) raises (not. Interested) ; void Sit (in string local) raises (not. Interested) ; void Play (in Dog friend) raises (not. Interested) ; boolean Alive () ; } }

IDL - exemplo module Escola { interface Curso; // declarado, mas não definido interface

IDL - exemplo module Escola { interface Curso; // declarado, mas não definido interface Estudante { attribute string nome; attribute unsigned long matricula; exception Classe. Lotada; void registra (in Curso curso) raises (Classe. Lotada); exception Req. Incompleto; void gradua ( ) raises (Req. Incompleto); typedef sequence<Curso> Lista. Cursos; Lista. Cursos cursos_registrados(); } }