log4tango  4.0.3
NDC.hh
Go to the documentation of this file.
00001 //
00002 // NDC.hh
00003 //
00004 // Copyright (C) :  2000 - 2002
00005 //                                      LifeLine Networks BV (www.lifeline.nl). All rights reserved.
00006 //                                      Bastiaan Bakker. All rights reserved.   
00007 //                                      
00008 //                                      2004,2005,2006,2007,2008,2009,2010
00009 //                                      Synchrotron SOLEIL
00010 //                      L'Orme des Merisiers
00011 //                      Saint-Aubin - BP 48 - France
00012 //
00013 // This file is part of log4tango.
00014 //
00015 // Log4ango is free software: you can redistribute it and/or modify
00016 // it under the terms of the GNU Lesser General Public License as published by
00017 // the Free Software Foundation, either version 3 of the License, or
00018 // (at your option) any later version.
00019 // 
00020 // Log4tango is distributed in the hope that it will be useful,
00021 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 // GNU Lesser General Public License for more details.
00024 // 
00025 // You should have received a copy of the GNU Lesser General Public License
00026 // along with Log4Tango.  If not, see <http://www.gnu.org/licenses/>.
00027 
00028 #ifndef _LOG4TANGO_NDC_H
00029 #define _LOG4TANGO_NDC_H
00030 
00031 #ifdef LOG4TANGO_HAS_NDC
00032 
00033 #include <log4tango/Portability.hh>
00034 #include <string>
00035 #include <vector>
00036 
00037 namespace log4tango {
00089 class LOG4TANGO_EXPORT NDC 
00090 {
00091 public:
00092 
00093   struct DiagnosticContext {
00094     DiagnosticContext(const std::string& message);
00095     DiagnosticContext(const std::string& message, 
00096                       const DiagnosticContext& parent);
00097 
00098     std::string message;
00099     std::string full_msg;
00100   };
00101 
00102   typedef std::vector<DiagnosticContext> ContextStack;
00103 
00112   static void clear (void);
00113 
00127   static ContextStack* clone_stack (void);
00128 
00133   static const std::string& get (void);
00134 
00139   static int get_depth (void);
00140 
00141   static void inherit (ContextStack* stack);
00142 
00152   static std::string pop (void);
00153 
00162   static void push (const std::string& message);
00163 
00170   static void set_max_depth (int max_depth);
00171 
00176   static NDC& get_ndc();
00177 
00178   NDC();
00179   virtual ~NDC();
00180 
00181 public:
00182   virtual void _clear (void);
00183   virtual ContextStack* _clone_stack (void);
00184   virtual const std::string& _get (void) const;
00185   virtual int _get_depth (void) const;
00186   virtual void _inherit (ContextStack* stack);
00187   virtual std::string _pop (void);
00188   virtual void _push (const std::string& message);
00189   virtual void _set_max_depth (int max_depth);
00190 
00191   ContextStack _stack;
00192 }; 
00193        
00194 } // namespace log4tango
00195 
00196 #endif // LOG4TANGO_HAS_NDC
00197 
00198 #endif // _LOG4TANGO_NDC_HH