taxkey.h

Go to the documentation of this file.
00001 // OSB library ********************************************* -*- C++ -*-
00009 /*
00010   AUTHOR(S): Lilian Qin Lan (lan)
00011 
00012   RCS information
00013    $Name: OSB_060808 $
00014    $Revision: 1.16 $
00015 
00016   License
00017    OSB rating and billing library for communication networks
00018    Copyright (C) 2004, 2005, 2006  OSB systems
00019 
00020    This file may be distributed and/or modify under the terms of the
00021    GNU General Public License (GPL) as published by the Free Software
00022    Foundation which is provided in the file LICENSE.GPL included in the
00023    packaging of this file.
00024 
00025    The file is distributed in the hope that it will be useful, but WITHOUT
00026    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00027    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00028    for more details.
00029 
00030    Holders of a OSB Commercial License may use this file under the terms
00031    and conditions of this commercial license.
00032  */
00033 #ifndef _TAXKEY_H_
00034 #define _TAXKEY_H_
00035 
00036 // *********************************************************************
00037 // included header files
00038 // + standard includes
00039 #include <string>
00040 #include <vector>
00041 
00042 // + local headers
00043 #include "osbid.h"
00044 
00045 
00046 // *********************************************************************
00047 // class declarations
00048 namespace OSB_DB {
00049     class Session;
00050     class TaxKeyGw;
00051 }
00052 
00053 // *********************************************************************
00054 // namespace extensions
00055 namespace OSB_LIB {
00066     enum TaxKeyType {
00068         tktUnknown   = '\0',
00070         tktAssociate = 'a',
00072         tktContract  = 'c',
00074         tktProduct   = 'p'
00075     };
00076 
00083     char toChar(TaxKeyType tkt);
00084 
00096     TaxKeyType toTaxKeyType(char c);
00097 
00101     class TaxKey {
00102         friend class OSB_DB::TaxKeyGw;
00103     public:
00105         typedef Id<TaxKey> Oid;
00106 
00108         TaxKey(Oid oid = Oid(ID_NOT_SET)): oid_(oid) {}
00109 
00111         TaxKey(const Oid&         oid,
00112                const std::string& name,
00113                const TaxKeyType   tkt,
00114                bool               wildCard = false
00115                ): oid_(oid), name_(name), type_(tkt),
00116                   wildCard_(wildCard) {}
00117 
00119 
00120         const Oid& oid() const { return oid_; }
00121         const std::string& name() const { return name_; }
00122         const TaxKeyType& type() const { return type_; }
00123         bool wildCard() const { return wildCard_; }
00125 
00134         bool read(const OSB_DB::Session& session);
00135 
00144         bool insert(const OSB_DB::Session& session);
00145 
00154         bool remove(const OSB_DB::Session& session);
00155 
00156     private:
00157         Oid         oid_;              
00158         std::string name_;             
00159         TaxKeyType  type_;             
00160 
00164         bool        wildCard_;
00165 
00166     };
00167 
00177     class TaxKeyList {
00178     public:
00180 
00181 
00182         typedef std::vector<TaxKey> List;
00184         typedef List AssociateList;
00186         typedef List ContractList;
00188         typedef List ProductList;
00190 
00200         long read(const OSB_DB::Session& session);
00201 
00209         const List& get(const TaxKeyType tkt) const;
00210 
00217         TaxKey::Oid getTaxKeyByName(const std::string& name) const;
00218 
00226         const TaxKey& getTaxKey(const TaxKey::Oid& oid) const;
00227 
00235         const TaxKey* findTaxKey(const TaxKey::Oid& oid) const;
00236 
00242         void add(const TaxKey& tk);
00243 
00245         long size() const;
00246 
00247     private:
00248         AssociateList aList_; 
00249         ContractList  cList_; 
00250         ProductList   pList_; 
00251     };
00252 }                                       // namespace OSB_LIB
00253 #endif                                  // #ifndef _TAXKEY_H_

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