cdrioimpl.h

Go to the documentation of this file.
00001 // OSB library ********************************************* -*- C++ -*-
00012 /*
00013   AUTHOR(S): Stephan Broennimann (vb)
00014 
00015   RCS information
00016    $Name: OSB_060808 $
00017    $Revision: 1.15 $
00018 
00019   License
00020    OSB rating and billing library for communication networks
00021    Copyright (C) 2004, 2005, 2006  OSB systems
00022 
00023    This file may be distributed and/or modify under the terms of the
00024    GNU General Public License (GPL) as published by the Free Software
00025    Foundation which is provided in the file LICENSE.GPL included in the
00026    packaging of this file.
00027 
00028    The file is distributed in the hope that it will be useful, but WITHOUT
00029    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00030    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00031    for more details.
00032 
00033    Holders of a OSB Commercial License may use this file under the terms
00034    and conditions of this commercial license.
00035  */
00036 #ifndef _CDRIOIMPL_H_
00037 #define _CDRIOIMPL_H_
00038 
00039 // *********************************************************************
00040 // included header files
00041 // + standard includes
00042 #include <iosfwd>
00043 #include <map>
00044 #include <list>
00045 #include <set>
00046 
00047 // + local headers
00048 #include "osbid.h"
00049 #include "cdrio.h"
00050 
00051 // *********************************************************************
00052 // class declarations
00053 namespace OSB_LIB {
00054     class Asn1Writer;
00055     class Date;
00056     class BsPage;
00057 }
00058 
00059 // *********************************************************************
00060 // namespace extensions
00061 namespace OSB_LIB {
00062 
00063 // *********************************************************************
00064 // class definitions
00065     // class CdrIoImpl
00075     class CdrIoImpl : public CdrIo {
00076     public:                             // construction
00078         CdrIoImpl(const Id<BsPage>& pageId);
00079 
00080     public:                             // interface implementation
00081         // Documentation from base class.
00082         std::auto_ptr<CdrIo> clone() const;
00083 
00084         // Documentation from base class.
00085         const Id<BsPage>& pageId() const;
00086 
00087         // Documentation from base class.
00088         void read(CdrList& dest);
00089 
00090         // Documentation from base class.
00091         void prepareWrite();
00092 
00093         // Documentation from base class.
00094         void write(
00095             const CdrList&    cdrs,
00096                   Asn1Writer& writer
00097         );
00098 
00099         // Documentation from base class.
00100         void replace(
00101             const CdrList&    newCdrs,
00102                   Asn1Writer& writer
00103         );
00104 
00105         // Documentation from base class.
00106         bool commitChanges();
00107 
00108         // Documentation from base class.
00109         bool undoChanges();
00110 
00111         // Documentation from base class.
00112         bool remove();
00113 
00114     private:
00116         typedef std::map<Date, CdrList> CdrGroups;
00118         typedef std::set<std::string> PathList;
00119 
00120     private:
00131         size_t getCdrFiles(
00132             const std::string& dirName,
00133                   PathList&    dest
00134         );
00135 
00146         size_t getSubDirs(
00147             const std::string& dirName,
00148                   PathList&    dest
00149         );
00150 
00160         void read(
00161                   CdrList&     dest,
00162             const std::string& path
00163         );
00164 
00174         void write(
00175             const CdrList&    cdrs,
00176                   Asn1Writer& writer,
00177                   bool        mkBackup
00178         );
00179 
00185         std::string pageDir() const;
00186 
00194         std::string mkFilename(long n) const;
00195 
00208         void moveFileAway(const std::string& path);
00209 
00221         void groupCdrsByDate(
00222                   CdrGroups& dest,
00223             const CdrList&   src
00224         );
00225 
00249         FILE* openOutputFile(
00250             std::string& path,
00251             bool         mkBackup
00252         );
00253 
00268         std::string newCdrFile(
00269             const std::string& dirName,
00270                   size_t       numFiles
00271         ) const;
00272 
00273 
00284         std::string renameCdrFile(
00285             const std::string& filePath,
00286             const std::string& extTo
00287         );
00288 
00301         void copyFile(
00302             const std::string& from,
00303             const std::string& to
00304         );
00305 
00318         bool removeChangedFiles();
00319 
00328         bool removeChangedFile(const std::string& path);
00329 
00345         bool restoreCdrFiles();
00346 
00364         bool restoreCdrFile(const std::string& path);
00365 
00366     private:
00368         static const std::string extBak_;
00370         static const std::string extCdr_;
00372         static const std::string extRpl_;
00373 
00374     private:
00376         Id<BsPage> pageId_;
00378         PathList changedFiles_;
00380         PathList recoverFiles_;
00381     };                                  // class CdrIoImpl
00382 }                                       // namespace OSB_LIB
00383 #endif                                  // #ifndef _CDRIOIMPL_H_

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