00001 // -*- c++ -*- 00002 // 00003 // 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 // dgDebug.h -- channel factory 00024 // 00025 00026 #ifndef _dgDebug_h_ 00027 #define _dgDebug_h_ 00028 00034 #include <iostream> 00035 #include <fstream> 00036 #include <string> 00037 #include <list> 00038 00039 #include <boost/smart_ptr.hpp> 00040 00041 #include "dgConfig.h" 00042 #include "dgStream.h" 00043 #include "dgChannel.h" 00044 #include "dgFunnel.h" 00045 #include "dgChannelManip.h" 00046 #include "dgDebugExtra.h" 00047 #include "dgDebugStd.h" 00048 #include "dgDebugOpt.h" 00049 #include "dgOptionFilter.h" 00050 00054 namespace DGD { 00055 00096 class Debug { 00097 public: 00098 typedef channel& channel_ref; 00099 typedef boost::shared_ptr<Debug> debug_factory_ref; 00100 typedef boost::shared_ptr<channel> channel_ptr; 00101 00102 public: 00103 Debug(); 00104 ~Debug(); 00105 00106 void process_options( int argc, char** argv ); 00107 void process_options( const option_filter::option_set_type& options ); 00108 00109 stream create_file ( const std::string& name ); 00110 stream append_file ( const stream& file ); 00111 stream prepend_file ( const stream& file ); 00112 stream main_file() const; 00113 channel& create_channel( const std::string& name ); 00114 operator channel_ref () const; 00115 channel_ptr operator[] ( const std::string& name ); 00116 void current( const std::string& name ); 00117 channel_ptr current() const; 00118 void flush(); 00119 00120 public: 00121 static debug_factory_ref debug_factory; 00122 static debug_factory_ref factory(); 00123 static debug_factory_ref create_factory( int argc, char** argv ); 00124 static debug_factory_ref create_factory( 00125 const option_filter::option_set_type& options ); 00126 00127 protected: 00128 typedef std::list< channel_ptr > Channel_list; 00129 typedef Channel_list::iterator Channel_iterator; 00130 typedef std::list< stream > File_list; 00131 00132 protected: 00133 void apply_options( channel_ptr& chnl ); 00134 00135 private: 00136 Channel_list m_channels; 00137 Channel_iterator m_current_channel; 00138 File_list m_files; 00139 stream m_main_file; 00140 00141 options m_args_info; 00142 option_locations m_args_given; 00143 }; 00144 00145 }; // end of namespace DGD 00146 00147 #endif /* _dgDebug_h_ */ 00148 00149 /* 00150 * Local Variables: 00151 * compile-command: "make dgDebug.obj" 00152 * End: 00153 */ 00154 00155