service.h

Go to the documentation of this file.
00001 // OSB library ********************************************* -*- C++ -*-
00006 /*
00007   AUTHOR(S): Tang Boon Leong (tbl)
00008              Stephan Broennimann (vb)
00009 
00010   RCS information
00011    $Name: OSB_060808 $
00012    $Revision: 1.73 $
00013 
00014   License
00015    OSB rating and billing library for communication networks
00016    Copyright (C) 2004, 2005, 2006  OSB systems
00017 
00018    This file may be distributed and/or modify under the terms of the
00019    GNU General Public License (GPL) as published by the Free Software
00020    Foundation which is provided in the file LICENSE.GPL included in the
00021    packaging of this file.
00022 
00023    The file is distributed in the hope that it will be useful, but WITHOUT
00024    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00025    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00026    for more details.
00027 
00028    Holders of a OSB Commercial License may use this file under the terms
00029    and conditions of this commercial license.
00030  */
00031 #ifndef _SERVICE_H_
00032 #define _SERVICE_H_
00033 
00034 // *********************************************************************
00035 // included header files
00036 // + standard includes
00037 #include <map>
00038 #include <set>
00039 #include <vector>
00040 
00041 // + local headers
00042 #include "osbid.h"
00043 
00044 // + class declarations
00045 namespace OSB_DB {
00046     class  Session;
00047     struct ServiceElementGw;
00048 }
00049 
00050 // ************************************************************************
00051 // namespace extensions
00052 namespace OSB_LIB {
00053 
00054 // *********************************************************************
00055 // class definitions
00056 
00057     // *****************************************************************
00058     // class ServiceElement
00065     class ServiceElement {
00070         friend struct OSB_DB::ServiceElementGw;
00071     public:
00073         typedef Id<ServiceElement> Oid;
00074 
00076         typedef unsigned char ServiceCode;
00077 
00084         enum ServiceType {
00085             stUnknown        = '?',
00086             gsmTelephony     = 'T',     
00087             gsmBearer        = 'B',     
00088             gsmSupplementary = 'S',     
00089             pstnTelephony    = 'P',     
00090             isdnTelephony    = 'I',     
00091             stMax            = 0xff
00092         };
00093 
00101         ServiceElement();
00102 
00114         ServiceElement(
00115             const Oid&        oid,
00116                   ServiceType type,
00117                   ServiceCode code,
00118             const Oid         pid
00119         );
00120 
00130         ServiceElement(
00131             ServiceType type,
00132             ServiceCode code
00133         );
00134 
00136 
00137 
00144         static char toChar(const ServiceType st);
00145 
00159         static ServiceType toServiceType(char c);
00160 
00170         static std::string toHex(ServiceCode c);
00172 
00174 
00175 
00176         const Oid& oid() const;
00177 
00179         const ServiceType& serviceType() const;
00180 
00182         const ServiceCode& serviceCode() const;
00183 
00185         const Oid& pId() const;
00187 
00197         const std::string shortCode() const;
00198 
00200 
00201 
00209         bool read(const OSB_DB::Session& session);
00210 
00220         bool insert(const OSB_DB::Session& session);
00221 
00230         bool update(const OSB_DB::Session& session);
00231 
00241         bool remove(const OSB_DB::Session& session);
00243 
00245 
00246 
00254         bool operator==(const ServiceElement& se) const;
00255 
00261         bool operator<(const ServiceElement& rhs) const;
00263 
00264     private:
00266         Oid id_;
00267 
00269         ServiceType serviceType_;
00270 
00275         ServiceCode serviceCode_;
00276 
00278         Oid pId_;
00279     };
00280 
00284     typedef std::vector<ServiceElement> ServiceElements;
00285 
00286     // *****************************************************************
00287     // SeTree
00295     class SeTree {
00296     public:
00298         typedef std::map<ServiceElement::Oid, ServiceElement> Elements;
00299     private:
00301         typedef std::set<ServiceElement> SeList;
00302     public:
00308         void read(const OSB_DB::Session& session);
00309 
00311         const Elements& elements() const;
00312 
00320         const ServiceElement* findServiceElement(
00321             const ServiceElement& se
00322         ) const;
00323 
00331         const ServiceElement* findServiceElement(
00332             const ServiceElement::Oid& seId
00333         ) const;
00334 
00343         const ServiceElement& getServiceElement(
00344             const ServiceElement::Oid& seId
00345         ) const;
00346 
00347     private:
00349         Elements elements_;
00351         SeList seList_;
00352     };
00353 
00354     // *****************************************************************
00355     // ServiceTuple
00364     class ServiceTuple {
00365     public:
00367         ServiceTuple();
00368 
00375         explicit ServiceTuple(
00376             const ServiceElements& ses
00377         );
00378 
00387         explicit ServiceTuple(
00388             const ServiceElement& se
00389         );
00390 
00403         ServiceTuple(
00404             ServiceElement::ServiceType type,
00405             ServiceElement::ServiceCode code
00406         );
00407 
00414         bool operator==(const ServiceTuple& rhs) const;
00415 
00417 
00418 
00419         const ServiceElements& serviceElements() const;
00421     private:
00426         ServiceElements serviceElements_;
00427     };
00428 }                                       // namespace OSB_LIB
00429 #endif                                  // #ifndef _SERVICE_H_

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