00001 // OSB library ************************************************ -*- C++ -*- 00006 /* 00007 AUTHOR(S): Stephan Broennimann (vb) 00008 00009 RCS information 00010 $Name: OSB_060808 $ 00011 $Revision: 1.5 $ 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 _RATEDPARTYTYPE_H_ 00031 #define _RATEDPARTYTYPE_H_ 00032 00033 // ************************************************************************ 00034 // included header files 00035 // + standard includes 00036 #include <list> 00037 00038 // + libraries 00039 00040 // + local headers 00041 #include "osbtype.h" 00042 00043 // + class declarations 00044 namespace OSB_LIB { 00045 class RatedParty; 00046 } 00047 namespace OSB_DB { 00048 class Session; 00049 class RatedPartyTypeGw; 00050 } 00051 00052 // ************************************************************************ 00053 // namespace extensions 00054 namespace OSB_LIB { 00055 00056 // ************************************************************************ 00057 // forward declarations 00058 class RatedPartyTypes; 00059 00060 // ************************************************************************ 00061 // type definitions 00062 00063 // ************************************************************************ 00064 // class definitions 00065 00069 class RatedPartyType { 00071 friend class RatedPartyTypes; 00076 friend class OSB_DB::RatedPartyTypeGw; 00078 typedef TypeId<RatedParty> Type; 00079 public: 00080 explicit RatedPartyType( 00081 Type type 00082 ); 00083 public: 00085 inline const Type& type() const; 00087 const std::string& name() const; 00089 const std::string& des() const; 00091 void setName(const std::string& name); 00093 void setDes(const std::string& des); 00094 00096 inline bool operator<(const RatedPartyType& rhs) const; 00097 private: 00108 void save(const OSB_DB::Session& session) const; 00116 void remove(const OSB_DB::Session& session) const; 00118 private: 00120 Type type_; 00122 std::string name_; 00124 std::string des_; 00125 }; // class RatedPartyType 00126 00130 class RatedPartyTypes { 00132 friend class OSB_DB::RatedPartyTypeGw; 00133 public: 00140 typedef std::list<RatedPartyType> Cont; 00141 public: 00149 const RatedPartyType& get(const TypeId<RatedParty>& type); 00157 const RatedPartyType* find(const TypeId<RatedParty>& type); 00158 00160 const Cont& rpTypes() const; 00164 void sort(); 00171 template<typename Comp> void sort(Comp comp); 00172 public: 00174 00179 void read( 00180 const OSB_DB::Session& session 00181 ); 00192 void replace( 00193 const OSB_DB::Session& session, 00194 const RatedPartyType& rpType 00195 ); 00204 void remove( 00205 const OSB_DB::Session& session, 00206 const RatedPartyType& rpType 00207 ); 00208 private: 00210 Cont cont_; 00211 }; // class RatedPartyTypes 00212 } // namespace OSB_LIB 00213 00214 // ************************************************************************ 00215 // inline definitions 00216 namespace OSB_LIB { 00217 // ******************************************************************** 00218 // class RatedPartyType 00219 inline const RatedPartyType::Type& RatedPartyType::type() const 00220 { 00221 return type_; 00222 } 00223 00224 inline bool RatedPartyType::operator<(const RatedPartyType& rhs) const 00225 { 00226 return type() < rhs.type(); 00227 } 00228 00229 // ******************************************************************** 00230 // class RatedPartyTypes 00231 template<typename Comp> void RatedPartyTypes::sort(Comp comp) 00232 { 00233 cont_.sort(comp); 00234 } 00235 } // namespace OSB_LIB 00236 #endif // #ifndef _RATEDPARTYTYPE_H_