OSB_LIB::Id< T > Struct Template Reference

Inheritance diagram for OSB_LIB::Id< T >:

Inheritance graph
[legend]
Collaboration diagram for OSB_LIB::Id< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<typename T>
struct OSB_LIB::Id< T >

Type-safe object identification.

The template structure Id provides type-safe object identifiers: Many database tables have an integer primary key. Id allows for typesafe "references" to objects via their id. Consider and compare the two code fragments below:

      // not type-safe
      class C {
      public:
          ...
          long oid;
          ...
      };

      C* findC(long cid); // any long to search for a C accepted!

      //  type-safe using Id<T>
      class C {
      public:
          typedef Id<C> Oid;
          ...
          Oid oid;
          ...
      };

      C* findC(const Id<C>& cid); // compiler error if findC() is not
                                  // called with correct type

Remarks:
Intentionally no operator long, i.e., automatic conversion to long is provided.

Definition at line 86 of file osbid.h.

Public Member Functions

Comparison operators:
All operators do normal comparsion on id_.

Private Attributes


Constructor & Destructor Documentation

template<typename T>
OSB_LIB::Id< T >::Id ( long  id = ID_NOT_SET  )  [inline, explicit]

Constructor with optional value.

Definition at line 91 of file osbid.h.


Member Function Documentation

template<typename T>
long OSB_LIB::Id< T >::id (  )  const [inline]

Get the value of the id.

Definition at line 93 of file osbid.h.

template<typename T>
bool OSB_LIB::Id< T >::isSet (  )  const [inline]

Check if object id is set.

Definition at line 97 of file osbid.h.

template<typename T>
bool OSB_LIB::Id< T >::notSet (  )  const [inline]

Check if object id is not set.

Definition at line 95 of file osbid.h.

Referenced by OSB_LIB::Id< OSB_LIB::Contract >::isSet(), and OSB_DB::OtlId::OtlId().

template<typename T>
bool OSB_LIB::Id< T >::operator!= ( const Id< T > &  rhs  )  const [inline]

Definition at line 103 of file osbid.h.

template<typename T>
bool OSB_LIB::Id< T >::operator< ( const Id< T > &  rhs  )  const [inline]

Definition at line 104 of file osbid.h.

template<typename T>
bool OSB_LIB::Id< T >::operator<= ( const Id< T > &  rhs  )  const [inline]

Definition at line 106 of file osbid.h.

template<typename T>
bool OSB_LIB::Id< T >::operator== ( const Id< T > &  rhs  )  const [inline]

Definition at line 102 of file osbid.h.

template<typename T>
bool OSB_LIB::Id< T >::operator> ( const Id< T > &  rhs  )  const [inline]

Definition at line 105 of file osbid.h.

template<typename T>
bool OSB_LIB::Id< T >::operator>= ( const Id< T > &  rhs  )  const [inline]

Definition at line 107 of file osbid.h.


Member Data Documentation

template<typename T>
long OSB_LIB::Id< T >::id_ [private]

The value of the id.

Definition at line 111 of file osbid.h.

Referenced by OSB_LIB::Id< OSB_LIB::Contract >::id(), OSB_LIB::Id< OSB_LIB::Contract >::notSet(), OSB_LIB::Id< OSB_LIB::Contract >::operator!=(), OSB_LIB::Id< OSB_LIB::Contract >::operator<(), OSB_LIB::Id< OSB_LIB::Contract >::operator<=(), OSB_LIB::Id< OSB_LIB::Contract >::operator==(), OSB_LIB::Id< OSB_LIB::Contract >::operator>(), and OSB_LIB::Id< OSB_LIB::Contract >::operator>=().


The documentation for this struct was generated from the following file:
Generated on Sat Sep 2 14:12:09 2006 for OSB Library by  doxygen 1.4.7