tariffperiod.h

Go to the documentation of this file.
00001 // OSB library ************************************************ -*- C++ -*-
00006 /*
00007   AUTHOR(S): Wang Peng (wp)
00008 
00009   RCS information
00010    $Name: OSB_060808 $
00011    $Revision: 1.70 $
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 _TARIFFPERIOD_H_
00031 #define _TARIFFPERIOD_H_
00032 
00033 // ************************************************************************
00034 // included header files
00035 // + standard includes
00036 #include <list>
00037 #include <set>
00038 #include <utility>
00039 #include <map>
00040 #include <vector>
00041 #include <memory>
00042 
00043 // + local headers
00044 #include "osbid.h"
00045 #include "chrono.h"
00046 #include "tariffobject.h"
00047 
00048 // ************************************************************************
00049 // class declarations
00050 namespace OSB_DB {
00051     class Session;
00052     class TariffSystemGw;
00053     struct DayClassGw;
00054     struct SpecialDateGw;
00055     struct TariffPeriodGw;
00056     struct TpSystemGw;
00057     struct TpsVersionGw;
00058 }
00059 
00060 namespace OSB_LIB {
00061     class OsbErrors;
00062 }
00063 
00064 // ************************************************************************
00065 // namespace extensions
00066 namespace OSB_LIB {
00067 
00068 // Forward declarations
00069     class TariffCatalogue;
00070 
00071 // ************************************************************************
00072 // class definitions
00073 
00074     // ********************************************************************
00075     // DayClass
00085     class DayClass : public TariffObject,
00086                      public ToCfgBase
00087     {
00089         friend struct OSB_DB::DayClassGw;
00095         friend class TariffCatalogue;
00096     public:
00098         typedef Id<DayClass> Oid;
00099     public:
00101         explicit DayClass(const Oid& oid = Oid());
00102     public:
00104         const Oid& oid() const;
00105     public:
00115         bool setWeekday(
00116             Weekday wd,
00117             bool    add
00118         );
00119 
00127         bool matchWeekDay (const Weekday& weekday) const;
00128 
00138         bool read(const OSB_DB::Session& session);
00139 
00140     private:
00142 
00143 
00155         bool insert(const OSB_DB::Session& session);
00156 
00171         bool remove(const OSB_DB::Session& session);
00172 
00186         bool update(const OSB_DB::Session& session);
00188 
00190 
00191 
00202         bool freeze(
00203             const OSB_DB::Session& session,
00204                   OsbErrors&       errors
00205         );
00206 
00218         bool release(
00219             const OSB_DB::Session& session,
00220                   OsbErrors&       errors
00221         );
00222 
00237         bool revoke(
00238             const OSB_DB::Session& session,
00239                   OsbErrors&       errors
00240         );
00241 
00256         bool unfreeze(
00257             const OSB_DB::Session& session,
00258                   OsbErrors&       errors
00259         );
00261 
00262     private:
00263         Oid         oid_;       
00264         bool        mon_;       
00265         bool        tue_;       
00266         bool        wed_;       
00267         bool        thu_;       
00268         bool        fri_;       
00269         bool        sat_;       
00270         bool        sun_;       
00271     };
00272 
00274     typedef std::list<DayClass> DayClasses;
00275 
00276     // ********************************************************************
00277     // SpecialDate
00284     class SpecialDate {
00286         friend struct OSB_DB::SpecialDateGw;
00287 
00292         friend class TariffCatalogue;
00293 
00295         typedef Id<DayClass> DcId;
00296 
00297     public:
00299         typedef Id<SpecialDate> Oid;
00300 
00301     public:
00305         explicit SpecialDate(
00306             const Oid& oid = Oid()
00307         );
00308 
00310         const Oid& oid() const { return oid_; }
00312         const DcId& dcId() const { return dcId_; }
00314         const std::string& name () const { return name_; }
00316         const Date& date () const { return date_; }
00318         const bool& annual () const { return annual_; }
00320         const CfgStatus& status() const { return status_; }
00322         long objVs() const { return objVs_; }
00323 
00332         void setName(const std::string& name);
00333 
00338         void setAnnual(const bool newAnnual);
00339 
00344         void setDate(const Date& newDate);
00345 
00350         void setDcId(const DcId& dcId);
00351 
00357         bool gracePeriodExpired() const;
00358 
00360 
00361 
00367         bool read(const OSB_DB::Session& session);
00368 
00369     private:
00378         bool insert(const OSB_DB::Session& session);
00379 
00390         bool remove(const OSB_DB::Session& session);
00391 
00402         bool update(const OSB_DB::Session& session);
00404 
00406 
00407 
00420         bool check(
00421             const OSB_DB::Session& session,
00422                   OsbErrors&       errors
00423         );
00424 
00439         bool release(
00440             const OSB_DB::Session& session,
00441                   OsbErrors&       errors
00442         );
00443 
00456         bool revoke(
00457             const OSB_DB::Session& session,
00458                   OsbErrors&       errors
00459         );
00460 
00472         bool unfreeze(
00473             const OSB_DB::Session& session,
00474                   OsbErrors&       errors
00475         );
00477 
00478     private:
00479         Oid         oid_;       
00480         DcId        dcId_;      
00481         std::string name_;      
00482         Date        date_;      
00483         bool        annual_;    
00484         CfgStatus   status_;    
00485         long        objVs_;     
00486     };
00487 
00489     typedef std::list<SpecialDate> SpecialDates;
00490 
00491     // ********************************************************************
00492     // TariffPeriod
00500     class TariffPeriod : public TariffObject {
00502         friend struct OSB_DB::TariffPeriodGw;
00503 
00508         friend class TariffCatalogue;
00509     public:
00511         typedef Id<TariffPeriod> Oid;
00512     public:
00514         explicit TariffPeriod(
00515             const Oid& oid = Oid()
00516         );
00517     public:
00519         const Oid& oid() const;
00521         std::string color() const { return color_; }
00522 
00527         void setColor(const std::string& color);
00528 
00530 
00531 
00540         bool read(const OSB_DB::Session& session);
00541 
00542     private:
00555         bool insert(const OSB_DB::Session& session);
00556 
00571         bool remove(const OSB_DB::Session& session);
00572 
00586         bool update(const OSB_DB::Session& session);
00588 
00589     private:
00591         Oid oid_;
00593         std::string color_;
00594     };                                  // class TariffPeriod
00595 
00597     typedef std::list<TariffPeriod> TariffPeriods;
00598 
00600     typedef std::set<TariffPeriod::Oid> TpOidSet;
00601 
00602     // ********************************************************************
00603     // TpSystem
00607     class TpSystem : public TariffObject {
00609         friend class OSB_DB::TpSystemGw;
00614         friend class TariffCatalogue;
00615     public:
00617         typedef Id<TpSystem> Oid;
00618     public:
00620         explicit TpSystem(const Oid& oid = Oid());
00621     public:
00623         const Oid& oid() const;
00630         TpOidSet supportedTp() const;
00631 
00633 
00634 
00643         bool read(const OSB_DB::Session& session);
00644 
00645     private:
00658         bool insert(const OSB_DB::Session& session);
00659 
00674         bool remove(const OSB_DB::Session& session);
00675 
00689         bool update(const OSB_DB::Session& session);
00691 
00692     private:
00693         Oid         oid_;     
00694     };
00695 
00697     typedef std::list<TpSystem> TpSystems;
00698 
00699     // ********************************************************************
00700     // class TpsConfig
00704     class TpsConfig {
00705     public:
00707         typedef std::map<OSB_LIB::Time, TariffPeriod::Oid> SwitchTimes;
00709         typedef std::map<DayClass::Oid, SwitchTimes> DcMap;
00710     public:
00712         const DcMap& dcMap() const;
00713 
00715 
00716 
00717         void clear();
00719         void add(
00720             const DayClass::Oid&     dcId,
00721             const OSB_LIB::Time&     switchTime,
00722             const TariffPeriod::Oid& tpId
00723         );
00730         void remove(
00731             const DayClass::Oid& dcId,
00732             const OSB_LIB::Time& switchTime
00733         );
00740         void cleanup();
00742     private:
00748         DcMap dcMap_;
00749     };                                  // class TpsConfig
00750 
00751     // ********************************************************************
00752     // TpsVersion
00760     class TpsVersion : public ToVersion {
00762         friend struct OSB_DB::TpsVersionGw;
00763 
00768         friend class TariffCatalogue;
00769     public:
00771         typedef Id2<TpsVersion> Oid;
00772     public:
00774         explicit TpsVersion(const Oid& oid = Oid());
00776         explicit TpsVersion(const TpSystem::Oid& tpsId);
00777     public:
00779         const Oid& oid() const;
00781         TpSystem::Oid tpsId() const;
00783         const TpsConfig& config() const;
00784 
00792         TariffPeriod::Oid getTp(const DateTime& ts) const;
00793 
00800         void supportedTp(
00801             std::set<TariffPeriod::Oid>& tpOids
00802         ) const;
00803 
00810         void setConfig(const TpsConfig& cfg);
00811 
00821         bool read(const OSB_DB::Session& session);
00822 
00823     private:
00825 
00826 
00838         bool insert(const OSB_DB::Session& session);
00839 
00854         bool remove(const OSB_DB::Session& session);
00855 
00869         bool update(const OSB_DB::Session& session);
00871 
00873 
00874 
00890         bool freeze(
00891             const OSB_DB::Session& session,
00892                   OsbErrors&       errors
00893         );
00894 
00910         bool release(
00911             const OSB_DB::Session& session,
00912                   OsbErrors&       errors
00913         );
00914 
00928         bool revoke(
00929             const OSB_DB::Session& session,
00930                   OsbErrors&       errors
00931         );
00932 
00946         bool unfreeze(
00947             const OSB_DB::Session& session,
00948                   OsbErrors&       errors
00949         );
00951 
00952     private:
00954         Oid oid_;
00956         TpsConfig config_;
00957     };                                  // class TpsVersion
00958 
00960     typedef std::list<TpsVersion> TpsVersions;
00961 
00962 // ************************************************************************
00963 // inline definitions
00964 }                                       // namespace OSB_LIB
00965 #endif                                  // #ifndef _TARIFFPERIOD_H_
00966 

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