sumcdr.h

Go to the documentation of this file.
00001 // OSB library ********************************************* -*- C++ -*-
00006 /*
00007   AUTHOR(S): Tang Boon Leong (tbl)
00008 
00009   RCS information
00010    $Name: OSB_060808 $
00011    $Revision: 1.34 $
00012 
00013   License
00014    OSB rating and billing library for communication networks
00015    Copyright (C) 2004, 2005, 2006  OSB systems
00016 
00017    This file may be distributed and/or modify under the terms of the
00018    GNU General Public License (GPL) as published by the Free Software
00019    Foundation which is provided in the file LICENSE.GPL included in the
00020    packaging of this file.
00021 
00022    The file is distributed in the hope that it will be useful, but WITHOUT
00023    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00024    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00025    for more details.
00026 
00027    Holders of a OSB Commercial License may use this file under the terms
00028    and conditions of this commercial license.
00029  */
00030 #ifndef _SUMCDR_H_
00031 #define _SUMCDR_H_
00032 
00033 // *********************************************************************
00034 // included header files
00035 // + standard includes
00036 
00037 // + local headers
00038 #include "cdr.h"
00039 
00040 // *********************************************************************
00041 // class declarations
00042 namespace OSB_DB {
00043     class SumCdr01Gw;
00044 }
00045 
00046 namespace OSB_LIB {
00047     class SumCdrList;
00048     class BsPage;
00049     template<typename T> class Id;
00050 }
00051 
00052 // *********************************************************************
00053 // namespace extensions
00054 namespace OSB_LIB {
00055 
00056 // *********************************************************************
00057 // type definitions
00058 
00059 // *********************************************************************
00060 // class definitions
00061 
00062     // *****************************************************************
00063     // class SumCdr
00071     class SumCdr : public Udr {
00072     public:
00074         typedef Id<SumCdr> Oid;
00075 
00077         SumCdr() {}
00078 
00088         SumCdr(
00089             const Id<BsPage>&  page,
00090             const Cdr&         cdr,
00091             const UsedService& us
00092         );
00093 
00101         virtual void add(Cdr& cdr) = 0;
00102 
00111         virtual bool match(
00112             const Cdr&         cdr,
00113             const UsedService& us
00114         ) const;
00115 
00140         virtual
00141         void insert(const OSB_DB::Session& session) = 0;
00142 
00161         virtual
00162         bool update(const OSB_DB::Session& session) = 0;
00164 
00165     protected:
00172         void addMoneyInfoList(
00173             const MoneyInfoList& usMoney,
00174                   MoneyInfoList& sumMoney
00175         );
00176 
00182         void addUsedServiceToSumCdr(
00183             const UsedService& us
00184         );
00185 
00186     public:
00188         Oid oid_;
00189 
00191         Id<BsPage> pageId_;
00192 
00194         Id2<TfVersion> flatTfId_;
00195 
00197         Id2<TfVersion> massTfId_;
00198 
00200         ChargeDetails chargeDetails_;
00201     };
00202 
00203     // *****************************************************************
00204     // class SumCdr01
00208     class SumCdr01 : public SumCdr {
00209 
00211         static const Udr::UdrType type_ = Udr::sumcdr01;
00212 
00214         friend class SumCdr01Gw;
00215 
00216     public:
00218         SumCdr01() : numCdrs_(0) {}
00219 
00227         SumCdr01(
00228             const Id<BsPage>&  page,
00229             const Cdr&         cdr,
00230             const UsedService& us
00231         );
00232 
00234         UdrType udrType() const;
00235 
00237         struct GroupingInfo {
00239             GroupingInfo() {};
00241             GroupingInfo(const Cdr& cdr, const UsedService& us);
00243             bool operator==(const GroupingInfo& rhs) const;
00245             bool match(const Cdr& cdr, const UsedService& us) const;
00246 
00247             Id<PersProduct>  persProduct_;  
00248 
00250             DateTime         from_;
00252             DateTime         to_;
00253 
00254             Id<TariffZone>   tariffZone_;   
00255             Id<TariffPeriod> tariffPeriod_; 
00256             Id<TariffClass>  tariffClass_;  
00257 
00258             Id<ConnectionPt> ratedOrigin_;  
00259             Id<ConnectionPt> ratedDest_;    
00260 
00262             std::string         inTrunkGroup_;
00264             std::string         outTrunkGroup_;
00266             Id2<NetworkElement> networkElement_;
00267         };
00268 
00269         // Documentation from base class.
00270         void add(Cdr& cdr);
00271 
00272         // Documentation from base class.
00273         bool match(
00274             const Cdr&         cdr,
00275             const UsedService& us
00276         ) const;
00277 
00278     private:
00280 
00281         // Documentation from base class.
00282         virtual
00283         void insert(const OSB_DB::Session& session);
00284 
00285         // Documentation from base class.
00286         virtual
00287         bool update(const OSB_DB::Session& session);
00289 
00290     public:
00292         long numCdrs_;
00293 
00295         GroupingInfo groupingInfo_;
00296     };
00297 
00298     // *****************************************************************
00299     // class SumCdr01Key
00306     class SumCdr01Key {
00307     public:
00309         SumCdr01Key(
00310             Id<ConnectionPt> a,
00311             Id<TariffPeriod> b,
00312             Id2<TfVersion>   c,
00313             Id2<TfVersion>   d
00314         ) : destinationId_(a),  tariffPeriodId_(b),
00315             flatTfId_(c), massTfId_(d) {}
00316 
00317         bool operator==(const SumCdr01Key&) const;
00318         bool operator!=(const SumCdr01Key&) const;
00319         bool operator< (const SumCdr01Key&) const;
00320         bool operator> (const SumCdr01Key&) const;
00321         bool operator<=(const SumCdr01Key&) const;
00322         bool operator>=(const SumCdr01Key&) const;
00323 
00324         Id<ConnectionPt> destinationId_;
00325         Id<TariffPeriod> tariffPeriodId_;
00326         Id2<TfVersion> flatTfId_;
00327         Id2<TfVersion> massTfId_;
00328     };
00329 
00330     typedef std::map<SumCdr01Key, SumCdr01> GroupedSumCdr01;
00331 
00341     void groupSumCdr01(
00342         const SumCdrList&      source,
00343               GroupedSumCdr01& target
00344     );
00345 
00346     // *****************************************************************
00347     // class SumCdrList
00356     class SumCdrList {
00357     public:
00359         typedef std::list<SumCdr*> List;
00360 
00362         virtual ~SumCdrList() { this->clear(); }
00363 
00365 
00366 
00367         typedef List::iterator Iterator;
00369         typedef List::const_iterator ConstIterator;
00371         typedef List::size_type SizeType;
00373 
00383 
00384         virtual Iterator begin() { return list_.begin(); }
00386         virtual Iterator end() { return list_.end(); }
00388         virtual ConstIterator begin() const { return list_.begin(); }
00390         virtual ConstIterator end() const { return list_.end(); }
00392         virtual SizeType size() const { return list_.size(); }
00394 
00401         virtual List& usageList() { return list_; }
00402 
00404         virtual const List& list() const { return list_; }
00405 
00413         virtual void add(
00414             const Cdr&        cdr,
00415             const Id<BsPage>& pageId
00416         ) = 0;
00417 
00425         virtual long read(
00426             const OSB_DB::Session& session,
00427             const Id<BsPage>&      pageId
00428         ) = 0;
00429 
00440         virtual void remove(
00441             const OSB_DB::Session& session,
00442             const Id<BsPage>&      pageId
00443         ) = 0;
00444 
00450         virtual void save(
00451             const OSB_DB::Session& session
00452         );
00453 
00455         void clear();
00456 
00457     protected:
00459         List list_;
00460     };
00461 
00462     // *****************************************************************
00463     // class SumCdr01List
00468     class SumCdr01List : public SumCdrList {
00469     public:
00471         SumCdr01List() {}
00472 
00474         SumCdr01List(const SumCdr01List& rhs);
00475 
00477         SumCdr01List& operator=(const SumCdr01List& rhs);
00478 
00486         virtual void add(
00487             const Cdr&        cdr,
00488             const Id<BsPage>& pageId
00489         );
00490 
00491         // Documentation from base class.
00492         virtual long read(
00493             const OSB_DB::Session& session,
00494             const Id<BsPage>&      pageId
00495         );
00496 
00497         // Documentation from base class.
00498         virtual void remove(
00499             const OSB_DB::Session& session,
00500             const Id<BsPage>&      pageId
00501         );
00502 
00503     };
00504 }                                       // namespace OSB_LIB
00505 #endif                                  // #ifndef _SUMCDR_H_
00506 

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