DGD Library
Version: 0.1.0.14 | Updated: Thu Aug 10 16:57:43 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  

DGD::Debug Class Reference

DGD channel factory. More...

#include <dgDebug.h>

List of all members.

Public Types

Public Member Functions

Static Public Member Functions

Static Public Attributes

Protected Types

Protected Member Functions

Private Attributes


Detailed Description

DGD channel factory.

The factory is used to create channels and streams those channels can be associated with. Currently only file streams are supported. Use Debug::create_file(const std::string&) to create a file stream and Debug::create_channel(const std::string&) to create a channel. The channels can be accessed by name using Debug::operator[].

There must be a single object of this class during the application lifetime. The best way to allocate this object is by calling static method Debug::create_factory(int,char**). The best way to get a pointer to the object is by calling static method Debug::factory(). You can also use static variable Debug::debug_factory, but this is less preferred way.

The factory is initialized with a channel called "main" it is not associated with any file by default. The main channel is opened by the factory. The factory creates no default file, but it can be created by specifying "--debug-main-file" option, see below. If the option has been specified, the main file stream will be created. Use Debug::main_file() to access that stream.

You can use notion of current channel to use the DGD::Debug object as a regular channel. By default main channel is a current channel, you can use Debug::current(const std::string&) method to select the current channel, and Debug::current() method to explicitly query pointer to the current channel. Except that DGD::Debug can be casted to reference to channel, for example:

 DGD::channel& chnl = (DGD::channel&)(*Debug::factory());
 chnl << "Hello World" << std::endl;

DGD::Debug can be controlled by command line options. Use Debug::process_options(int,char**) method to pass the options as received by main() function or use DGD::option_filter to create custom option sets.


Member Typedef Documentation

typedef channel& DGD::Debug::channel_ref
 

typedef boost::shared_ptr<Debug> DGD::Debug::debug_factory_ref
 

typedef boost::shared_ptr<channel> DGD::Debug::channel_ptr
 

typedef std::list< channel_ptr > DGD::Debug::Channel_list [protected]
 

typedef Channel_list::iterator DGD::Debug::Channel_iterator [protected]
 

typedef std::list< stream > DGD::Debug::File_list [protected]
 


Constructor & Destructor Documentation

DGD::Debug::Debug  ) 
 

Default constructor.

Initializes the factory and opens the main channel.

DGD::Debug::~Debug  ) 
 

Destructor.

All memory is deallocated automatically by smart pointers. This destructor flushes all files and channels.

See also:
Debug::Debug()


Member Function Documentation

void DGD::Debug::process_options int argc,
char ** argv
 

Process command line options.

This method applies the command line options set on the DGD::Debug object and its channels.

The following options are accepted:

--trace-version
Print DGD version to std::cout and exit the application (actually throw DGD::exit_required exception).
--trace-help
Print DGD help to std::cout and exit the application (actually throw DGD::exit_required exception).
--trace-enable
Enable trace. By default the trace logging is disabled. This command line option enables it. Debug::process_options(int,char**) will throw debug_disabled exception if this option is not specified on command line.
--trace-main-file
Create the main file. This option must be specified with a string argument which defines the main file name. The main file is created and its stream can be queried by Debug::main_file().
--trace-min-width
Set default minimum line width for all existing and future channels. This option must be specified with an integer parameter which defines the default minimum line width.
--trace-max-width
Set default maximum line width for all existing and future channels. This option must be specified with an integer parameter which defines the default maximum line width.
--trace-indent-step
Set default indentation step for all existing and future channels. This option must be specified with an integer parameter which defines the default indentation step.
--trace-allow-wrap
Set default character wrapping policy for all existing and future channels.
--trace-allow-word-wrap
Set default word wrapping policy for all existing and future channels.
--trace-space-characters
Set default space character set for all existing and future channels. This option must be specified with a string parameter which defines the default space characters.
--trace-turn-on
Turn on (open) channels. This option must be specified with a string parameter which defines a regular expression. This regexp is applied on the current channel list. All channels with names matching the regexp will be opened.
--trace-turn-off
Turn off (close) channels. This option must be specified with a string parameter which defines a GNU regular exception. This regexp is applied on the current channel list. All channels with names matching the regexp will be closed.

void DGD::Debug::process_options const option_filter::option_set_typeoptions ) 
 

Process command line options.

This method applies the command line options set on the DGD::Debug object and its channels. See Debug::process_options(int,char**) for more info.

stream DGD::Debug::create_file const std::string & name ) 
 

Create a file stream.

This method will return NULL stream if the file can't be created.

stream DGD::Debug::append_file const streamfile ) 
 

Append a file stream to the stream list.

This one is used when the application must create the stream by itself. Note that the stream will be deallocated by the smart pointer.

stream DGD::Debug::prepend_file const streamfile ) 
 

Prepend a file stream to the stream list.

This one is used when the application must create the stream by itself. Note that the stream will be deallocated by the smart pointer.

stream DGD::Debug::main_file  )  const
 

Return main file stream.

channel & DGD::Debug::create_channel const std::string & name ) 
 

Create channel.

This method creates a new channel if there is no channel with the given name in the channels list. If a channel with the given name does already exist it is returned.

See also:
Debug::operator[]

DGD::Debug::operator Debug::channel_ref )  const
 

int Debug::operator channel_ref ( ) const DGD::Debug to DGD::channel& conversion.

Returns current channel.

Debug::channel_ptr DGD::Debug::operator[] const std::string & name ) 
 

Get channel by name.

Returns:
Pointer to the channel with the given name or NULL.
See also:
Debug::create_channel(const std::string&)

void DGD::Debug::current const std::string & name ) 
 

Set current channel.

See also:
Debug::current()

Debug::channel_ptr DGD::Debug::current  )  const
 

Return current channel.

See also:
Debug::current(const std::string&)

void DGD::Debug::flush  ) 
 

Flush all channels and files.

Debug::debug_factory_ref DGD::Debug::factory  )  [static]
 

Return pointer to the global Debug factory.

See also:
Debug::create_factory(int,char**)

Debug::debug_factory_ref DGD::Debug::create_factory int argc,
char ** argv
[static]
 

Create global Debug factory.

This function must be called at most once during the application lifetime. It creates the factory and calls Debug::process_options(int,char**).

Returns:
This method returns a smart pointer to the factory. This smart pointer must be used to ensure proper factory destruction, even when the application crashes. Usually you need only a single instance of the pointer:
 int main( int argc, char** argv ) {
     using namespace DGD;
     debug_factory_ref factory = create_factory( argc, argv );
     ...
 }
Note that the 'factory' variable is destructed always when main() does exit. It will be destructed even if application crashes on unexpected exception. It is bad idea to make this variable global or static since not all compilers ensure that global variables are destructed on the crash (at least msvc6.0sp5 does not).
See also:
Debug::debug_factory

Debug::factory()

Debug::debug_factory_ref DGD::Debug::create_factory const option_filter::option_set_typeoptions )  [static]
 

Create global Debug factory.

This function must be called at most once during the application lifetime. See Debug::create_factory(int,char**) for more info.

void DGD::Debug::apply_options channel_ptrchnl )  [protected]
 

Apply default channel-specific options on given channel.

See also:
Debug::process_options(int,char**)


Member Data Documentation

Debug::debug_factory_ref DGD::Debug::debug_factory [static]
 

Global Debug factory pointer .

Use this global static variable with care. It is initialized by Debug::create_factory(int,char**). This variable is not const, nor const pointer, but changing this variable directly is not recommended.

See also:
Debug::create_factory(int,char**)

Debug::factory()

Channel_list DGD::Debug::m_channels [private]
 

Channel_iterator DGD::Debug::m_current_channel [private]
 

File_list DGD::Debug::m_files [private]
 

stream DGD::Debug::m_main_file [private]
 

options DGD::Debug::m_args_info [private]
 

option_locations DGD::Debug::m_args_given [private]
 


The documentation for this class was generated from the following files:
Generated on Thu Aug 10 16:48:30 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>