tariffclass.h

Go to the documentation of this file.
00001 // OSB library ********************************************* -*- C++ -*-
00006 /*
00007   AUTHOR(S): Stephan Broennimann (vb)
00008 
00009   RCS information
00010    $Name: OSB_060808 $
00011    $Revision: 1.55 $
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 _TARIFFCLASS_H_
00031 #define _TARIFFCLASS_H_
00032 
00033 // *********************************************************************
00034 // included header files
00035 // + standard includes
00036 #include <string>
00037 #include <list>
00038 #include <set>
00039 
00040 // + local headers
00041 #include "osbid.h"
00042 #include "tariffobject.h"
00043 
00044 // ************************************************************************
00045 // class declarations
00046 namespace OSB_DB {
00047     class Session;
00048     class TariffSystemGw;
00049     class TcsVersionGw;
00050     struct TariffClassGw;
00051     struct TcSystemGw;
00052 }
00053 
00054 // ************************************************************************
00055 // namespace extensions
00056 namespace OSB_LIB {
00057 
00058 // *********************************************************************
00059 // forward declarations
00060     class OsbException;
00061     class ServiceClass;
00062     class Cdr;
00063     class UsedService;
00064 
00065 // *********************************************************************
00066 // type definitions
00067 
00068 // *********************************************************************
00069 // class definitions
00070 
00071     /*
00072      @brief Type of tariff classification system.
00073 
00074      Currently, three types of classification system are supported.
00075     */
00076     enum TcsType {
00077 
00082         tcsZone     = 1,
00083 
00089         tcsDirect   = 2,
00090 
00097         tcsSsAction = 3,
00098 
00100         tcsUnknown  = 0
00101     };
00102 
00103     // *****************************************************************
00104     // class TariffClass
00114     class TariffClass : public TariffObject {
00118         friend class TariffCatalogue;
00120         friend class OSB_DB::TariffClassGw;
00121     public:
00123         typedef Id<TariffClass> Oid;
00124     public:
00126         explicit TariffClass(const Oid& oid = Oid());
00127     public:
00129         const Oid& oid() const;
00130 
00140         bool read(const OSB_DB::Session& session);
00141     private:
00143 
00144 
00156         bool insert(const OSB_DB::Session& session);
00157 
00172         bool remove(const OSB_DB::Session& session);
00173 
00187         bool update(const OSB_DB::Session& session);
00189     private:
00191         Oid oid_;
00192     };
00193 
00195     typedef std::list<TariffClass> TariffClasses;
00196 
00197     // *****************************************************************
00198     // class TcSystem
00210     class TcSystem : public TariffObject {
00212         friend struct OSB_DB::TcSystemGw;
00217         friend class TariffCatalogue;
00218     public:
00220         typedef Id<TcSystem> Oid;
00221 
00223         enum TcsType {
00224             tcsUnknown = 0,             
00225             tcsDist    = 1,             
00226             tcsMapping = 2              
00227         };
00228     public:
00236         static TcsType mkTcsType(long t) throw();
00244         static long toLong(TcsType t) throw();
00245     public:
00250 
00251         explicit TcSystem(const Oid& oid = Oid());
00252     public:
00254         const Oid& oid() const;
00256         TcsType tcsType() const;
00257 
00265         const std::set<TariffClass::Oid> supportedTc() const;
00266 
00274         void setTcsType(TcsType tcsType);
00275 
00285         bool read(const OSB_DB::Session& session);
00286 
00287     private:
00289 
00290 
00302         bool insert(const OSB_DB::Session& session);
00303 
00318         bool remove(const OSB_DB::Session& session);
00319 
00333         bool update(const OSB_DB::Session& session);
00335 
00336     private:
00337         Oid         oid_;             
00338         TcsType     tcsType_;         
00339     };
00340 
00342     typedef std::list<TcSystem> TcSystems;
00343 
00345     typedef std::list<TcSystem::Oid> TcSystemOids;
00346 
00347     // *****************************************************************
00348     // TcsVersion
00353     class TcsVersion : public ToVersion {
00358         friend struct OSB_DB::TcsVersionGw;
00363         friend class TariffCatalogue;
00364     public:
00370         typedef Id2<TcsVersion> Oid;
00377         typedef std::auto_ptr<TcsVersion> AutoPtr;
00383         explicit TcsVersion(const TcSystem::Oid& tcsId);
00384 
00386         virtual ~TcsVersion();
00387 
00393         AutoPtr clone() const;
00394 
00426         template<typename T> T* isa(T*& ptr);
00427 
00429         template<typename T> const T* isa(const T*& ptr) const;
00430     protected:
00438         TcsVersion& operator=(const TcsVersion& rhs);
00439     public:
00441 
00442 
00443         const Oid& oid() const;
00445         const TcSystem::Oid tcsId() const;
00447         long vs() const;
00448 
00450         virtual TcSystem::TcsType type() const = 0;
00452 
00459         virtual void copyCfg(const TcsVersion* src) = 0;
00470         virtual void supportedTc(
00471             std::set<TariffClass::Oid>& tcOids
00472         ) const = 0;
00473 
00475 
00476 
00488         bool freeze(
00489             const OSB_DB::Session& session,
00490                   OsbErrors&       errors
00491         );
00492 
00511         bool release(
00512             const OSB_DB::Session& session,
00513                   OsbErrors&       errors
00514         );
00515 
00530         bool revoke(
00531             const OSB_DB::Session& session,
00532                   OsbErrors&       errors
00533         );
00534 
00548         bool unfreeze(
00549             const OSB_DB::Session& session,
00550                   OsbErrors&       errors
00551         );
00553 
00564         virtual TariffClass::Oid getTc(
00565             Cdr&         cdr,
00566             UsedService& service
00567         ) const = 0;
00568     private:
00574         virtual TcsVersion* clone_() const = 0;
00575 
00595         virtual bool canFreeze(
00596             const OSB_DB::Session& session,
00597                   OsbErrors&       errors
00598         ) const = 0;
00599 
00609         virtual bool canRelease(
00610             const OSB_DB::Session& session,
00611                   OsbErrors&       errors
00612         ) const = 0;
00613 
00623         virtual bool canRevoke(
00624             const OSB_DB::Session& session,
00625                   OsbErrors&       errors
00626         ) const = 0;
00627 
00637         virtual bool canUnfreeze(
00638             const OSB_DB::Session& session,
00639                   OsbErrors&       errors
00640         ) const = 0;
00642 
00657         virtual bool readSpecific(
00658             const OSB_DB::Session& session
00659         ) = 0;
00660 
00668         virtual bool insSpecific(
00669             const OSB_DB::Session& session
00670         ) = 0;
00671 
00684         virtual bool delSpecific(
00685             const OSB_DB::Session& session
00686         ) = 0;
00687 
00695         virtual bool updSpecific(
00696             const OSB_DB::Session& session
00697         ) = 0;
00699 
00701 
00702     public:
00715         bool read(const OSB_DB::Session& session);
00716 
00717     private:
00731         bool insert(const OSB_DB::Session& session);
00732 
00746         bool remove(const OSB_DB::Session& session);
00747 
00761         bool update(const OSB_DB::Session& session);
00763 
00764     private:
00766         Oid oid_;
00767     };                                  // class TcsVersion
00768 
00769     // *****************************************************************
00770     // TcsVersions
00781     struct TcsVersions {
00783 
00784 
00787         typedef std::list<TcsVersion*> List;
00789         typedef List::iterator Iterator;
00791         typedef List::const_iterator ConstIterator;
00793         typedef List::size_type SizeType;
00795 
00797         TcsVersions();
00804         TcsVersions(const TcsVersions& rhs);
00806         TcsVersions& operator=(const TcsVersions& rhs);
00808         ~TcsVersions();
00809 
00816 
00817         Iterator       begin();
00819         Iterator       end();
00821         ConstIterator begin() const;
00823         ConstIterator end() const;
00825         SizeType      size() const;
00827         void swap(TcsVersions& rhs);
00829 
00839         void pushBack(const TcsVersion& tcsVs);
00840 
00852         void pushBack(TcsVersion::AutoPtr tcsVs);
00853 
00864         void erase(const TcsVersion::Oid& tcsVs);
00865 
00872         void clear();
00873     public:
00875         List list_;
00876     };
00877 
00878     // *****************************************************************
00879     // TcsVersionFactory
00891     class TcsVersionFactory {
00892     public:
00907         static TcsVersion::AutoPtr create(
00908             const TcSystem::TcsType& type,
00909             const TcSystem::Oid&     tcsId
00910         );
00911 
00912     private:
00914         TcsVersionFactory();
00916         TcsVersionFactory(const TcsVersionFactory& rhs);
00917     };
00918 
00919 // *********************************************************************
00920 // inline definitions
00921 
00922     // *****************************************************************
00923     // TcsVersion
00924     template<typename T> T* TcsVersion::isa(T*& ptr)
00925     {
00926         ptr = dynamic_cast<T*>(this);
00927         return ptr;
00928     }
00929 
00930     template<typename T> const T* TcsVersion::isa(const T*& ptr) const
00931     {
00932         ptr = dynamic_cast<const T*>(this);
00933         return ptr;
00934     }
00935 }                                       // namespace OSB_LIB
00936 #endif                                  // #ifndef _TARIFFCLASS_H_

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