00001 // OSB library ********************************************* -*- C++ -*- 00013 /* 00014 AUTHOR(S): Lilian Qin Lan (lan) 00015 00016 RCS information 00017 $Name: OSB_060808 $ 00018 $Revision: 1.27 $ 00019 00020 License 00021 OSB rating and billing library for communication networks 00022 Copyright (C) 2004, 2005, 2006 OSB systems 00023 00024 This file may be distributed and/or modify under the terms of the 00025 GNU General Public License (GPL) as published by the Free Software 00026 Foundation which is provided in the file LICENSE.GPL included in the 00027 packaging of this file. 00028 00029 The file is distributed in the hope that it will be useful, but WITHOUT 00030 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00031 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00032 for more details. 00033 00034 Holders of a OSB Commercial License may use this file under the terms 00035 and conditions of this commercial license. 00036 */ 00037 #ifndef _TSITEM_H_ 00038 #define _TSITEM_H_ 00039 00040 // ********************************************************************* 00041 // included header files 00042 // + standard includes 00043 #include <set> 00044 00045 // + local headers 00046 #include "osbid.h" 00047 #include "productitem.h" 00048 #include "persitem.h" 00049 00050 // ********************************************************************* 00051 // class declarations 00052 namespace OSB_DB { 00053 class Session; 00054 class TsItemGw; 00055 } 00056 00057 namespace OSB_LIB { 00058 class TariffSystem; 00059 } 00060 00061 // ********************************************************************* 00062 // namespace extensions 00063 namespace OSB_LIB { 00064 00065 // ********************************************************************* 00066 // class definitions 00072 class PersTariffSystem : public PersProductItem { 00073 private: 00081 friend class OSB_DB::TsItemGw; 00083 friend class TariffSystemItem; 00084 public: 00086 static const Type type_; 00087 00089 typedef Id<TariffSystem> TsId; 00090 00091 // Documentation from base class. 00092 typedef std::auto_ptr<PersTariffSystem> AutoPtr; 00093 00100 explicit PersTariffSystem(const Oid& oid = Oid()) 00101 : PersProductItem(oid) {} 00102 00108 explicit PersTariffSystem( 00109 const TsId& tsid 00110 ) : tsId_(tsid) {} 00111 00118 void setTsId(const TsId& tsid) { tsId_ = tsid; } 00119 00121 00122 00123 const TsId& tsId() const { return tsId_; } 00125 00126 public: 00127 // Documentation from base class. 00128 Type type() const { return type_; } 00129 AutoPtr clone() const; 00130 00134 std::string personalization() const; 00135 00137 bool canConfig() const; 00138 00139 private: 00158 bool readSpecific( 00159 const OSB_DB::Session& session 00160 ); 00161 00175 bool insSpecific( 00176 const OSB_DB::Session& session 00177 ); 00178 00191 bool updSpecific( 00192 const OSB_DB::Session& session 00193 ); 00194 00208 bool delSpecific( 00209 const OSB_DB::Session& session 00210 ); 00212 00213 // Documentation from base class. 00214 PersProductItem* clone_() const; 00215 00217 TsId tsId_; 00218 }; // class PersTariffSystem 00219 00229 class TariffSystemItem : public ProductItem { 00230 public: 00232 static const Type type_; 00233 00234 // Documentation from base class. 00235 typedef std::auto_ptr<TariffSystemItem> AutoPtr; 00236 00244 TariffSystemItem( 00245 const Oid& oid, 00246 const std::string& name = "", 00247 const std::string& des = "" 00248 ); 00249 00250 public: 00252 Type type() const { return type_; } 00253 00254 // Documentation from base class. 00255 AutoPtr clone() const; 00256 00265 std::auto_ptr<PersProductItem> 00266 crePersProductItem() const; 00267 00269 ProductItem::CfgType canConfigure() const { 00270 return ProductItem::cfgMandatory; 00271 } 00272 00274 ProductItem::DefPersType canDefPers() const { 00275 return ProductItem::defPersOptional; 00276 } 00277 00279 CfgPersType canPersonalize() const; 00280 00282 const PersProductItem* defPersItem() const; 00283 00284 private: 00291 00303 bool readSpecific( 00304 const OSB_DB::Session& session 00305 ); 00306 00319 bool insSpecific( 00320 const OSB_DB::Session& session 00321 ); 00322 00335 bool updSpecific( 00336 const OSB_DB::Session& session 00337 ); 00338 00350 bool delSpecific( 00351 const OSB_DB::Session& session 00352 ); 00354 00355 // Documentation from base class. 00356 ProductItem* clone_() const; 00357 00358 // Tariff system item specific methods and data: 00359 public: 00361 typedef Id<TariffSystem> TsId; 00363 typedef std::set<TsId> TsList; 00364 00375 bool addTs(const TsId& ts); 00385 bool rmTs(const TsId& ts); 00386 00388 const TsList& tsList() const; 00389 00391 void clear(); 00392 00399 const TsId& defaultTs() const; 00408 void defaultTs(const TsId& ts); 00409 00411 void clearDefaultTs(); 00412 00413 private: 00415 TsList tsList_; 00417 TsId defaultTs_; 00419 PersTariffSystem defPersTs_; 00420 }; // class TariffSystemItem 00421 00422 } 00423 #endif // #ifndef _TSITEM_H_