trunkresource.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.41 $
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 _TRUNKRESOURCE_H_
00031 #define _TRUNKRESOURCE_H_
00032 
00033 // *********************************************************************
00034 // included header files
00035 // + standard includes
00036 #include <list>
00037 
00038 // + local headers
00039 #include "osberror.h"
00040 #include "resource.h"
00041 #include "resourceitem.h"
00042 
00043 // *********************************************************************
00044 // class declarations
00045 namespace OSB_DB {
00046     class Session;
00047     class TrunkResourceGw;
00048 }
00049 
00050 namespace OSB_LIB {
00051     class TrunkGroup;
00052 }
00053 
00054 // *********************************************************************
00055 // namespace extensions
00056 namespace OSB_LIB {
00057 
00058 // *********************************************************************
00059 // class definitions
00060 
00061     // *****************************************************************
00062     // class TrunkResource
00068     class TrunkResource : public Resource {
00070         friend class OSB_DB::TrunkResourceGw;
00071     private:
00073         static const Type typeId_ = rtTrunkResource;
00074 
00075     public:
00077         struct AssignedTrunk {
00079             Id<TrunkGroup> trunkId_;
00081             DateTime       from_;
00083             DateTime       to_;
00084         };
00085 
00087         typedef std::list<AssignedTrunk> AssignedTrunks;
00088 
00089     public:
00091 
00092         class SameNetwork : public OsbException {
00093         public:
00094             SameNetwork(const TrunkResource& tr);
00095         };
00096 
00097         class TrunksAssigned : public OsbException {
00098         public:
00099             TrunksAssigned(const TrunkResource& tr);
00100         };
00101 
00102         class StatusIsAssigned : public OsbException {
00103         public:
00104             StatusIsAssigned(const TrunkResource& tr);
00105         };
00107 
00108     public:
00110         TrunkResource(const Oid& id = Oid());
00111 
00119         TrunkResource(
00120             const Number&       rn,
00121             const Id<Network>&  nw
00122         );
00123 
00125 
00126 
00127         Type typeId() const;
00129         const std::string& des() const;
00131         const Id<Network>& extNetwork() const;
00133         const AssignedTrunks& assignedTrks() const;
00135         const AssignedTrunks curAssignedTrks() const;
00145         bool canSetExtNw() const;
00147 
00159         const TrunkGroup& getTrkGroup(
00160             const Id<TrunkGroup>& tgId
00161         ) const;
00162 
00164 
00165 
00166         void setDes(const std::string& des);
00179         void setExternalNetwork(const Id<Network>& ext);
00181 
00183 
00184         bool read(const OSB_DB::Session& session);
00185         bool insert(const OSB_DB::Session& session);
00186         void updData(const OSB_DB::Session& session);
00187         bool remove(const OSB_DB::Session& session);
00188         bool addTrkGroup(
00189             const OSB_DB::Session& session,
00190             const Date&            start,
00191             const TrunkGroup&      tg
00192         );
00193         bool delTrkGroup(
00194             const OSB_DB::Session& session,
00195             const Id<TrunkGroup>&  tgId
00196         );
00198 
00206         bool isCurAssigned(const Id<TrunkGroup>& tgId) const;
00207 
00213         static void sortTgsByPriority(
00214             AssignedTrunks& groups
00215         );
00216 
00222         static void sortTgsByName(
00223             AssignedTrunks& groups
00224         );
00225     private:
00235         bool assign(const AssignedTrunk& assignedTg);
00243         bool deassign(const Id<TrunkGroup>& tgId);
00244 
00245     private:
00247         std::string des_;
00249         Id<Network> extNetworkId_;
00251         AssignedTrunks assignedTrunks_;
00252     };
00253 
00254     // *****************************************************************
00255     // class PersTrunk
00261     class PersTrunk : public PersResource {
00262     public:
00263         // Documentation from base class.
00264         typedef std::auto_ptr<PersTrunk> AutoPtr;
00265 
00267         static const Type type_;
00268 
00269     public:
00271         PersTrunk(const Oid& oid = Oid());
00273         PersTrunk(const PersTrunk& rhs);
00275         PersTrunk& operator=(const PersTrunk& rhs);
00277         ~PersTrunk();
00278     public:
00279         // Documentation from base class.
00280         virtual Type type() const;
00281         AutoPtr clone() const;
00282     private:
00283         // Documentation from base class.
00284         PersProductItem* clone_() const;
00285 
00286     public:
00293         virtual bool canConfig() const;
00294 
00296         virtual const Resource* resource() const;
00297 
00299         virtual const Resource* oldResource() const;
00300 
00302         void assign(const TrunkResource& trunkResource);
00303     private:
00305         virtual Resource* resource();
00307         virtual Resource* oldResource();
00309         virtual Resource* createResource(
00310             const Resource::Oid& resourceId
00311         );
00312 
00313     private:
00330         virtual bool readSpecific(
00331             const OSB_DB::Session& session
00332         );
00333 
00334         virtual bool insSpecific(
00335             const OSB_DB::Session& session
00336         );
00337 
00338         virtual bool updSpecific(
00339             const OSB_DB::Session& session
00340         );
00341 
00342         virtual bool delSpecific(
00343             const OSB_DB::Session& session
00344         );
00346 
00347     private:
00349         TrunkResource* trunkResource_;
00351         TrunkResource* oldTrunkResource_;
00352     };                                  // class PersTrunk
00353 
00354     // *****************************************************************
00355     // class TrunkItem
00361     class TrunkItem : public ResourceItem {
00362     public:
00364         static const Type type_;
00365 
00367         typedef std::auto_ptr<TrunkItem> AutoPtr;
00368 
00376         TrunkItem(
00377             const Oid&         oid,
00378             const std::string& name = "",
00379             const std::string& des  = ""
00380         );
00381 
00382     public:
00383         // Documentation from base class.
00384         virtual Type type() const;
00385         AutoPtr clone() const;
00386 
00387     public:
00394         ProductItem::CfgType canConfigure() const;
00395 
00402         ProductItem::DefPersType canDefPers() const;
00403 
00405         CfgPersType canPersonalize() const;
00406 
00408         const PersProductItem* defPersItem() const;
00409 
00416         std::auto_ptr<PersProductItem> crePersProductItem() const;
00417 
00418     private:
00420         ProductItem* clone_() const;
00421 
00428 
00429         virtual bool readSpecific(
00430             const OSB_DB::Session& session
00431         );
00433         virtual bool insSpecific(
00434             const OSB_DB::Session& session
00435         );
00437         virtual bool updSpecific(
00438             const OSB_DB::Session& session
00439         );
00441         virtual bool delSpecific(
00442             const OSB_DB::Session& session
00443         );
00445     };                                  // class TrunkItem
00446 
00447 // *********************************************************************
00448 // inline definitions
00449 
00450 }                                       // namespace OSB_LIB
00451 #endif                                  // #ifndef _TRUNKRESOURCE_H_

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