anclist.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.16 $
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 _ANCLIST_H_
00031 #define _ANCLIST_H_
00032 
00033 // ************************************************************************
00034 // included header files
00035 // + standard includes
00036 #include <map>
00037 #include <memory>
00038 #include <set>
00039 
00040 // + libraries
00041 
00042 // + local headers
00043 #include "associate.h"
00044 #include "contract.h"
00045 #include "osbid.h"
00046 
00047 // + class declarations
00048 namespace OSB_DB {
00049     class Session;
00050 }
00051 
00052 // ************************************************************************
00053 // namespace extensions
00054 namespace OSB_LIB {
00055 
00056 // ************************************************************************
00057 // forward declarations
00058     struct AnCFilter;
00059 
00060 // ************************************************************************
00061 // type definitions
00062 
00063 // ************************************************************************
00064 // class definitions
00068     class AssociateList {
00069     public:
00077         typedef std::auto_ptr<Associate> AssociateAutoPtr;
00078 
00080 
00081 
00086         typedef std::map<Id<Associate>, Associate*> List;
00088         typedef List::iterator Iterator;
00090         typedef List::const_iterator ConstIterator;
00092         typedef List::size_type SizeType;
00094         typedef List::key_type KeyType;
00096 
00098         AssociateList() {};
00099 
00106         AssociateList(const AssociateList& rhs);
00107 
00109         AssociateList& operator=(const AssociateList& rhs);
00110 
00112         ~AssociateList();
00113 
00122 
00123         Iterator begin() { return list_.begin(); }
00125         Iterator end() { return list_.end(); }
00127         Iterator find(const KeyType& k) { return list_.find(k); }
00129         ConstIterator begin() const { return list_.begin(); }
00131         ConstIterator end() const { return list_.end(); }
00133         ConstIterator find(const KeyType& k) const
00134         { return list_.find(k); }
00136         SizeType size() const { return list_.size(); }
00138         void swap(AssociateList& rhs);
00140 
00155         Associate* insert(const Associate& assoc);
00156 
00174         Associate* insert(AssociateAutoPtr ap);
00175 
00184         void erase(Iterator pos);
00185 
00194         void erase(const KeyType& k);
00195 
00202         void clear();
00203 
00205         const List& list() const { return list_; }
00206 
00214         Associate* findAssociate(const Id<Associate>& asId);
00215 
00223         const Associate* findAssociate(const Id<Associate>& asId) const;
00224 
00232         const Associate& getAssociate(const Id<Associate>& asId) const;
00233 
00242         Associate& getAssociate(const Id<Associate>& asId);
00243 
00244     private:
00246         List list_;
00247     };
00248 
00249     // *****************************************************************
00250     // AnCList
00254     class AnCList {
00256         friend class Associate;
00257     private:
00259         typedef std::set<Associate::Oid> AssociateIds;
00260 
00261     public:
00263         class AssocReadFailed : public OsbException {
00264         public:
00266             AssocReadFailed(
00267                       ErrorNo         errNo,
00268                 const Associate::Oid& asId
00269             );
00270         };                              // class AssocReadFailed
00271 
00273         class ContractReadFailed : public OsbException {
00274         public:
00276             ContractReadFailed(
00277                       ErrorNo        errNo,
00278                 const Contract::Oid& coId
00279             );
00280         };                              // class ContractReadFailed
00281 
00283         class PpReadFailed : public OsbException {
00284         public:
00286             PpReadFailed(
00287                       ErrorNo          errNo,
00288                 const Id<PersProduct>& ppId
00289             );
00290         };                              // class PpReadFailed
00291 
00292     public:
00294         typedef std::map< Id<Contract>,    Contract>      ContractMap;
00296         typedef std::map< Id<PersProduct>, Id<Contract> > PersProductMap;
00297 
00298     public:
00300         AnCList() {}
00302         AnCList(const AnCList& rhs);
00304         AnCList& operator=(const AnCList& rhs);
00306         ~AnCList();
00307 
00308     public:
00310         const AssociateList& associateList() const
00311         {
00312             return aList_;
00313         }
00314 
00316         const ContractMap& contractMap() const
00317         {
00318             return cMap_;
00319         }
00320 
00322 
00323 
00332         long search(
00333             const OSB_DB::Session& session,
00334                   AnCFilter&       filter
00335         );
00337 
00339 
00340 
00347         Associate* associate(const Associate::Oid& asId);
00348 
00357         Associate& getAssociate(const Associate::Oid& asId);
00358 
00380         Associate* read(
00381             const OSB_DB::Session& session,
00382             const Associate::Oid   asId
00383         );
00384 
00395         bool create(
00396             OSB_DB::Session& session,
00397             Associate&       assoc
00398         );
00399 
00415         bool replace(
00416             const Associate& assoc
00417         );
00418 
00431         bool remove(
00432                   OSB_DB::Session& session,
00433             const Associate::Oid   asId
00434         );
00436 
00438 
00439 
00446         const Contract* findContract(const Contract::Oid& coId) const;
00447 
00456         Contract* contract(const Contract::Oid& coId);
00457 
00465         const Contract& getContract(const Contract::Oid& coId) const;
00466 
00474         Contract& getContract(const Contract::Oid& coId);
00475 
00491         Contract* read(
00492             const OSB_DB::Session& session,
00493             const Contract::Oid    coId
00494         );
00495 
00504         bool create(
00505                   OSB_DB::Session& session,
00506             const Associate::Oid&  owner,
00507                   Contract&        contract
00508         );
00509 
00516         void remove(
00517                   OSB_DB::Session& session,
00518             const Contract::Oid    coId
00519         );
00520 
00532         bool replace(
00533             const Contract& contract
00534         );
00536 
00538 
00539 
00546         PersProduct* persProduct(
00547             const Id<PersProduct>& ppId
00548         );
00549 
00571         PersProduct* read(
00572             const OSB_DB::Session& session,
00573             const Id<PersProduct>  ppId
00574         );
00576 
00582         void refresh(const OSB_DB::Session& session);
00583 
00584     private:
00597         void read(
00598             const OSB_DB::Session& session,
00599             const AssociateIds&    idList
00600         );
00601 
00605         void swap(AnCList& rhs);
00606 
00616         void insert(
00617             const Contract& co
00618         );
00619 
00630         void erase(
00631             const Contract::Oid coId
00632         );
00633 
00651         bool delAssoc(
00652             const OSB_DB::Session& session,
00653             const Associate::Oid   asId
00654         );
00655 
00656     private:
00658         AssociateList aList_;
00660         ContractMap  cMap_;
00662         PersProductMap ppMap_;
00663     };                                  // class AnCList
00664 
00666     struct AnCFilter {
00668         Associate::Oid asId_;
00670         std::string    asName_;
00672         Contract::Oid  coId_;
00673 
00675         size_t         maxRows_;
00677         bool           moreRows_;
00678 
00684         AnCFilter();
00685     };                                  // struct AnCList::Filter
00686 }                                       // namespace OSB_LIB
00687 
00688 // ************************************************************************
00689 // inline definitions
00690 namespace OSB_LIB {
00691 }                                       // namespace OSB_LIB
00692 #endif                                  // #ifndef _ANCLIST_H_

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