00001 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 #ifndef _SERVICECLASS_H_
00031 #define _SERVICECLASS_H_
00032 
00033 
00034 
00035 
00036 #include <list>
00037 #include <set>
00038 #include <map>
00039 
00040 
00041 #include "ratedservice.h"
00042 #include "tariffobject.h"
00043 #include "osbid.h"
00044 #include "chrono.h"
00045 
00046 
00047 namespace OSB_LIB {
00048     class Cdr;
00049     class UsedService;
00050 }
00051 
00052 namespace OSB_DB {
00053     struct ServiceClassGw;
00054     struct ScSystemGw;
00055     struct ScsVersionGw;
00056 }
00057 
00058 
00059 
00060 namespace OSB_LIB {
00061 
00062 
00063 
00064     class ScsVersion;
00065 
00066 
00067 
00068 
00069     
00070     
00079     class ServiceClass : public TariffObject {
00084         friend struct OSB_DB::ServiceClassGw;
00085 
00090         friend class TariffCatalogue;
00091     public:
00093         typedef Id<ServiceClass> Oid;
00094 
00096         ServiceClass(const Oid& oid = Oid()) : oid_(oid) {};
00097 
00099         const Oid& oid() const;
00100 
00110         bool read(const OSB_DB::Session& session);
00111 
00112     private:
00114 
00115 
00127         bool insert(const OSB_DB::Session& session);
00128 
00140         bool update(const OSB_DB::Session& session);
00141 
00154         bool remove(const OSB_DB::Session& session);
00156 
00157     private:
00159         Oid oid_;
00160     };
00161 
00163     typedef std::list<ServiceClass> ServiceClasses;
00164 
00165     
00166     
00176     class MatchingTree {
00177     private:
00178         
00179         class Leaf;
00181         typedef std::list<Leaf> Leaves;
00182     public:
00189         void populate(const ScsVersion& scsVs);
00190 
00199         void addService(const RatedService& rs);
00200 
00209         const RatedService::Oid
00210         match(const ServiceTuple& st) const;
00211 
00217         void swap(MatchingTree& rhs);
00218 
00219     private:
00228         void addService(
00229                   Leaves&            leaves,
00230                   ServiceElements    ses,
00231             const RatedService::Oid& rsId
00232         );
00233 
00245         const RatedService::Oid
00246         match(
00247             const Leaves&         leaves,
00248                   ServiceElements ses
00249         ) const;
00250 
00251     private:
00253         Leaves leaves_;
00254     };
00255 
00256     
00257     
00261     struct MatchingTree::Leaf {
00267         explicit Leaf(const ServiceElement& se);
00268     public:
00270         ServiceElement se_;
00272         RatedService::Oid rsId_;
00274         Leaves childs_;
00275     };                                  
00276 
00277     
00278     
00288      class ScSystem : public TariffObject {
00293         friend struct OSB_DB::ScSystemGw;
00294 
00299         friend class TariffCatalogue;
00300      public:
00302         typedef Id<ScSystem> Oid;
00303      public:
00305         ScSystem(const Oid& oid = Oid()) : oid_(oid) {};
00306      public:
00308         const Oid& oid() const;
00316         const std::set<ServiceClass::Oid> supportedSc() const;
00317 
00327         bool read(const OSB_DB::Session& session);
00328 
00329     private:
00331 
00332 
00344         bool insert(const OSB_DB::Session& session);
00345 
00357         bool update(const OSB_DB::Session& session);
00358 
00371         bool remove(const OSB_DB::Session& session);
00373      private:
00375         Oid oid_;
00376      };
00377 
00379     typedef std::list<ScSystem> ScSystems;
00380 
00381     
00382     
00393      class ScsVersion : public ToVersion {
00398         friend struct OSB_DB::ScsVersionGw;
00403         friend class TariffCatalogue;
00404      public:
00409         typedef Id2<ScsVersion> Oid;
00411         typedef std::set<ServiceClass::Oid> ScOids;
00413         typedef std::map<Id<RatedService>, ServiceClass::Oid> RsScMap;
00414      public:
00416         explicit ScsVersion(const Oid& oid = Oid());
00418         explicit ScsVersion(const ScSystem::Oid& scsId);
00419 
00421 
00422 
00423         const Oid& oid() const;
00425         ScSystem::Oid scsId() const;
00427         const RsScMap& config() const;
00429 
00435         void supportedSc(ScOids& scOids) const;
00436 
00438 
00439 
00448         void addService(
00449             const RatedService::Oid& rsId,
00450             const ServiceClass::Oid& scId
00451         );
00452 
00461         void delService(const Id<RatedService>& service);
00463 
00479         ServiceClass::Oid getSc(
00480             Cdr&         cdr,
00481             UsedService& us
00482         ) const;
00483 
00493         bool read(const OSB_DB::Session& session);
00494 
00495      private:
00497 
00498 
00510         bool insert(const OSB_DB::Session& session);
00526         bool remove(const OSB_DB::Session& session);
00539         bool update(const OSB_DB::Session& session);
00541 
00543 
00544 
00561         bool freeze(
00562             const OSB_DB::Session& session,
00563                   OsbErrors&       errors
00564         );
00580         bool release(
00581             const OSB_DB::Session& session,
00582                   OsbErrors&       errors
00583         );
00597         bool revoke(
00598             const OSB_DB::Session& session,
00599                   OsbErrors&       errors
00600         );
00614         bool unfreeze(
00615             const OSB_DB::Session& session,
00616                   OsbErrors&       errors
00617         );
00619 
00621         void refreshMatchingTree();
00622      private:
00624         Oid oid_;
00626         RsScMap config_;
00628         MatchingTree mTree_;
00629      };
00630 
00632     typedef std::list<ScsVersion> ScsVersions;
00633 
00634 }                                       
00635 #endif                                  // #ifndef _SERVICECLASS_H_