tariff.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.43 $
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 _TARIFF_H_
00031 #define _TARIFF_H_
00032 
00033 // *********************************************************************
00034 // included header files
00035 // + standard includes
00036 #include <string>
00037 #include <list>
00038 
00039 // + local headers
00040 #include "tariffobject.h"
00041 #include "ratingfn.h"
00042 #include "serviceclass.h"
00043 
00044 // *********************************************************************
00045 // class declarations
00046 namespace OSB_DB {
00047     class  RateCodeGw;
00048     struct TariffGw;
00049     struct TfVersionGw;
00050     class  TariffSystemGw;
00051 }
00052 
00053 namespace OSB_LIB {
00054     class SumCdr;
00055 }
00056 
00057 // ************************************************************************
00058 // namespace extensions
00059 namespace OSB_LIB {
00060 
00061 
00062 // *********************************************************************
00063 // type definitions
00064 
00065 // *********************************************************************
00066 // class definitions
00067 
00068     // ********************************************************************
00069     // class RateCode
00077     class RateCode : public TariffObject {
00079         friend class OSB_DB::RateCodeGw;
00080     public:
00082         typedef Id<RateCode> Oid;
00083     public:
00085         explicit RateCode(const Oid& oid = Oid());
00086     public:
00088         const Oid& oid() const;
00090         const std::string& mnemonic() const;
00097         void setMnemonic(const std::string& mnemonic);
00098     private:
00100         Oid oid_;
00102         std::string mnemonic_;
00103     };                                  // class RateCode
00104 
00108     class RateCodes {
00109     public:
00111         typedef std::map<RateCode::Oid, RateCode> Cont;
00112     public:
00114         const Cont& codes() const;
00123         const RateCode& getRateCode(const RateCode::Oid& id);
00124 
00132         const RateCode* findRateCode(const RateCode::Oid& id);
00133 
00135         void read(const OSB_DB::Session& session);
00136     public:
00138 
00139 
00150         void create(
00151             const OSB_DB::Session& session,
00152                   RateCode*        rc
00153         );
00154 
00168         void update(
00169             const OSB_DB::Session& session,
00170                   RateCode*        rc
00171         );
00172 
00190         void remove(
00191             const OSB_DB::Session& session,
00192                   RateCode*        rc
00193         );
00195     private:
00197         Cont codes_;
00198     };                                  // class RateCodes
00199 
00200     // *****************************************************************
00201     // Tariff
00209     class Tariff : public TariffObject {
00214         friend class OSB_DB::TariffSystemGw;
00219         friend struct OSB_DB::TariffGw;
00224         friend class TariffCatalogue;
00225     public:
00227         typedef Id<Tariff> Oid;
00228     public:
00230         Tariff (const Oid& oid = Oid());
00231     public:
00233 
00234 
00235         const Oid& oid() const;
00237         bool rounded() const;
00239 
00241 
00242 
00251         void setRounded(bool rounded);
00253 
00264         bool read(const OSB_DB::Session& session);
00265 
00266     private:
00268 
00269 
00282         bool insert(const OSB_DB::Session& session);
00283 
00298         bool remove(const OSB_DB::Session& session);
00299 
00313         bool update(const OSB_DB::Session& session);
00315 
00316     private:
00317         Oid  oid_;                      
00318         bool rounded_;                  
00319     };
00320 
00322     typedef std::list<Tariff> Tariffs;
00323 
00324     // *****************************************************************
00325     // TfVersion
00333     class TfVersion : public ToVersion {
00338         friend struct OSB_DB::TfVersionGw;
00339 
00344         friend class TariffCatalogue;
00345     public:
00347         typedef Id2<TfVersion> Oid;
00349         typedef std::set< Id<RatingFn> > AssignedRf;
00350     public:
00352         explicit TfVersion(const Oid& oid = Oid());
00354         explicit TfVersion(const Tariff::Oid& tfOid);
00355     public:
00357         const Oid& oid() const;
00359         Tariff::Oid tfId() const;
00360         // documentation from base class.
00361         long vsId() const;
00363         const AssignedRf& ratingFns() const;
00364 
00372         void rate(
00373                   UsedService& us,
00374             const Money&       money,
00375                   Decimal&     volume
00376         ) const;
00377 
00383         void rate(UsedService& us) const;
00384 
00390         void rate(SumCdr& sumCdr) const;
00391 
00407         bool patch(
00408             const OSB_DB::Session& session,
00409                   OsbErrors&       errors,
00410                   TfVersion*       replacing
00411         );
00412 
00426         bool addRatingFn(const RatingFn::Oid& rfId);
00427 
00441         bool removeRatingFn(const RatingFn::Oid& rfId);
00442 
00458         bool freeze(
00459             const OSB_DB::Session& session,
00460                   OsbErrors&       errors
00461         );
00462 
00483         bool release(
00484             const OSB_DB::Session& session,
00485                   OsbErrors&       errors
00486 //                  bool             patch = false
00487 //          @param  patch   Flag to indicate if tariff version is a
00488 //                          patch version. Defaulted to false.
00489         );
00490 
00504         bool revoke(
00505             const OSB_DB::Session& session,
00506                   OsbErrors&       errors
00507         );
00508 
00522         bool unfreeze(
00523             const OSB_DB::Session& session,
00524                   OsbErrors&       errors
00525         );
00526 
00527     private:
00537         bool checkObjVs(
00538             const OSB_DB::Session& session,
00539                   OsbErrors&       errors
00540         );
00541 
00550        bool hasReplacement(OSB_LIB::DateTime* nextVs) const;
00551 
00558        bool gracePeriodExpired() const;
00559 
00560     public:
00572         bool read(const OSB_DB::Session& session);
00573 
00574     private:
00576 
00577 
00590         bool insert(const OSB_DB::Session& session);
00591 
00606         bool remove(const OSB_DB::Session& session);
00607 
00621         bool update(const OSB_DB::Session& session);
00623 
00624     private:
00626         Oid oid_;
00628         AssignedRf ratingFns_;
00629     };
00630 
00632     typedef std::map<Tariff::Oid,
00633                      std::list<TfVersion> > TfVersions;
00634 
00635 // *********************************************************************
00636 // inline definitions
00637 
00638 }                                       // namespace OSB_LIB
00639 #endif                                  // #ifndef _TARIFF_H_

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