tcdist.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.63.2.1 $
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 _TCDIST_H_
00031 #define _TCDIST_H_
00032 
00033 // *********************************************************************
00034 // included header files
00035 // + standard includes
00036 #include <string>
00037 #include <list>
00038 #include <vector>
00039 #include <map>
00040 
00041 // + local headers
00042 #include "osbid.h"
00043 #include "osbtype.h"
00044 #include "tariffclass.h"
00045 #include "tariffobject.h"
00046 
00047 // *********************************************************************
00048 // class declarations
00049 namespace OSB_LIB {
00050     class Cdr;
00051     class ConnectionPt;
00052     class CpMapper;
00053     class Date;
00054     class OsbException;
00055 }
00056 
00057 namespace OSB_DB {
00058     class Session;
00059     class TariffSystemGw;
00060     class MappingDistTcsGw;
00061     struct DistTcsGw;
00062     struct TariffZoneGw;
00063     struct TzConfigGw;
00064 }
00065 
00066 // ************************************************************************
00067 // namespace extensions
00068 namespace OSB_LIB {
00069 
00070 // *********************************************************************
00071 // class definitions
00072 
00073     // *****************************************************************
00074     // class TariffZone
00082     class TariffZone : public TariffObject {
00084         friend struct OSB_DB::TariffZoneGw;
00086         friend class TariffCatalogue;
00087     public:
00089         typedef Id<TariffZone> Oid;
00090     public:
00092         explicit TariffZone(const Oid& oid = Oid()) : oid_(oid) {}
00093     public:
00095         const Oid& oid() const { return oid_; }
00096 
00098 
00099 
00108         bool read(const OSB_DB::Session& session);
00109     private:
00122         bool insert(const OSB_DB::Session& session);
00123 
00135         bool update(const OSB_DB::Session& session);
00136 
00149         bool remove(const OSB_DB::Session& session);
00151     private:
00153         Oid oid_;
00154     };
00155 
00157     typedef std::list<TariffZone> TariffZones;
00158 
00159     // *****************************************************************
00160     // class TzConfig
00173     class TzConfig : public ToCfgPeriodBase {
00175         friend struct OSB_DB::TzConfigGw;
00177         friend class TariffCatalogue;
00178     public:
00180         typedef Id<TzConfig> Oid;
00181     public:
00183         TzConfig(const Oid& oid = Oid());
00185         TzConfig(
00186             const Id<TariffZone>& tzId,
00187             const Id<ConnectionPt>& origin,
00188             const Id<ConnectionPt>& dest
00189         );
00190     public:
00192 
00193 
00194         const Oid& oid() const;
00196         const Id<TariffZone>& tzOid() const;
00198         inline const Id<ConnectionPt>& origin() const
00199         {
00200             return origin_;
00201         }
00203         inline const Id<ConnectionPt>& dest() const
00204         {
00205             return dest_;
00206         }
00208 
00210 
00211 
00220         bool read(const OSB_DB::Session& session);
00221 
00222     private:
00234         bool insert(const OSB_DB::Session& session);
00235 
00247         bool update(const OSB_DB::Session& session);
00248 
00261         bool remove(const OSB_DB::Session& session);
00263 
00265 
00266 
00282         bool freeze(
00283             const OSB_DB::Session& session,
00284                   OsbErrors&       errors
00285         );
00286 
00300         bool release(
00301             const OSB_DB::Session& session,
00302                   OsbErrors&       errors
00303         );
00304 
00318         bool revoke(
00319             const OSB_DB::Session& session,
00320                   OsbErrors&       errors
00321         );
00322 
00336         bool unfreeze(
00337             const OSB_DB::Session& session,
00338                   OsbErrors&       errors
00339         );
00341     private:
00343         Oid oid_;
00345         long objVs_;
00347         Id<TariffZone> tzId_;
00349         Id<ConnectionPt> origin_;
00351         Id<ConnectionPt> dest_;
00352     };                                  // class TzConfig
00353 
00355     typedef std::list<TzConfig> TzConfigs;
00356 
00357     // *****************************************************************
00358     // DistTcs
00370     class DistTcs : public TcsVersion {
00374         friend struct OSB_DB::DistTcsGw;
00375 
00381         typedef std::multimap< Id<ConnectionPt>, TzConfig> Config;
00382 
00384         static const TcSystem::TcsType type_ = TcSystem::tcsDist;
00385 
00386     public:
00388         typedef std::map<TariffZone::Oid, TariffClass::Oid> ZoneClassMap;
00389 
00390         // Documentation from base class.
00391         typedef std::auto_ptr<DistTcs> AutoPtr;
00392 
00398         explicit DistTcs(const TcSystem::Oid& tcsId);
00399 
00401         virtual TcSystem::TcsType type() const;
00402 
00403         // doc from base class
00404         void copyCfg(const OSB_LIB::TcsVersion* src);
00405 
00406         // Documentation from base class.
00407         AutoPtr clone() const;
00408 
00410         const ZoneClassMap& zcMap() const { return zcMap_; }
00411 
00422         void supportedTc(
00423             std::set<TariffClass::Oid>& tcOids
00424         ) const;
00425 
00448         virtual TariffClass::Oid getTc(
00449             Cdr&         cdr,
00450             UsedService& service
00451         ) const;
00452 
00462         void addZone(
00463             const TariffZone::Oid&  tzOid,
00464             const TariffClass::Oid& tcOid
00465         );
00466 
00475         void removeZone( const TariffZone::Oid& tzOid);
00476 
00477     private:
00478         // Documentation from base class.
00479         virtual TcsVersion* clone_() const;
00480 
00482 
00483 
00497         bool canFreeze(
00498             const OSB_DB::Session& session,
00499                   OsbErrors&       errors
00500         ) const;
00501 
00514         virtual bool canRelease(
00515             const OSB_DB::Session& session,
00516                   OsbErrors&       errors
00517         ) const;
00518 
00529         virtual bool canRevoke(
00530             const OSB_DB::Session& session,
00531                   OsbErrors&       errors
00532         ) const;
00533 
00544         virtual bool canUnfreeze(
00545             const OSB_DB::Session& session,
00546                   OsbErrors&       errors
00547         ) const;
00549 
00551 
00552 
00558         virtual bool readSpecific(
00559             const OSB_DB::Session& session
00560         );
00561 
00568         virtual bool insSpecific(
00569             const OSB_DB::Session& session
00570         );
00571 
00578         virtual bool delSpecific(
00579             const OSB_DB::Session& session
00580         );
00581 
00588         virtual bool updSpecific(
00589             const OSB_DB::Session& session
00590         );
00592 
00600         const TariffClass::Oid& getTariffClass(
00601             const TariffZone::Oid& tzOid
00602         ) const;
00603 
00605 
00606 
00612         void populate() const;
00613 
00621         bool findDest(
00622                   Id<ConnectionPt>& dest,
00623             const DateTime&         ts
00624         ) const;
00625 
00641         TariffZone::Oid findTzOid(
00642                   Id<ConnectionPt>& origin,
00643             const DateTime&         ts,
00644             const Id<ConnectionPt>& dest
00645         ) const;
00647 
00648     private:
00655         mutable Config config_;
00656 
00658         ZoneClassMap zcMap_;
00659     };
00660 
00672     class UsageMapping {
00673     public:
00675         typedef OSB_LIB::TypeId<OSB_LIB::Cdr, 1> UsageType;
00676     public:
00687         explicit UsageMapping(
00688             UsageType        ut = UsageType(),
00689             TypeId<CpMapper> ot = TypeId<CpMapper>(),
00690             TypeId<CpMapper> dt = TypeId<CpMapper>()
00691         );
00693         ~UsageMapping();
00695         UsageMapping(const UsageMapping& rhs);
00697         UsageMapping& operator=(const UsageMapping& rhs);
00698     public:
00700         UsageType usageType() const;
00702         TypeId<CpMapper> originType() const;
00704         TypeId<CpMapper>  destType() const;
00706         const CpMapper* originMapper() const;
00708         const CpMapper* destMapper() const;
00709 
00720         void createMappers();
00721     private:
00723         UsageType    usageType_;
00725         TypeId<CpMapper>  originType_;
00727         TypeId<CpMapper>  destType_;
00729         CpMapper*         originMapper_;
00731         CpMapper*         destMapper_;
00732     };
00733 
00734     // *****************************************************************
00735     // class MappingDistTcs
00740     class MappingDistTcs : public TcsVersion {
00741     private:
00743         static const TcSystem::TcsType type_ = TcSystem::tcsMapping;
00744 
00749         friend class OSB_DB::MappingDistTcsGw;
00750     public:
00752         typedef TypeId<Cdr, 1> UsageType;
00753         // Documentation from base class.
00754         typedef std::auto_ptr<MappingDistTcs> AutoPtr;
00756         typedef std::vector<UsageMapping> MappingList;
00757     public:
00759         explicit MappingDistTcs(const TcSystem::Oid& tcsId);
00760         // Documentation from base class.
00761         AutoPtr clone() const;
00762 
00773         void supportedTc(
00774             std::set<TariffClass::Oid>& tcOids
00775         ) const;
00776 
00778         TcSystem::TcsType type() const;
00779 
00780         // doc from base class
00781         void copyCfg(const OSB_LIB::TcsVersion* src);
00782 
00805         TariffClass::Oid getTc(
00806             Cdr&         cdr,
00807             UsedService& service
00808         ) const;
00809 
00817         const UsageMapping* findMapping(const UsageType& ut) const;
00818 
00820 
00821 
00822         const TcSystem::Oid& distTcs() const
00823         {
00824             return distTcs_;
00825         }
00841         bool setDistTcs(const TcSystem::Oid& distTcs);
00842 
00844         const MappingList& usageTypeMapping() const;
00856         bool addMapping(const UsageMapping& mapping);
00867         bool rmMapping(const UsageType& ut);
00868 
00870         void clearMappings();
00872 
00874 
00875 
00901         bool canFreeze(
00902             const OSB_DB::Session& session,
00903                   OsbErrors&       errors
00904         ) const;
00905 
00919         bool canRelease(
00920             const OSB_DB::Session& session,
00921                   OsbErrors&       errors
00922         ) const;
00923 
00935         bool canRevoke(
00936             const OSB_DB::Session& session,
00937                   OsbErrors&       errors
00938         ) const;
00939 
00951         bool canUnfreeze(
00952             const OSB_DB::Session& session,
00953                   OsbErrors&       errors
00954         ) const;
00956 
00958 
00959 
00970         virtual bool readSpecific(
00971             const OSB_DB::Session& session
00972         );
00973 
00985         virtual bool insSpecific(
00986             const OSB_DB::Session& session
00987         );
00988 
01000         virtual bool updSpecific(
01001             const OSB_DB::Session& session
01002         );
01003 
01015         virtual bool delSpecific(
01016             const OSB_DB::Session& session
01017         );
01019 
01020     private:
01024         TcSystem::Oid distTcs_;
01028         MappingList mappings_;
01029 
01030         // Documentation from base class.
01031         virtual TcsVersion* clone_() const;
01032 
01040         MappingList::iterator mappingDef(const UsageType& ut);
01041     };
01042 
01043 // *********************************************************************
01044 // inline definitions
01045 
01046 }                                       // namespace OSB_LIB
01047 #endif                                  // #ifndef _TCDIST_H_

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