EntryExit.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef ENTRYEXIT_H
00009 #define ENTRYEXIT_H
00010 
00011 #include "TransportDebug.h"
00012 #include "ace/Log_Msg.h"
00013 #include "ace/OS_NS_string.h"
00014 
00015 #define DBG_ENTRY_CORE(CNAME,MNAME)   \
00016   EntryExit ee_dbg(CNAME,MNAME,this)
00017 
00018 #define DBG_ENTRY0(CNAME,MNAME)
00019 #define DBG_ENTRY1(CNAME,MNAME)
00020 #define DBG_ENTRY2(CNAME,MNAME)
00021 #define DBG_ENTRY3(CNAME,MNAME)
00022 #define DBG_ENTRY4(CNAME,MNAME)
00023 #define DBG_ENTRY5(CNAME,MNAME)
00024 #define DBG_ENTRY6(CNAME,MNAME)
00025 
00026 #if DDS_BLD_DEBUG_LEVEL >=0
00027 #undef DBG_ENTRY0
00028 #define DBG_ENTRY0(CNAME,MNAME)     \
00029   DBG_ENTRY_CORE(CNAME,MNAME)
00030 #endif
00031 
00032 #if DDS_BLD_DEBUG_LEVEL >=1
00033 #undef DBG_ENTRY1
00034 #define DBG_ENTRY1(CNAME,MNAME)     \
00035   DBG_ENTRY_CORE(CNAME,MNAME)
00036 #endif
00037 
00038 #if DDS_BLD_DEBUG_LEVEL >=2
00039 #undef DBG_ENTRY2
00040 #define DBG_ENTRY2(CNAME,MNAME)     \
00041   DBG_ENTRY_CORE(CNAME,MNAME)
00042 #endif
00043 
00044 #if DDS_BLD_DEBUG_LEVEL >=3
00045 #undef DBG_ENTRY3
00046 #define DBG_ENTRY3(CNAME,MNAME)     \
00047   DBG_ENTRY_CORE(CNAME,MNAME)
00048 #endif
00049 
00050 #if DDS_BLD_DEBUG_LEVEL >=4
00051 #undef DBG_ENTRY4
00052 #define DBG_ENTRY4(CNAME,MNAME)     \
00053   DBG_ENTRY_CORE(CNAME,MNAME)
00054 #endif
00055 
00056 #if DDS_BLD_DEBUG_LEVEL >=5
00057 #undef DBG_ENTRY5
00058 #define DBG_ENTRY5(CNAME,MNAME)     \
00059   DBG_ENTRY_CORE(CNAME,MNAME)
00060 #endif
00061 
00062 #if DDS_BLD_DEBUG_LEVEL >=6
00063 #undef DBG_ENTRY6
00064 #define DBG_ENTRY6(CNAME,MNAME)     \
00065   DBG_ENTRY_CORE(CNAME,MNAME)
00066 #endif
00067 
00068 #define DBG_ENTRY_LVL(CNAME,MNAME,DBG_LVL)  \
00069   DBG_ENTRY##DBG_LVL(CNAME,MNAME)
00070 
00071 // deprecated
00072 #define DBG_ENTRY(CNAME,MNAME)      \
00073   DBG_ENTRY_LVL(CNAME,MNAME,6)
00074 
00075 class EntryExit {
00076 public:
00077   EntryExit(const char* className, const char* methodName, const void* addr
00078             , unsigned recurse_level = 0)
00079   : recurse_level_(recurse_level)
00080   , addr_(addr)
00081   , addr_set_(true) {
00082 
00083     ACE_UNUSED_ARG(addr_set_);
00084 
00085     // No processing unless debugging turned on.
00086     if (OpenDDS::DCPS::Transport_debug_level > 0) {
00087       class_[25] = method_[25] = 0;
00088 
00089       ACE_OS::strncpy(this->class_, className, 25);
00090       ACE_OS::strncpy(this->method_, methodName, 25);
00091 
00092       if (this->recurse_level_ == 0) {
00093         ACE_DEBUG((LM_DEBUG, "(%P|%t) DBG: ENTRY: [%s::%s() ::%@]\n"
00094                    , this->class_, this->method_, this->addr_));
00095 
00096       } else {
00097         ACE_DEBUG((LM_DEBUG, "(%P|%t) DBG: ENTRY: [%s::%s() ::%@ :%d]\n"
00098                    , this->class_, this->method_, this->addr_
00099                    , this->recurse_level_));
00100       }
00101     }
00102   };
00103 
00104   ~EntryExit() {
00105     if (OpenDDS::DCPS::Transport_debug_level > 0) {
00106       if (this->recurse_level_ == 0) {
00107         ACE_DEBUG((LM_DEBUG, "(%P|%t) DBG: EXIT : [%s::%s() ::%@]\n"
00108                    , this->class_, this->method_, this->addr_));
00109 
00110       } else {
00111         ACE_DEBUG((LM_DEBUG, "(%P|%t) DBG: EXIT : [%s::%s() ::%@:%d]\n"
00112                    , this->class_, this->method_, this->addr_
00113                    , this->recurse_level_));
00114       }
00115     }
00116   };
00117 
00118 private:
00119 
00120   char class_[26];
00121   char method_[26];
00122   unsigned    recurse_level_;
00123   const void *addr_;
00124   bool addr_set_;
00125 };
00126 
00127 #endif  /* ENTRYEXIT_H */

Generated on Fri Feb 12 20:05:23 2016 for OpenDDS by  doxygen 1.4.7