cpmapper.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.34 $
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 _CPMAPPER_H_
00039 #define _CPMAPPER_H_
00040 
00041 // *********************************************************************
00042 // included header files
00043 // + standard includes
00044 #include <memory>
00045 #include <string>
00046 #include <vector>
00047 #include <list>
00048 
00049 // + local headers
00050 #include "osbid.h"
00051 #include "osbtype.h"
00052 #include "chrono.h"
00053 
00054 // + class declarations
00055 namespace OSB_LIB {
00056     template<typename T> class Id;
00057     class Cdr;
00058     class UsedService;
00059     class TariffCatalogue;
00060     class ConnectionPt;
00061 }
00062 
00063 namespace OSB_DB {
00064     class Session;
00065 }
00066 
00067 // ************************************************************************
00068 // namespace extensions
00069 namespace OSB_LIB {
00070 
00071 // *********************************************************************
00072 // class definitions
00073 
00074     // *****************************************************************
00075     // class CpMapper
00079     class CpMapper {
00080     public:
00082         typedef TypeId<CpMapper> Type;
00095         enum CpmType {
00096             cpmCgi           = 1,       
00097             cpmCalledParty   = 2,       
00098             cpmCallingParty  = 3,       
00099             cpmNetwork       = 4,       
00100             cpmNwElement     = 5,       
00101             cpmMsrn          = 6,       
00102             cpmServedParty   = 7        
00103             // if you add here: change cpmMax below!
00104         };
00106         static const CpmType cpmMax_ = cpmServedParty;
00107 
00114         typedef std::auto_ptr<CpMapper> AutoPtr;
00115 
00116     public:
00118         virtual ~CpMapper() {}
00119 
00125         AutoPtr clone() const;
00126 
00138         virtual Id<ConnectionPt> map2Cp(Cdr& cdr) const = 0;
00139 
00141         virtual Type type() const = 0;
00148         CpmType cpmType() const;
00149     public:
00151         static CpmType cpmType(const Type& type);
00152     private:
00158         virtual CpMapper* clone_() const = 0;
00159     };
00160 
00161     // *****************************************************************
00162     // class CpMapperList
00169     class CpMapperList {
00170     public:
00172         struct Info {
00173             CpMapper::Type type_;       
00174             std::string    name_;       
00175             std::string    des_;        
00176         };
00177 
00179         typedef std::vector<Info> InfoList;
00181         typedef InfoList::const_iterator ConstIterator;
00182 
00193         long read(const OSB_DB::Session& session);
00194 
00196         ConstIterator begin() const { return infoList_.begin(); }
00198         ConstIterator end() const { return infoList_.end(); }
00200         const InfoList& infoList() const { return infoList_; }
00201 
00210         const Info* findInfo(CpMapper::Type type) const;
00211 
00219         const Info* findInfo(const std::string& name) const;
00220 
00228         const Info& getInfo(CpMapper::Type type) const;
00229 
00237         const Info& getInfo(const std::string& name) const;
00238 
00239     private:
00240         InfoList infoList_;             
00241 
00243         Info* find(CpMapper::Type type);
00245         Info* find(const std::string& name);
00246     };
00247 
00248     // *****************************************************************
00249     // class CpMapperFactory
00263     class CpMapperFactory {
00264     private:
00266         CpMapperFactory();
00268         ~CpMapperFactory();
00270         CpMapperFactory(const CpMapperFactory&);
00272         CpMapperFactory& operator=(CpMapperFactory&);
00273     public:
00293         static CpMapper::AutoPtr mkCpMapper(
00294             CpMapper::Type type
00295         );
00296     };
00297 
00298     // *****************************************************************
00299     // struct MappedCp
00312     struct MappedCp {
00313         Id<ConnectionPt> cpId_;          
00314         DateTime         cpStart_;       
00315         DateTime         cpEnd_;         
00316 
00318         MappedCp();
00320         MappedCp(const ConnectionPt& cp);
00329 //        MappedCp& operator=(const ConnectionPt& cp);
00330 
00345         bool withinPeriod(const DateTime& ts) const;
00346     };
00347 
00348     // *****************************************************************
00349     // MappedPartInfo
00354     class MappedPartInfo {
00358         friend class MappedPartInfoList;
00359 
00360     public:
00368         MappedPartInfo(
00369             const ConnectionPt& cp,
00370             const DateTime&     startTs,
00371             const DateTime&     endTs
00372         );
00373 
00386         bool withinPeriod(const DateTime& ts) const;
00387 
00389         void print(std::ostream& os, std::string spacer) const;
00390 
00391     private:
00393         MappedCp mappedCp_;
00395         DateTime startTs_;
00397         DateTime endTs_;
00398     };
00399 
00400     // *****************************************************************
00401     // MappedPartInfoList
00409     class MappedPartInfoList {
00410     public:
00412         typedef std::list<MappedPartInfo> MappedPartInfos;
00413 
00415         std::list<MappedPartInfo> mappedInfo_;
00416 
00425         void add(const MappedPartInfo& info);
00426 
00437         void map2Cp(Id<ConnectionPt>& cpId, const DateTime& ts) const;
00438 
00440         void print(std::ostream& os, std::string spacer) const;
00441     };
00442 }                                       // namespace OSB_LIB
00443 #endif                                  // #ifndef _CPMAPPER_H_

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