OTL 4.0, OTL namespaces

OTL namespaces

The user may want to define more than one instance of the OTL 4.0, e.g. OTL 4.0/OCI7 and OTL 3.1/ODBC. In this example, two instances of otl_stream, otl_connect and otl_exception will be generated. The first instance is for the OCI7 and the second is for ODBC. In order to resolve the name conflict, OTL automatically generates namespaces to wrap up the instances of the OTL classes with, e.g. in the case of OTL_ODBC & OTL_ORA7, the following namespaces get generated: Of course, if both ODBC and OCI7 are being used, both ODBC and OCI object libraries need to be linked into the program, to resolve references to all external functions.

If only one out of many OTL #define's (OTL_ORA7, OTL_ORA8, OTL_ODBC, OTL_DB2_CLI, OTL_ODBC_MYSQL) is specified, no namespaces are generated, since there is no need.

The following is the list of legitimate combinations of the OTL macro definitions and namespaces to be generated:
 
OTL_ODBC or OTL_ODBC_MYSQL No namespaces defined
OTL_ORA7 No namespaces defined
OTL_ORA8 No namespaces defined
OTL_DB2_CLI No namespace defined
OTL_ODBC (or OTL_ODBC_MYSQL) &
OTL_ORA8
Namespace odbc is defined for OTL/ODBC & 
namespace oracle is defined for OTL/OCI8
OTL_ODBC (or OTL_ODBC_MYSQL) &
OTL_ORA7
Namespace odbc is defined for OTL/ODBC & 
namespace oracle is defined for OTL/OCI7
OTL_DB2_CLI &
OTL_ORA7
Namespace db2 is defined for OTL/DB2-CLI & 
namespace oracle is defined for OTL/OCI7
OTL_DB2_CLI &
OTL_ORA8
Namespace db2 is defined for OTL/DB2-CLI & 
namespace oracle is defined for OTL/OCI8

In case when namespaces are defined, OTL objects need to be prefixed with the namespace + the scope resolution operator, e.g.: oracle::otl_stream, odbc::otl_stream, db2::otl_stream. The only two objects that aredefined outside the namespaces are the otl_long_string and otl_null classes. OTL namespaces are useful for working with more than database at the same time. For more detail, see example 42.

The OTL namespace default behavior can be changed by the following macro definition: #define OTL_EXPLICIT_NAMESPACES. This #define forces OTL to always generate namespaces.


Prev NextContents Go Home

Copyright © 1996, 2007, Sergei Kuchin, email: skuchin@ispwest.com, skuchin@gmail.com .

Permission to use, copy, modify and redistribute this document for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies.