tariffsystem.h

Go to the documentation of this file.
00001 // OSB library ********************************************* -*- C++ -*-
00006 /*
00007   AUTHOR(S): Wang Peng (wp)
00008               Stephan Broennimann (vb)
00009 
00010   RCS information
00011    $Name: OSB_060808 $
00012    $Revision: 1.171 $
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 _TARIFFSYSTEM_H_
00032 #define _TARIFFSYSTEM_H_
00033 
00034 // *********************************************************************
00035 // included header files
00036 // + standard includes
00037 #include <list>
00038 #include <utility>
00039 #include <map>
00040 #include <vector>
00041 #include <memory>
00042 
00043 // + local headers
00044 #include "tariffobject.h"
00045 #include "tariff.h"
00046 #include "tariffclass.h"
00047 #include "tariffperiod.h"
00048 #include "serviceclass.h"
00049 #include "osbid.h"
00050 #include "chrono.h"
00051 
00052 // *********************************************************************
00053 // class declarations
00054 namespace OSB_DB {
00055     class Session;
00056     class TariffSystemGw;
00057     struct TsVersionGw;
00058 }
00059 
00060 namespace OSB_LIB {
00061     class Unit;
00062     class Cdr;
00063 }
00064 
00065 // *********************************************************************
00066 // namespace extensions
00067 namespace OSB_LIB {
00068 
00069 // ************************************************************************
00070 // forward declarations
00071     class TsVersion;
00072 
00073 // ************************************************************************
00074 // class definitions
00075 
00076     // *****************************************************************
00077     // TariffSystem
00085     class TariffSystem : public TariffObject {
00090         friend class OSB_DB::TariffSystemGw;
00091 
00093         friend class TariffCatalogue;
00094 
00095     public:
00097         typedef Id<TariffSystem> Oid;
00098 
00100         struct AuthenType {
00101             AuthenType()
00102               : status(1), volume(0)
00103             {
00104                 // empty body
00105             }
00106 
00108             long status;
00110             TypeId<Unit> unitId;
00112             Decimal volume;
00113         };
00114 
00115     public:
00117         explicit TariffSystem(const Oid& oid = Oid());
00118     public:
00120         const Oid& oid() const;
00138         const AuthenType rate(
00139                   Cdr&   cdr,
00140             const Money& money
00141         );
00142 
00156         void rate(Cdr& cdr);
00157 
00167         bool getTariffInfo(
00168                   Cdr&         cdr,
00169                   UsedService& us,
00170             const TsVersion&   tsVs
00171         );
00172 
00182         bool read(const OSB_DB::Session& session);
00183 
00184     private:
00186 
00187 
00200         bool insert(const OSB_DB::Session& session);
00201 
00216         bool update(const OSB_DB::Session& session);
00217 
00232         bool remove(const OSB_DB::Session& session);
00234 
00235     private:
00237         Oid oid_;
00238     };                                  // TariffSystem
00239 
00241     typedef std::list<TariffSystem> TariffSystems;
00242 
00247     typedef std::map<ServiceClass::Oid, TcSystem::Oid> ScTcsCfg;
00248 
00253     typedef std::map<TariffClass::Oid, TpSystem::Oid> TcTpsCfg;
00254 
00256     typedef std::pair<TariffClass::Oid, TariffPeriod::Oid> TcTp;
00257 
00259     typedef std::map<TcTp, Tariff::Oid> TcTpTariff;
00260 
00261     // *****************************************************************
00262     // Tariff system version
00272     class TsVersion : public ToVersion {
00276         friend struct OSB_DB::TsVersionGw;
00278         friend class TariffCatalogue;
00279     public:
00281         enum RatingType {
00286             flatRating  = 1,
00292             sumRating     = 2,
00294             unknownRating = -1
00295         };
00296 
00301         typedef Id2<TsVersion> Oid;
00306         typedef Id<ScSystem> ScsOid;
00307     public:
00312         static long rtToLong(const RatingType type);
00317         static RatingType longToRt(const long type);
00318     public:
00320         explicit TsVersion(
00321             const Oid&       oid  = Oid(),
00322                   RatingType type = flatRating
00323         );
00325         explicit TsVersion(
00326             const TariffSystem::Oid& tsId,
00327                   RatingType         type = flatRating
00328         );
00329     public:
00331         const Oid& oid() const;
00333         TariffSystem::Oid tsId() const;
00335         RatingType ratingType() const;
00336 
00338 
00339 
00340         const ScsOid& scsId() const;
00342         const ScTcsCfg& scTcsCfg() const;
00344         const TcTpsCfg& tcTpsCfg() const;
00346         const TcTpTariff& tcTpFlatTariff() const;
00348         const TcTpTariff& tcTpMassTariff() const;
00350 
00352 
00353 
00359         const TcSystem::Oid&
00360         getTcSystem(const ServiceClass::Oid& scId) const;
00361 
00368         const TpSystem::Oid&
00369         getTpSystem(const TariffClass::Oid& tcId) const;
00370 
00379         const Tariff::Oid& getFlatTariff(
00380             const TariffClass::Oid&  tcId,
00381             const TariffPeriod::Oid& tpId
00382         ) const;
00383 
00392         const Tariff::Oid& getMassTariff(
00393             const TariffClass::Oid&  tcId,
00394             const TariffPeriod::Oid& tpId
00395         ) const;
00397 
00399 
00400 
00409         void getSupportedScOid(
00410             std::set<ServiceClass::Oid>& scOids
00411         ) const;
00420         void getSupportedTcOid(
00421             std::set<TariffClass::Oid>& tcOids
00422         ) const;
00431         void getSupportedTpOid(
00432             std::set<TariffPeriod::Oid>& tpOids
00433         ) const;
00440         void getSupportedTcTpOid(std::set<TcTp>& tcTpOids) const;
00442 
00444 
00445 
00456         void copyCfg(const TsVersion& src);
00457 
00471         void setRatingType(const RatingType rt);
00482         void setScsId(const ScsOid& scsId);
00483 
00496         void setScTcsCfg(
00497             const ScTcsCfg& scTcsCfg
00498         );
00499 
00514         void setScTcsCfg(
00515             const ServiceClass::Oid& scId,
00516             const TcSystem::Oid&     tcsId
00517         );
00518 
00531         void setTcTpsCfg(
00532             const TcTpsCfg& tcTpsCfg
00533         );
00534 
00549         void setTcTpsCfg(
00550             const TariffClass::Oid& tcOid,
00551             const TpSystem::Oid&    tpsOid
00552         );
00553 
00569         void setFlatTariff(const TcTpTariff& flatTf);
00584         void setTcTpFlatTariff(
00585             const TcTp&        tcTp,
00586             const Tariff::Oid& tariffOid
00587         );
00588 
00604         void setMassTariff(const TcTpTariff& massTf);
00619         void setTcTpMassTariff(
00620             const TcTp&        tcTp,
00621             const Tariff::Oid& tariffOid
00622         );
00624 
00626 
00627 
00636         bool read(const OSB_DB::Session& session);
00637 
00638     private:
00652         bool insert(const OSB_DB::Session& session);
00653 
00668         bool update(const OSB_DB::Session& session);
00669 
00684         bool remove(const OSB_DB::Session& session);
00686 
00688 
00689 
00718         bool freeze(
00719             const OSB_DB::Session& session,
00720                   OsbErrors&       errors
00721         );
00722 
00742         bool release(
00743             const OSB_DB::Session& session,
00744                   OsbErrors&       errors
00745         );
00746 
00765         bool revoke(
00766             const OSB_DB::Session& session,
00767                   OsbErrors&       errors
00768         );
00769 
00782         bool unfreeze(
00783             const OSB_DB::Session& session,
00784                   OsbErrors&       errors
00785         );
00787 
00789         void repopulateScTcsConfig();
00791         void repopulateTcTpsConfig();
00793         void repopulateTcTpFlatTariff();
00795         void repopulateTcTpMassTariff();
00796 
00797     private:
00799         Oid         oid_;
00801         ScsOid      scsOid_;
00803         RatingType  ratingType_;
00805         ScTcsCfg    scTcsCfg_;
00807         TcTpsCfg    tcTpsCfg_;
00809         TcTpTariff  tcTpFlatTariff_;
00811         TcTpTariff  tcTpMassTariff_;
00812     };                                  // TsVersion
00813 
00815     typedef std::list<TsVersion> TsVersions;
00816 }                                       // namespace OSB_LIB
00817 #endif                                  // #ifndef _TARIFFSYSTEM_H_

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