|
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::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
| Default constructor. Initializes the factory and opens the main channel. |
| 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.
|
| 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. |
| 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. |
| 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 |
|
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[]
|
void DGD::Debug::current | ( | const std::string & | name | ) | |
|
void DGD::Debug::flush | ( | | ) | |
|
| Flush all channels and files. |
| 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: 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()
|
void DGD::Debug::apply_options | ( | channel_ptr & | chnl | ) | [protected] |
|
Member Data Documentation
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 1.3
|