credit.h

Go to the documentation of this file.
00001 // OSB library ********************************************* -*- C++ -*-
00010 /*
00011   AUTHOR(S): Lilian Qin Lan (lan)
00012 
00013   RCS information
00014    $Name: OSB_060808 $
00015    $Revision: 1.40 $
00016 
00017   License
00018    OSB rating and billing library for communication networks
00019    Copyright (C) 2004, 2005, 2006  OSB systems
00020 
00021    This file may be distributed and/or modify under the terms of the
00022    GNU General Public License (GPL) as published by the Free Software
00023    Foundation which is provided in the file LICENSE.GPL included in the
00024    packaging of this file.
00025 
00026    The file is distributed in the hope that it will be useful, but WITHOUT
00027    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00028    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00029    for more details.
00030 
00031    Holders of a OSB Commercial License may use this file under the terms
00032    and conditions of this commercial license.
00033  */
00034 #ifndef _CREDIT_H_
00035 #define _CREDIT_H_
00036 
00037 // *********************************************************************
00038 // included header files
00039 // + standard includes
00040 
00041 // + local headers
00042 #include "productitem.h"
00043 #include "persitem.h"
00044 #include "money.h"
00045 
00046 // *********************************************************************
00047 // class declarations
00048 namespace OSB_DB {
00049     class CreditItemGw;
00050     class PersCreditGw;
00051 }
00052 
00053 // *********************************************************************
00054 // namespace extensions
00055 namespace OSB_LIB {
00056 
00057 // *********************************************************************
00058 // type definitions
00059 
00060 // *********************************************************************
00061 // class definitions
00062 
00068     class PersCredit : public PersProductItem {
00070         friend class OSB_DB::PersCreditGw;
00071     public:
00073         static const Type type_;
00074 
00075         // Documentation from base class.
00076         typedef std::auto_ptr<PersCredit> AutoPtr;
00077 
00078     public:
00080         explicit PersCredit(
00081             const Oid&   oid    = Oid(),
00082             const Money& credit = Money()
00083         ) : PersProductItem(oid), credit_(credit)
00084         {
00085             // empty
00086         }
00087 
00089         explicit PersCredit(
00090             const Money& credit
00091         ) : credit_(credit)
00092         {
00093             // empty
00094         }
00095 
00096     public:
00098         Type type() const;
00099 
00100         // Documentation from base class.
00101         AutoPtr clone() const;
00102 
00111         virtual std::string personalization() const;
00112 
00114         virtual bool canConfig() const;
00115 
00117         const Money& credit() const { return credit_; }
00118 
00137         bool add(
00138             const OSB_DB::Session& session,
00139             const Money&           money,
00140                   long             objVs,
00141                   bool             uptodate
00142         );
00143 
00162         bool deduct(
00163             const OSB_DB::Session& session,
00164             const Money&           money,
00165                   long             objVs,
00166                   bool             uptodate
00167         );
00168 
00195         bool lock(const OSB_DB::Session& session);
00196 
00225         bool unlock(
00226             const OSB_DB::Session& session,
00227                   bool             nowait
00228         );
00229     private:
00231 
00232 
00238         bool readSpecific(const OSB_DB::Session& session);
00239 
00247         bool insSpecific(const OSB_DB::Session& session);
00248 
00257         bool updSpecific(const OSB_DB::Session& session);
00258 
00267         bool delSpecific(const OSB_DB::Session& session);
00269 
00270         // Documentation from base class.
00271         PersProductItem* clone_() const;
00272 
00273     private:
00275         Money credit_;
00276     };                                  // class PersCredit
00277 
00286     class CreditItem : public ProductItem {
00288         friend class OSB_DB::CreditItemGw;
00289 
00290     public:
00292         static const Type type_;
00293         // Documentation from base class.
00294         typedef std::auto_ptr<CreditItem> AutoPtr;
00295 
00296     public:
00298         CreditItem(const ProductItem::Oid& oid);
00299 
00301         CreditItem(const ProductItem::Oid& oid,
00302                    const std::string&      name,
00303                    const std::string&      des,
00304                    const Money&            money);
00305 
00306     public:
00308         Type type() const;
00309 
00310         // Documentation from base class.
00311         AutoPtr clone() const;
00312 
00321         std::auto_ptr<PersProductItem> crePersProductItem() const;
00322 
00324         const Money& initValue() const;
00325 
00327         void setInitValue(const Money& money);
00328 
00330         ProductItem::CfgType canConfigure() const
00331         {
00332             return ProductItem::cfgNone;
00333         }
00334 
00336         ProductItem::DefPersType canDefPers() const
00337         {
00338             return ProductItem::defPersMandatory;
00339         }
00340 
00342         virtual CfgPersType canPersonalize() const;
00343 
00345         const PersProductItem* defPersItem() const;
00346 
00347     private:
00349 
00350 
00358         bool readSpecific(const OSB_DB::Session& session);
00359 
00367         bool insSpecific(const OSB_DB::Session& session);
00368 
00377         bool updSpecific(const OSB_DB::Session& session);
00378 
00387         bool delSpecific(const OSB_DB::Session& session);
00389 
00390         // Documentation from base class.
00391         ProductItem* clone_() const;
00392 
00393     private:
00395         PersCredit defPersCredit_;
00396     };                                  // class CreditItem
00397 
00398 // *********************************************************************
00399 // inline definitions
00400 
00401 }
00402 #endif                                  // #ifndef _CREDIT_H_

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