IDL – Constructed Types (User-defined datatypes)

February 24, 2008 at 6:03 pm (CORBA, Unit 4) (, )

  • Combine other types to enable the creation of user-defined data types.

a) enumerated type

  • The enumerated type, enum allows the creation of types that can hold one of a set of predefined value specified by the enum.
  • Although the identifiers in the enumeration comprise an ordered list, IDL does not specify the ordinal numbering for the identifiers.
  • This is similar to enum in C and C++

Ex:

            enum DaysOfWeek

            {

                        Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday

            };

b) structure type

  • Contains any no. of member values of disparate types
  • Structures are useful in IDL because, unlike CORBA objects, structures are passed by value rather than by reference.
  • In other words, when a struct is passed to a remote object, a copy of that struct’s value is created and marshaled to the remote object.

Ex:

            struct DateStruct

            {

                        short year,

                        short month,

                        short day,

                        short hour,

                        short minute,

                        short second,

                        short microsecond

            };

c) union type

  • Represents values of different types.
  • Resembles a cross between a C/C++ union and a case statement.

Ex:

            union MultipleType switch(long)

            {

                        case 1:

                                    short myShortType;

                        case 2:

                                    double myDoubleType;

                        case 3:

                        default:

                                    string myStringType;

            };

  • Here, the parameter is called as discriminator.
  • A discriminator used in an IDL union is a parameter that determines the value used by the union. The constant values in the case statements must match the discriminator’s type.

 

Post a Comment

You must be logged in to post a comment.