DGD Library
Version: 0.1.0.14 | Updated: Thu Aug 10 16:58:58 2006
Home
DGD News
FAQ
Code Documentation
DGD Installation Guide
Bugs-n-Features
DGD at Sourceforge.net
Download DGD
Subversion
Code Documentation
Documentation
Namespaces
Class Hierarchy
Class List
File List
Namespace Members
Functions
Globals
Tutorial
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

dgMultifileLog.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //
00003 // $Id$
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //
00019 // This file is part of Depression Glass library.
00020 //
00021 // Copyright (c) 2002. Dimitry Kloper <kloper@users.sf.net> . 
00022 //
00023 // dgMultifileLog.h -- multifile log funnel
00024 //
00025 
00026 #ifndef _dgMultifileLog_h_
00027 #define _dgMultifileLog_h_
00028 
00035 #include <iostream>
00036 #include <fstream>
00037 #include <string>
00038 
00039 #include "dgFunnel.h"
00040 
00041 namespace DGD {
00042 
00063 class multifile_log: public funnel {
00064    public:
00076       class Split_criteria {
00077          public:
00078             virtual bool operator () ( unsigned long volume,
00079                                        unsigned long line, 
00080                                        unsigned long column,
00081                                        unsigned long bytes ) const = 0;
00082       };
00083 
00088       class Dont_split: public Split_criteria {
00089          public:
00090             bool operator () (  unsigned long volume,
00091                                 unsigned long line, 
00092                                unsigned long column,
00093                                unsigned long bytes ) const { return false; };
00094       };
00095 
00101       class Split_by_size: public Split_criteria  {
00102          public:
00103             Split_by_size() : m_vol_size(1024*1024*5) {} // 5M per volume
00104             Split_by_size( unsigned long vol_size ) : m_vol_size(vol_size) {}
00105 
00106             bool operator () ( unsigned long volume,
00107                                unsigned long line, 
00108                                unsigned long column,
00109                                unsigned long bytes ) const { 
00110                return ( bytes >= volume * m_vol_size ); 
00111             }
00112          private:
00113             unsigned long m_vol_size;
00114       };
00115 
00121       class Split_by_lines: public Split_criteria  {
00122          public:
00123             Split_by_lines() : m_vol_size(60000) {} // ~5M per volume
00124             Split_by_lines( unsigned long vol_size ) : m_vol_size(vol_size) {}
00125             Split_by_lines( const Split_by_lines& peer ) : 
00126                m_vol_size( peer.m_vol_size ) {}
00127 
00128             bool operator () ( unsigned long volume,
00129                                unsigned long line, 
00130                                unsigned long column,
00131                                unsigned long bytes ) const { 
00132                return ( line >= volume * m_vol_size ); 
00133             }
00134          private:
00135             unsigned long m_vol_size;
00136       };
00137 
00138    public:
00139       static Dont_split dont_split;
00140       static Split_by_size split_by_size;
00141       static Split_by_lines split_by_lines;
00142             
00143    public:
00144       multifile_log( const char* name, 
00145                      Split_criteria* criteria = &split_by_size );
00146       ~multifile_log();
00147 
00148    private:
00149       void operator () ( unsigned long line, 
00150                          unsigned long column,
00151                          unsigned long bytes );
00152       std::string real_name() const;
00153       
00154    private:
00155       std::ofstream m_file;
00156       std::string   m_name;
00157       unsigned int  m_part_count;
00158       Split_criteria* m_split;
00159 };
00160 
00161 
00162 }; // end of namespace DGD
00163 
00164 #endif /* _dgMultifileLog_h_ */
00165 
00166 /* 
00167  * Local Variables:
00168  * compile-command: "make dgMultifileLog.obj"
00169  * End:
00170  */
00171 
00172 

Generated on Thu Aug 10 16:48:28 2006 for DGD Library by doxygen1.3

SourceForge.net Logo Powered by Mason Powered by Perl
Web design derived from Pasilda design found on www.oswd.org.
Copyright (c) 2002, 2003. Dimitry Kloper <kloper@users.sourceforge.net>