00001 // OSB library ************************************************ -*- C++ -*- 00006 /* 00007 AUTHOR(S): Stephan Broennimann (vb) 00008 00009 RCS information 00010 $Name: OSB_060808 $ 00011 $Revision: 1.6 $ 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 _PERSITEM_H_ 00031 #define _PERSITEM_H_ 00032 00033 // ************************************************************************ 00034 // included header files 00035 // + standard includes 00036 00037 // + libraries 00038 00039 // + local headers 00040 #include "chrono.h" 00041 #include "productitem.h" 00042 00043 // + class declarations 00044 namespace OSB_DB { 00045 class Session; 00046 class PersProductGw; 00047 } 00048 00049 namespace OSB_LIB { 00050 class PersProduct; 00051 class PersProductNode; 00052 class ProductNode; 00053 } 00054 00055 // ************************************************************************ 00056 // namespace extensions 00057 namespace OSB_LIB { 00058 00059 // ************************************************************************ 00060 // forward declarations 00061 00062 // ************************************************************************ 00063 // type definitions 00064 00065 // ************************************************************************ 00066 // class definitions 00067 00079 class PersProductItem : public ProductItemBase { 00084 friend class OSB_DB::PersProductGw; 00089 friend class PersProductNode; 00090 00091 public: 00100 typedef Id<PersProductItem> Oid; 00101 00108 typedef std::auto_ptr<PersProductItem> AutoPtr; 00109 00113 explicit PersProductItem( 00114 const Oid& oid = Oid() 00115 ) : canConfig_(false), oid_(oid) {} 00116 00117 protected: 00119 PersProductItem(const PersProductItem& rhs); 00121 PersProductItem& operator=(const PersProductItem& rhs); 00122 00123 public: 00129 AutoPtr clone() const; 00130 00132 00133 00134 const Oid& oid() const { return oid_; } 00136 const Id2<PersProductNode>& persNodeId() const; 00138 Id<PersProduct> persProductId() const; 00140 Id<ProductNode> productNodeId() const; 00142 const DateTime& assignDate() const { return assignDate_; } 00144 const DateTime& deassignDate() const { return deassignDate_; } 00146 00154 virtual std::string personalization() const = 0; 00155 00161 virtual bool canConfig() const = 0; 00162 00163 public: 00194 bool read( 00195 const OSB_DB::Session& session, 00196 bool baseRead = false 00197 ); 00198 00221 // Todo: can we remove this, let pers product do it 00222 bool update( 00223 const OSB_DB::Session& session, 00224 long objVs, 00225 bool uptodate 00226 ); 00228 00229 private: 00231 00232 00252 bool insert(const OSB_DB::Session& session); 00253 00272 bool remove(const OSB_DB::Session& session); 00273 00290 PersProductItem::AutoPtr changeConfig( 00291 const OSB_DB::Session& session 00292 ); 00293 00309 virtual bool overwrite( 00310 const OSB_DB::Session& session 00311 ); 00312 00326 virtual bool deassignOld( 00327 const OSB_DB::Session& session 00328 ); 00329 00349 virtual bool changeAssignTs( 00350 const OSB_DB::Session& session, 00351 const DateTime& newTs 00352 ); 00354 00355 protected: 00357 00358 00385 bool overwriteBase( 00386 const OSB_DB::Session& session 00387 ); 00388 00398 bool deassignOldBase( 00399 const OSB_DB::Session& session 00400 ); 00401 00421 bool changeAssignTsBase( 00422 const OSB_DB::Session& session, 00423 const DateTime& newTs 00424 ); 00426 00427 protected: 00433 virtual PersProductItem* clone_() const = 0; 00434 00435 private: 00455 virtual bool 00456 readSpecific(const OSB_DB::Session& session) = 0; 00457 00464 virtual bool 00465 insSpecific(const OSB_DB::Session& session) = 0; 00466 00474 virtual bool 00475 updSpecific(const OSB_DB::Session& session) = 0; 00476 00485 virtual bool 00486 delSpecific(const OSB_DB::Session& session) = 0; 00488 00489 protected: 00491 void setConfig(bool canConfig); 00492 protected: 00494 bool canConfig_; 00495 private: 00497 Oid oid_; 00502 Id2<PersProductNode> persNodeId_; 00504 ProductItem::Oid itemId_; 00509 DateTime assignDate_; 00517 DateTime deassignDate_; 00518 }; // class PersProductItem 00519 } // namespace OSB_LIB 00520 00521 // ************************************************************************ 00522 // inline definitions 00523 namespace OSB_LIB { 00524 } // namespace OSB_LIB 00525 #endif // #ifndef _PERSITEM_H_