otl.h

Go to the documentation of this file.
00001 // OSB library ********************************************* -*- C++ -*-
00013 /*
00014   AUTHOR(S): Andreas Huggel (ahu)
00015 
00016   RCS information
00017    $Name: OSB_060808 $
00018    $Revision: 1.28 $
00019 
00020   License
00021    OSB rating and billing library for communication networks
00022    Copyright (C) 2004, 2005, 2006  OSB systems
00023 
00024    This file may be distributed and/or modify under the terms of the
00025    GNU General Public License (GPL) as published by the Free Software
00026    Foundation which is provided in the file LICENSE.GPL included in the
00027    packaging of this file.
00028 
00029    The file is distributed in the hope that it will be useful, but WITHOUT
00030    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00031    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00032    for more details.
00033 
00034    Holders of a OSB Commercial License may use this file under the terms
00035    and conditions of this commercial license.
00036  */
00037 #ifndef _OSBOTL_H_
00038 #define _OSBOTL_H_
00039 
00040 // *********************************************************************
00041 // included header files
00042 #include <string>
00043 
00044 #include <config.h>                     // for OTL configuration
00045 
00046 // Pragmas to disable cxx compiler warnings on Compaq Tru64 UNIX
00047 #pragma message save
00048 #pragma message disable (intconlosbit, setbutnotused, unrfunprm)
00049 #include <otlv4.h>
00050 #pragma message restore
00051 
00052 #include "osbid.h"
00053 #include "chrono.h"
00054 
00055 // *********************************************************************
00056 // class declarations
00057 namespace OSB_DB {
00058     class DbException;
00059     class ChildFound;
00060 }
00061 
00062 // *********************************************************************
00063 // namespace extensions
00064 namespace OSB_DB {
00065 
00067     const short FEW_ROWS  =  50;
00069     const short MANY_ROWS = 2000;
00070 
00071     const unsigned int MAX_NAME =  63;   // OSB_LIB::MAX_NAME
00072     const unsigned int MAX_DES  = 255;   // OSB_LIB::MAX_DES
00073     const std::string DES_DB = "<char[256]>";
00074     const std::string NAME_DB = "<char[64]>";
00075     const std::string ROWID_DB = "<char[32]>";
00076 
00082     enum SqlCode { CHILD_FOUND                = -2292,
00083                    NO_PARENT                  = -2291,
00084                    DEAD_LOCK                  =   -60,
00085                    RESOURCE_BUSY              =   -54,
00086                    UNIQUE_CONSTRAINT_VIOLATED =    -1,
00087                    SUCCESSFUL_COMPLETION      =     0,
00088                    NO_DATA_FOUND              =  1403 };
00089 
00095     DbException dbException(const otl_exception& e);
00102     DbException dbException(long errNo, const otl_exception& e);
00103 
00110     ChildFound childFound(const otl_exception& e);
00117     ChildFound childFound(long errNo, const otl_exception& e);
00118 
00126     std::string otlErrMsg(const otl_exception& e);
00127 
00136     class OtlString : public otl_value<std::string> {
00137     public:
00139 
00140 
00141         OtlString();
00143         OtlString(const otl_null& rhs);
00145 
00151         explicit OtlString(const std::string& rhs);
00152 
00158         operator std::string() const;
00159     };                                  // class OtlString
00160 
00169     class OtlId : public otl_value<long> {
00170     public:
00172 
00173 
00174         OtlId() : otl_value<long>() {}
00176         OtlId(const otl_null& rhs) : otl_value<long>(rhs) {}
00178 
00182         template <typename T>
00183         explicit OtlId(const OSB_LIB::Id<T>& rhs)
00184           : otl_value<long>(rhs.id())
00185         {
00186             if (rhs.notSet()) set_null();
00187         }
00192         long id() const
00193         {
00194             return is_null() ? nvl() : v;
00195         }
00199         static long nvl()
00200         {
00201             return OSB_LIB::ID_NOT_SET;
00202         }
00203     };                                  // class OtlId
00204 
00212     class OtlId2 {
00213     public:
00215 
00216 
00217         template <typename T>
00218         explicit OtlId2(const OSB_LIB::Id2<T>& id)
00219           : id1_(id.id1_), id2_(id.id2_)
00220         {
00221             if (OSB_LIB::ID_NOT_SET == id1_.v) id1_.set_null();
00222             if (OSB_LIB::ID_NOT_SET == id2_.v) id2_.set_null();
00223         }
00225 
00227 
00228 
00229         OtlId2() : id1_(OSB_LIB::ID_NOT_SET),
00230                    id2_(OSB_LIB::ID_NOT_SET)
00231         {
00232             id1_.set_null();
00233             id2_.set_null();
00234         }
00240         long id1() const
00241         {
00242             return id1_.is_null() ? nvl() : id1_.v;
00243         }
00249         long id2() const
00250         {
00251             return id2_.is_null() ? nvl() : id2_.v;
00252         }
00254 
00257         static long nvl()
00258         {
00259             return OSB_LIB::ID_NOT_SET;
00260         }
00261     public:
00267         otl_value<long> id1_;
00273         otl_value<long> id2_;
00274     };
00275 
00284     class OtlDateTime : public otl_value<otl_datetime> {
00285     public:
00287 
00288 
00289         OtlDateTime() : otl_value<otl_datetime>() {}
00291         OtlDateTime(const otl_value<otl_datetime>& rhs)
00292             : otl_value<otl_datetime>(rhs) {}
00294         OtlDateTime(const otl_datetime& rhs)
00295             : otl_value<otl_datetime>(rhs) {}
00297         OtlDateTime(const otl_null& rhs)
00298             : otl_value<otl_datetime>(rhs) {}
00300 
00301 
00302 
00306         OtlDateTime(const OSB_LIB::Date&);
00311         OtlDateTime(const OSB_LIB::DateTime&);
00313 
00314 
00315 
00316         OSB_LIB::Date date() const;
00318         OSB_LIB::DateTime dateTime() const;
00320     };                                  // class OtlDateTime
00321 }
00322 
00323 #endif                                  // #ifndef _OSBOTL_H_

Generated on Sat Sep 2 14:06:33 2006 for OSB Library by  doxygen 1.4.7