cgi.h

Go to the documentation of this file.
00001 // OSB library ********************************************* -*- C++ -*-
00014 /*
00015   AUTHOR(S): Stephan Broennimann (vb)
00016 
00017   RCS information
00018    $Name: OSB_060808 $
00019    $Revision: 1.37 $
00020 
00021   License
00022    OSB rating and billing library for communication networks
00023    Copyright (C) 2004, 2005, 2006  OSB systems
00024 
00025    This file may be distributed and/or modify under the terms of the
00026    GNU General Public License (GPL) as published by the Free Software
00027    Foundation which is provided in the file LICENSE.GPL included in the
00028    packaging of this file.
00029 
00030    The file is distributed in the hope that it will be useful, but WITHOUT
00031    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00032    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00033    for more details.
00034 
00035    Holders of a OSB Commercial License may use this file under the terms
00036    and conditions of this commercial license.
00037  */
00038 #ifndef _OSB_CGI_H_
00039 #define _OSB_CGI_H_
00040 
00041 // *********************************************************************
00042 // included header files
00043 // + standard includes
00044 #include <iosfwd>
00045 #include <string>
00046 #include <list>
00047 #include <map>
00048 
00049 // + local headers
00050 #include "osbid.h"
00051 #include "osbconst.h"
00052 #include "cpmapper.h"
00053 
00054 // + class declarations
00055 namespace OSB_DB {
00056     struct CgiGw;
00057 }
00058 
00059 namespace OSB_LIB {
00060     class ConnectionPt;
00061     class OsbErrors;
00062 }
00063 
00064 // ************************************************************************
00065 // namespace extensions
00066 namespace OSB_LIB {
00067 
00068 // *********************************************************************
00069 // class forward declarations
00070 
00071 // *********************************************************************
00072 // class definitions
00073 
00074     // *****************************************************************
00075     // Cgi
00093     class Cgi {
00097         friend struct OSB_DB::CgiGw;
00098 
00103         friend class TariffCatalogue;
00104     public:
00106         typedef Id<Cgi> Oid;
00107 
00109         typedef Id<ConnectionPt> CpId;
00110 
00112         Cgi() : objVs_() {};
00113 
00130         Cgi(const Oid&         oid,
00131             const long         objVs,
00132             const std::string& name,
00133             const std::string& val,
00134             const CpId&        cpId
00135         );
00136 
00138 
00139 
00140         const Oid& oid() const { return oid_; }
00141 
00143         const CpId& cpId() const { return cpId_; }
00144 
00146         long objVs() const { return objVs_; }
00147 
00149         const std::string& name() const { return name_; }
00150 
00152         const std::string& value() const { return value_; }
00153 
00155         const CfgStatus& status() const { return status_; }
00156 
00158         const Date& startDate() const { return startDate_; }
00159 
00161         const Date& endDate() const { return endDate_; }
00163 
00173         static bool validate(
00174             const std::string& value
00175         );
00176 
00184         bool validate() const;
00185 
00187 
00188 
00189         static std::string mcc(const std::string& value);
00191         static std::string mnc(const std::string& value);
00193         static std::string lac(const std::string& value);
00195         static std::string ci(const std::string& valule);
00197 
00199 
00200 
00201         std::string mcc() const;
00203         std::string mnc() const;
00205         std::string lac() const;
00207         std::string ci() const;
00209 
00217         bool setName(const std::string& newName);
00218 
00232         bool setValue(const std::string& newValue);
00233 
00244         bool setCpId(const CpId& id);
00245 
00251         void setStartDate(const Date& sDate);
00252 
00258         void setEndDate(const Date& eDate);
00259 
00261         static const std::string catchall;
00262 
00264 
00265 
00274         bool read(const OSB_DB::Session& session);
00275 
00276     private:
00289         bool insert(const OSB_DB::Session& session);
00290 
00307         bool remove(const OSB_DB::Session& session);
00308 
00322         bool update(const OSB_DB::Session& session);
00324 
00326 
00327 
00340         bool check(
00341             const OSB_DB::Session& session,
00342                   OsbErrors&       errors
00343         );
00344 
00359         bool release(
00360             const OSB_DB::Session& session,
00361                   OsbErrors&       errors
00362         );
00363 
00376         bool revoke(
00377             const OSB_DB::Session& session,
00378                   OsbErrors&       errors
00379         );
00380 
00392         bool unfreeze(
00393             const OSB_DB::Session& session,
00394                   OsbErrors&       errors
00395         );
00397 
00398     private:
00399         Oid         oid_;         
00400         long        objVs_;       
00401         std::string name_;        
00402         std::string value_;       
00403         CpId        cpId_;        
00404         CfgStatus   status_;      
00405         Date        startDate_;   
00406         Date        endDate_;     
00407     };
00408 
00410     typedef std::list<Cgi> Cgis;
00411 
00412     // *****************************************************************
00413     // CgiToCp
00420     class CgiToCp : public CpMapper {
00422         static const CpmType cpmType_ = cpmCgi;
00423         // Documentation from base class.
00424         typedef std::auto_ptr<CgiToCp> AutoPtr;
00425     public:
00426         // Documentation from base class.
00427         AutoPtr clone() const;
00428 
00430         Type type() const { return Type(cpmType_); }
00431 
00443         virtual Id<ConnectionPt> map2Cp(Cdr& cdr) const;
00444     private:
00445         // Documentation from base class.
00446         virtual CpMapper* clone_() const;
00447     };
00448 
00449     // *****************************************************************
00450     // CgiMap
00459     class CgiMap {
00467         friend class TariffCatalogue;
00468 
00470 
00471         struct Ci;
00472         struct Lac;
00473         struct Mnc;
00474         struct Mcc;
00475         friend struct Ci;
00476         friend struct Lac;
00477         friend struct Mnc;
00478         friend struct Mcc;
00480     public:
00486         CgiMap();
00487 
00500         void build(const TariffCatalogue& tcat);
00501 
00508         Id<ConnectionPt> map2Cp(
00509             const std::string& cgi,
00510             const DateTime&    ts
00511         ) const;
00512 
00514         void print(std::ostream& os, std::string spacer) const;
00515 
00516     private:
00518         typedef Id<ConnectionPt> CpId;
00519 
00521         struct Ci {
00523             std::string        ci_;
00525             MappedPartInfoList mappedPartInfoList_;
00527             void map2Cp(
00528                       CpId&     id,
00529                 const DateTime& ts
00530             ) const;
00532             void print(std::ostream& os, std::string spacer) const;
00533         };
00535         typedef std::map<std::string, Ci> Cis;
00536 
00538         struct Lac {
00540             std::string        lac_;
00542             MappedPartInfoList mappedPartInfoList_;
00544             Cis         cis_;
00546             void add(
00547                 const Cgi&          cgi,
00548                 const std::string&  ci,
00549                 const ConnectionPt& cp
00550             );
00559             void map2Cp(
00560                       CpId&        id,
00561                 const std::string& cgi,
00562                 const DateTime&    ts
00563             ) const;
00565             void print(std::ostream& os, std::string spacer) const;
00566         };
00568         typedef std::map<std::string, Lac> Lacs;
00569 
00571         struct Mnc {
00573             std::string mnc_;
00575             MappedPartInfoList mappedPartInfoList_;
00577             Lacs        lacs_;
00579             void add(
00580                 const Cgi&          cgi,
00581                 const std::string&  lac,
00582                 const ConnectionPt& cp
00583             );
00592             void map2Cp(
00593                       CpId&        id,
00594                 const std::string& cgi,
00595                 const DateTime&    ts
00596             ) const;
00598             void print(std::ostream& os, std::string spacer) const;
00599         };
00601         typedef std::map<std::string, Mnc> Mncs;
00602 
00604         struct Mcc {
00606             std::string mcc_;
00608             MappedPartInfoList mappedPartInfoList_;
00610             Mncs        mncs_;
00612             void add(
00613                 const Cgi&          cgi,
00614                 const std::string&  mnc,
00615                 const ConnectionPt& cp
00616             );
00625             void map2Cp(
00626                       CpId&        id,
00627                 const std::string& cgi,
00628                 const DateTime&    ts
00629             ) const;
00631             void print(std::ostream& os, std::string spacer) const;
00632         };
00634         typedef std::map<std::string, Mcc> Mccs;
00635 
00636     private:
00637         Mccs        mccs_;              
00638         MappedCp    catchall_;          
00639 
00650         bool        needBuild_;
00651 
00653         void add(const Cgi& cgi, const ConnectionPt& cp);
00654     };
00655 }                                       // namespace OSB_LIB
00656 #endif                                  // #ifndef _OSB_CGI_H_

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