wx_debugging_base.h

Go to the documentation of this file.
00001 #ifndef WX_DEBUGGER_BASE_CLASS
00002 #define WX_DEBUGGER_BASE_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : wx_debugging_base                                                 *
00007 *  Author : Aaron Buchanan                                                    *
00008 *  Author : Chris Koeritz                                                     *
00009 *                                                                             *
00010 *  Purpose:                                                                   *
00011 *                                                                             *
00012 *    A shared set of operations on edit controls that permits different       *
00013 *  manners of creating and presenting the windows that really show the info.  *
00014 *                                                                             *
00015 *******************************************************************************
00016 * Copyright (c) 1995-$now By Author.  This program is free software; you can  *
00017 * redistribute it and/or modify it under the terms of the GNU General Public  *
00018 * License as published by the Free Software Foundation; either version 2 of   *
00019 * the License or (at your option) any later version.  This is online at:      *
00020 *     http://www.fsf.org/copyleft/gpl.html                                    *
00021 * Please send any updates to: fred@gruntose.com                               *
00022 \*****************************************************************************/
00023 
00024 #include "wx_debugger.h"
00025 
00026 #include <basis/log_base.h>
00027 #include <basis/portable.h>
00028 
00029 // forward.
00030 class file_logger;
00031 class uls;
00032 class wxTextCtrl;
00033 
00034 class WX_EXTENSIONS_CLASS_STYLE wx_debugging_base : public log_base
00035 {
00036 public:
00037   wx_debugging_base(wxTextCtrl &to_manipulate, int buffer_size = 2 * MEGABYTE,
00038           int file_size = int(1.2 * MEGABYTE));
00039     // the editor "to_manipulate" is managed by this object as the repository
00040     // for the debugging information.  the "buffer_size" is the maximum number
00041     // of characters allowed in the editor.  the size is ignored on w9x.
00042 
00043   virtual ~wx_debugging_base();
00044 
00045   IMPLEMENT_CLASS_NAME("wx_debugging_base");
00046 
00047   void setup();
00048     // this must be called when appropriate.  the wxTextCtrl must be a valid window
00049     // at the time this method is invoked.
00050 
00051   void shut_down();
00052     // prepares the object for destruction by closing down any networked
00053     // logging support.
00054 
00055   int current_length();
00056     // returns the current length of the edit buffer.
00057 
00058   // logs a message to the log file and window, as required by log_base.
00059   // it uses the current ending as set in our members.
00060   virtual outcome log(const istring &info, int filter = ALWAYS_PRINT);
00061 
00062   // logs a message to the logging file, if one exists, and allows the ending
00063   // to be specified separately.
00064   void log_ending(const istring &to_show, int filter = ALWAYS_PRINT,
00065           line_ending ending = CRLF_AT_END);
00066 
00067   void display_message(byte_array &message);
00068     // logging a message through the debugger after cracking it open
00069 
00070   // prints a message to the window and logs it.  this is just a synonym for
00071   // log() above.
00072   outcome print(const istring &to_show, int filter = ALWAYS_PRINT)
00073           { return log(to_show, filter); }
00074 
00075   istring name() const;
00076   void name(const istring &new_name);
00077     // allows the file name for logging to be observed or modified.
00078 
00079   int buffer_limit();
00080   void buffer_limit(int new_limit);
00081     // observes or modifies the limit on the buffer length.
00082 
00083   int file_limit() const;
00084   void file_limit(int new_limit);
00085     // allows the log file size limit to be observed or modified.
00086 
00087   void go_to_end();
00088     // causes the window to jump to the last line such that all future output
00089     // scrolls from there.
00090 
00091   bool get_contents(istring &to_fill);
00092     // returns the entire current contents of the window as a string.  true is
00093     // returned if we succeeded in getting the contents.
00094 
00095   bool get_selection(int &start, int &end);
00096     // returns the selection position for the edit window.  false is returned
00097     // if nothing is currently selected, although the "start" and "end" will
00098     // still be set correctly.
00099 
00100   void select(int start, int end);
00101     // selects the text in the window between "start" and "end" if possible.
00102 
00103   void reset();
00104     // clears all text out of the debugging console.
00105 
00106   wxTextCtrl &get_editor();
00107     // allows access to the lower-level object used for the editing window.
00108 
00109 private:
00110   wxTextCtrl &_editor;  // the edit window object.
00111   int _length;
00112     // current length (our internal count; might not be accurate to exact
00113     // buffer contents).
00114   int _maximum_active_length;  
00115     // this is the point at which the information in the debugging window is
00116     // shortened.  the top chunk is clipped to ensure that the buffer doesn't
00117     // overflow (because there are varying results when this happens, depending
00118     // on the platform).
00119   int _file_limit;  // the maximum length the log file can attain.
00120   istring *_log_name;  // the name of the log file or stream.
00121 #ifndef LIGHTLINK_CODEBASE
00122   file_logger *_the_log;  // handles logging to files.
00123 #else
00124   uls *_the_log;  // handles logging to a uls stream.
00125 #endif
00126 
00127   int locked_current_length();  // the real function, for internal use only.
00128 };
00129 
00130 #endif
00131 

Generated on Fri Nov 28 04:29:06 2008 for HOOPLE Libraries by  doxygen 1.5.1