OMG Interface Definition Language (IDL)

zhaozj2021-02-16  54

OMG interface definition language

(IDL)

Interface Definition Language (IDL) is required when writing a distributed system with RPC / COM / CORBA technology.

IDL Features: 1, IDL is a normative language. 2, IDL looks like C language. 3, the purpose of the omg IDL is to define the process of interface and streamlined distribution objects. 4, the interface of the IDL separation object is implemented. 5, IDL peel off the programming language and hardware dependence. 6. The client programmer using the IDL definition interface does not know the details behind the interface. 7. IDL provides a universal data type and defines a more complex data type in these data types.

This article explains the built-in type and keyword of the OMG IDL.

OMG interface definition language built-in type table:

Types of

range

Minimum size (bit)

Short

-215 to 215-1

16

Unsigned short

0 to 216-1

16

Long

-231 to 231-1

32

Unsigned long

0 to 232-1

32

Long Long

-263 to 263-1

64

Unsigned long long

0 to 264-1

64

Float

IEEE single precision

32

Double

IEEE double precision

64

Long Double

IEEE double-byte extension floating point number

15-digit index, 64-bit band symbol decimal

charr

ISO Latin-1

8

Wchar

Code wide character from any wide character set, such as Unicode

Depend on implementation

String

Iso Latin-1, except for ASCII NUL

Variable

Boolean

True or False

unspecified

Octet

0 to 255

8

Any

The type of data described you can represent any IDL type

Variable

IDL basic type

Integer type

OMG IDL Abandon INT types of polymity of differentness in different platforms. IDL provides an integer type of 2 bytes (Short), 4 bytes (LONG), and 8-byte (long long). All of these integer types have the corresponding non-symbolic number type.

Floating point type

OMG IDL floating point type Float, Double and long double. OMG IDL follows the standard of IEEE 754-1985 binary floating point count arithmetic. Currently, Long Double is used for huge numbers, and some language mappings do not support this type.

CHAR and WCHAR

IDL Standard Character Set: The lexical convention (indicating keywords, comments, and characters of the IDL file) specifies the ISO 8859.1 character set represents characters in the IDL file. ISO 464 defines empty characters (NULL) and other graphic characters.

OMG IDL must handle characters transfer from a computer system to another computer system. The conversion from a character code set to another character code set depends on the language binding.

OMG IDL Char is an 8-bit variable that can be represented by two ways. First, it can encode the single-byte character from the byte of the code set. Second, when used in an array, you can encode any multi-byte characters from a multi-byte character set (such as Unicode). OMG IDL WCHAR only allows for more than 8 bytes of code set. Specifications do not support special code sets. OMG IDL WCHAR allows each client and server to use this unit's code set, then specify how characters and strings are converted between environments using different code sets.

The BooleanBoolean value can only be True or False.

Octet

OcTet is an 8-bit type, a very important type.

There will be no changes when the OCTET is transmitted between the address space. OcTet is still the same as when sending binary data and packing it. The other IDL types have differentiated changes in transmission. For example, according to the indication of the IOR code set information, the Char array will experience the code set conversion. The OCTET array is not. Any Type IDL ANY is a structure containing any data type.

IDL ANY consists of type codes and values. Type code describes the content of the value of any.

IDL Any This type can be a CHAR or Long Long or String or another ANY, or a type that has already been created, such as Address.

IDL ANY is similar to C self-description data type VOID *, but it is safer.

IDL ANY is similar to user-defined type of Variant's user-defined VARIANT.

OMG IDL provides custom data types, which can be enumerated, structures, and union, or new types created with TypedEF.

Named types should create new type names using TypedEf, which will help interpret interfaces or save your input.

For example, TypedEf float atmospressure;

In style, be careful not to create an alias for the existing type. The CORBA specification does not guarantee the two types of TypeDef for SHORTs that are compatible and interchangeable.

The OMG IDL Typedef keyword specific meaning depends on the implementation language they are mapped. In C , the TypeDef keyword represents the type definition, and actually the alias may be a more precise term.

Enumeration OMG IDL enumeration is a way to attach names to numbers, thus understanding the code more meaning.

The omg idl version enumeration looks like a C version enumeration.

For example, Enum CloudCover {Cloudy, Sunny};

CloudCover now has a new type that can be used in IDL.

Enumerate up to 232 identifications.

There is no order value in the specification.

OMG IDL does not allow empty enumerations.

The structural struct keyword provides a method of focusing a set of variables into a structure.

E.g,

Struct date {

Short month;

SHORT DAY;

Long Year;

}

When defining struct, make sure that the type created is readable.

Do not create several different symbol structures in different namespaces, making IDL users confused.

Identification combined with a mixture of C-shaped types and Switch statements.

The combination must have a type tag field.

Only one joint member can be active at a time, and the member can be determined from its identification name.

E.g,

ENUM PRESSURESCALE {Customary, Metric};

Union BarometricPressure Switch (PressureScale) {

Case Customary:

Float inches;

Case metric:

DEFAULT:

Short CCS;

}

In the above example, if the identification name is metric, or the identified identification name value is used, the SHORT CCS is active. If the identification name is Customary, the Float member inches is active. A joint member can be any type, including user-defined complex types.

The identification name type must be an integer type (Short, long, long long, etc., and char, boolean or enumeraton).

Constant defined constants can be integer, characters, floating point numbers, strings, boolean, octet, or enumeration types,

Can't be an ANY type or user-defined type.

E.g,

Const float meandensityearth = 5.522; // g / cm ^ 3const float knot = 1.1508; // miles per hour

Const char NUL = '/ 0';

You can define an integer constant with a decimal, hexadecimal or octal count:

E.g,

Const long array_max_size = 10000;

Const long hex_num = 0xff;

For index and decimal, floating-point characters use common C conventions:

E.g,

Const Double Speed_of_light = 2.997925E8;

Const Double Avogadro = 6.0222E26;

Characters and string constants support standard modulation sequences:

E.g,

Const char Tab = '/ t';

Const char newline = '/ n';

As long as there is no hybrid type expression, the arithmetic operator can be used in the constant statement.

User abnormal exception is similar to a structure, using exceptions from the method.

E.g,

Exception Divide_BY_ZERO {

String Err;

}

Interface someiface {

LONG DIV (in long x, in long y) raises (divide_by_zero);

}

An exception will create a namespace.

The member name in the abnormality must be unique.

An exception cannot be used as a data member for a user-defined type.

There is no abnormal inheritance in the OMG IDL.

An array, sequence, and string are only possible each time it is possible.

An array of languages ​​is usually different from an array of language in another language.

OMG IDL array types IDL Array and Sequence can be easily mapped to implement language.

The String type is a special sequence that allows the language to use their string and optimization.

Array OMG IDL has an array of multi-dimensional fixed-size modes.

All arrays are boundless.

The array is ideal for use with a list with a fixed number of elements, and these elements are usually existing.

E.g,

// Bounded and UNBounded Array Examples

Typedef long shares [1000];

Typedef string spreadsheet [100] [100];

Struct OFARRAYS {

Long AnaRray [1000];

}

// unbounded arrays not allowed

// typedf long orderrs [];

The array dimension must be specified and must be a positive integer constant.

IDL does not support an array of open arises in C and C .

IDL does not have a pointer support.

The IDL must appear typedef keyword unless the specified array is part of the structure.

IDL does not specify an array subtraction method in any way, morphology or form.

An array subscript that implements language to another implementation language can be different.

It cannot be assumed that the array will be sent to the server from the client, and the server adjusts and points to the correct array element.

The array subscript of some languages ​​starts from 0, while others start from 1.

The sequence sequence is a growing vector, which has two features: the maximum size of the element, determined when compiling, can be infinite;

Length, determined at runtime.

The sequence can contain all types of elements, whether the basic type or the user-defined type.

The sequence can be boundless or not.

E.g,

// bounded and unbounded sequence exampleypedec sequence unbounded;

Typedef sequence boud;

An unlimited sequence can have any multiple elements, which will only be limited by the platform memory size.

The limited sequence has boundary restrictions.

Unlimited sequences and finite sequences may not contain elements, user-defined types, but can contain other sequences.

String and WStringString are equivalent to the sequence of char, while WString represents the sequence of Wchar.

As a compromise between C and C , OMG IDL String and WString can contain any characters, other than empty characters.

The char or WCHAR convention determines that the element size of type String is represented by 8 bytes.

The element size of the WString type is 16 bytes or more.

The strings in IDL are very special, and OMG allows language mapping to use special optimization, which will not be processed with the general sequence.

Names and scope OMG IDL identities are case sensitive.

IDL only has a global scope.

The entire OMG IDL content and all files introduced through the preprocessor pseudo directive form a naming field.

No definitions in a scope are part of the global scope.

In the global scope, the following definitions make up the scope: Module, Interface, Struct, UNION, Operation, and Exception.

The Module keyword unique purpose is to create a namespace.

A logo can be defined in a scope, but can redefine in a nested scope.

example

Module States {

// Error: redefinition

// Typedef sequern states;

Module Pennsylvania {

Typedef string river;

Interface capital {

Void Visitgovernor ();

}

}

Module newyork {

Interface capital {

Void Visitgovernor ();

}

Interface Pennsylvania {

Void Visit ();

}

}

Module newjersey {

Typedef Pennsylvania :: River NJRIVER;

// Error

// typedef string pennsylvania;

Interface capital {

Void Visitgovernor ();

}

}

}

The interface interface specifies the software implementation between the service implementation and the use of its clients.

An example of a callback.

// thrown by Server When the client passes

// an invalid connection id to the server

Exception InvalidConnectionIDEXCEPTION

{

Long InvalidId;

}

// this is the callback interface there

// the client has to import in order

// TO Listen to a Talker.

Interface Listener

{

// Called by the server to dispatch message on the client

Void Listen (in string message);

// Called by the Server When THE Connection

// with the client is successfully opened

Void Engage (in string person); // called by the server when the connection with the client is close

Void Disngage (in string person);

}

// Interface on the Server Side

Interface Speaker

{

// Called by the client to open a new connection

// returned long is the connection id

Long Register (In Listener Client, In String Listenername);

// Makes The Server Broadcast The Message To All Clients

Void Speak (in long connectionid, in string message)

Raises (InvalidConnectionIDexception);

// Called by the client to sever the communication

Void Unregister (in long connectionID)

Raises (InvalidConnectionIDexception);

}

The interface name becomes a type, which can be transmitted as a parameter. It is actually a reference.

Each object reference (IOR) only points to an interface.

The IDL interface corresponds to the class definition, and the CORBA object corresponds to class instance.

转载请注明原文地址:https://www.9cbs.com/read-28304.html

New Post(0)