 |
|
|
Oct 26 1999. |
Some ODL Examples
|
Note the use of enumerated
types, and the structure for Timestamp.If you are a C user this
should be very familar. This Timestamp structure could map to
a class or just be represented as a dictionary. The TimestampOrNil
object would become an instance of a CorbaUnion class, and the
ExampleOne or ExampleTwo structures could map to classes, or
again be dictionaries.
module Example {
enum logicalOperator { NOP, AND, OR };
struct Timestamp {
short year,month,day,hour,minute,second,millisecond;
};
//A Union object to allow us to have a reference both to nil,
//or to the timestamp value. In Smalltalk some implementations
let you
//get away with passing nil without explicit declaration, but
you
//are asking for trouble.
union TimestampOrNil switch (long) {
case 1: Timestamp aTimestamp;
case 2: Smalltalk::UndefinedObject nil;
};
//A more complex stucture using previous ODL definitions.
struct ExampleOne {
string identifier;
TimestampOrNil timestampOrNil;
Timestamp timestampOnly;
};
//Final example, where we use an array(sequence)
//Note that ackStartTimestamp must have a value, but ackEndTimestamp
//can be nil if required because of the use of the union defined
above.
//The sequenceOfExampleOnes will map to a CorbaArray instance.
struct startEndStamp {
sequence<ExampleOne> sequenceofExampleOnes;
string ackStartBy;
Timestamp ackStartTimestamp;
string ackEndBy;
TimestampOrNil ackEndTimestamp;
logicalOperator logicalOperatorToApply;
}
//Our lone interface to allow us
to push data to a remote object
//Note we get back a Timestamp object, or a possible exception.
interface push {
Timestamp pushData(in startEndStamp data)
raises (InvalidTimeStamp);
};
}; //end module
|