13.1.9 Sequences
A sequence in OMG IDL is mapped to a C++ class. The C++ class contains the following:
- Constructors
Each sequence has the following:
- A default constructor
- A constructor that initializes each element
- A copy constructor
- Destructors
- Modifiers for current length (and for maximum, if the sequence is unbounded)
- Accessors for current length
-
Operator[]
functions to access or modify sequence elements - Allocation and deallocation member functions
You must set the length before accessing any elements.
For example, consider the following OMG IDL definition:
// OMG IDL
module INVENT
{
. . .
typedef sequence<LogItem> LogList;
}
This definition maps to C++ as follows:
// C++
class LogList
{
public:
// Default constructor
LogList();
// Maximum constructor
LogList(CORBA::ULong _max);
// TYPE * data constructor
LogList
(
CORBA::ULong _max,
CORBA::ULong _length,
LogItem *_value,
CORBA::Boolean _relse = CORBA_FALSE
);
// Copy constructor
LogList(const LogList&);
// Destructor
~LogList();
LogList &operator=(const LogList&);
CORBA::ULong maximum() const;
void length(CORBA::ULong);
CORBA::ULong length() const;
LogItem &operator[](CORBA::ULong _index);
const LogItem &operator[](CORBA::ULong _index) const;
static LogItem *allocbuf(CORBA::ULong _nelems);
static void freebuf(LogItem *);
};
};
Parent topic: Mappings