13.1.5 Constants
A constant in OMG IDL is mapped to a C++ const
definition. For example, consider the following OMG IDL
definition:
// OMG IDL
const string CompanyName = “BEA Systems Incorporated”;
module INVENT
{
const string Name = “Inventory Modules”;
interface Order
{
const long MAX_ORDER_NUM = 10000;
};
};
This definition maps to C++ as follows:
// C++
const char *const
CompanyName = “BEA Systems Incorporated”;
. . .
class INVENT
{
static const char *const Name;
. . .
class Order : public virtual CORBA::Object
{
static const CORBA::Long MAX_ORDER_NUM;
. . .
};
};
Top-level constants are initialized in the generated.h
include file, but module and interface constants are initialized in the generated client stub modules.
The following is an example of a valid reference to the MAX_ORDER_NUM
constant, as defined in the previous example:
CORBA::Long accnt_id = INVENT::Order::MAX_ORDER_NUM;
Parent topic: Mappings