Main Page   Reference Manual   Namespace List   Compound List   Namespace Members   Compound Members   File Members  

class_fatal_channel.h

Go to the documentation of this file.
00001 // $Header: /cvsroot/libcwd/libcwd/include/libcwd/class_fatal_channel.h,v 1.5 2004/06/03 12:23:07 libcw Exp $
00002 //
00003 // Copyright (C) 2000 - 2004, by
00004 // 
00005 // Carlo Wood, Run on IRC <carlo@alinoe.com>
00006 // RSA-1024 0x624ACAD5 1997-01-26                    Sign & Encrypt
00007 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6  F6 F6 55 DD 1C DC FF 61
00008 //
00009 // This file may be distributed under the terms of the Q Public License
00010 // version 1.0 as appearing in the file LICENSE.QPL included in the
00011 // packaging of this file.
00012 //
00013 
00018 #ifndef LIBCWD_CLASS_FATAL_CHANNEL_H
00019 #define LIBCWD_CLASS_FATAL_CHANNEL_H
00020 
00021 #ifndef LIBCWD_CONFIG_H
00022 #include <libcwd/config.h>
00023 #endif
00024 #ifndef LIBCWD_MAX_LABEL_LEN_H
00025 #include <libcwd/max_label_len.h>
00026 #endif
00027 #ifndef LIBCWD_CONTROL_FLAG_H
00028 #include <libcwd/control_flag.h>
00029 #endif
00030 
00031 namespace libcwd {
00032 
00033 //===================================================================================================
00034 // class fatal_channel_ct
00035 //
00036 // A debug channel with a special characteristic: It terminates the application.
00037 //
00038 
00039 class fatal_channel_ct {
00040 private:
00041   char WNS_label[max_label_len_c + 1];                          // +1 for zero termination.
00042     // A reference name for the represented debug channel
00043     // This label will be printed in front of each output written to
00044     // this debug channel.
00045 
00046   control_flag_t WNS_maskbit;
00047     // The mask that contains the control bit.
00048 
00049 public:
00050   //-------------------------------------------------------------------------------------------------
00051   // Constructor
00052   //
00053 
00054   // MT: All channel objects must be global so that `WNS_maskbit' is zero
00055   //     at the start of the program and initialization occurs before other
00056   //     threads share the object.
00057   explicit fatal_channel_ct(char const* lbl, control_flag_t maskbit);
00058     // Construct a special debug channel with label `lbl' and control bit `cb'.
00059 
00060   // MT: May only be called from the constructors of global objects (or single threaded functions).
00061   void NS_initialize(char const* lbl, control_flag_t maskbit LIBCWD_COMMA_TSD_PARAM);
00062     // Force initialization in case the constructor of this global object
00063     // wasn't called yet.  Does nothing when the object was already initialized.
00064 
00065 public:
00066   control_flag_t get_maskbit(void) const;
00067   char const* get_label(void) const;
00068 };
00069 
00070 } // namespace libcwd
00071 
00072 #endif // LIBCWD_CLASS_FATAL_CHANNEL_H
00073 
Copyright © 2001 - 2004 Carlo Wood.  All rights reserved.