device.h

Go to the documentation of this file.
00001 // OSB library ************************************************ -*- C++ -*-
00006 /*
00007   AUTHOR(S): Stephan Broennimann (vb)
00008 
00009   RCS information
00010    $Name: OSB_060808 $
00011    $Revision: 1.13 $
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 _DEVICE_H_
00031 #define _DEVICE_H_
00032 
00033 // ************************************************************************
00034 // included header files
00035 // + standard includes
00036 
00037 // + libraries
00038 
00039 // + local headers
00040 #include "osbid.h"
00041 #include "osbtype.h"
00042 
00043 // + class declarations
00044 namespace OSB_DB {
00045     class DeviceGw;
00046     class Session;
00047 }
00048 
00049 namespace OSB_LIB {
00050     class InventoryPool;
00051     class PersDevice;
00052 }
00053 
00054 // ************************************************************************
00055 // namespace extensions
00056 namespace OSB_LIB {
00057 
00058 // ************************************************************************
00059 // forward declarations
00060 
00061 // ************************************************************************
00062 // type definitions
00063 
00064 // ************************************************************************
00065 // class definitions
00069     class Device {
00071         friend class OSB_DB::DeviceGw;
00073         friend class PersDevice;
00074     public:
00076         typedef TypeId<Device> Type;
00078         typedef Id<Device> Oid;
00080         typedef Id<InventoryPool> PoolId;
00081 
00093         enum Status {
00095             dvcUnknown = '\0',
00100             dvcCreated    = 'c',
00102             dvcAvailable  = 'v',
00104             dvcAssigned   = 'a',
00108             dvcDeactivated = 'd'
00109         };
00110 
00111     public:
00113         explicit Device(const Oid& oid = Oid());
00115         virtual ~Device();
00116     protected:
00118         Device(const Device& rhs);
00120         Device& operator=(const Device& rhs);
00121 
00122     public:
00124         Oid oid() const;
00126         virtual Type type() const = 0;
00128         Status status() const;
00134         PoolId poolId() const;
00135 
00143         void setPool(
00144             const PoolId poolId
00145         );
00158         virtual void setStatus(
00159             const Status newStatus
00160         );
00161 
00162     public:
00173         static void lock(
00174             const OSB_DB::Session& session,
00175             const Oid&             id,
00176                   bool             noWait
00177         );
00178 
00187         void lock(
00188             const OSB_DB::Session& session,
00189                   bool             noWait
00190         ) const;
00191 
00193 
00194 
00201         virtual void read(
00202             const OSB_DB::Session& session
00203         ) = 0;
00219         virtual void saveData(
00220             const OSB_DB::Session& session,
00221                   bool             noWait
00222         ) = 0;
00237         virtual void updStatus(
00238             const OSB_DB::Session& session,
00239                   bool             noWait
00240         );
00252         virtual void remove(
00253             const OSB_DB::Session& session,
00254                   bool             noWait
00255         ) = 0;
00257 
00258     protected:
00270         static void handleObjectStatus(
00271                   ObjectStatus os,
00272             const Oid&         id
00273         );
00274 
00276 
00277 
00285         void readBase(
00286             const OSB_DB::Session& session
00287         );
00295         void insertBase(
00296             const OSB_DB::Session& session
00297         );
00307         void updDataBase(
00308             const OSB_DB::Session& session,
00309                   bool             noWait
00310         );
00321         void removeBase(
00322             const OSB_DB::Session& session
00323         );
00335         void incObjVs(const OSB_DB::Session& session);
00337 
00338     private:                            // for PersDevice only
00346         void setAssigned(
00347             const OSB_DB::Session& session
00348         );
00357         void setUnAssigned(
00358             const OSB_DB::Session& session
00359         );
00368         void setDeassigned(
00369             const OSB_DB::Session& session
00370         );
00371     private:
00381         void updStatusNoLock(
00382             const OSB_DB::Session& session
00383         );
00384     private:
00386         Oid oid_;
00388         long objVs_;
00390         Status status_;
00392         PoolId poolId_;
00393     };                                  // class Device
00394 }                                       // namespace OSB_LIB
00395 
00396 // ************************************************************************
00397 // inline definitions
00398 namespace OSB_LIB {
00399 }                                       // namespace OSB_LIB
00400 #endif                                  // #ifndef _DEVICE_H_

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