OpenDDS  Snapshot(2023/04/28-20:55)
EntryExit.h
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #ifndef OPENDDS_DCPS_TRANSPORT_FRAMEWORK_ENTRYEXIT_H
9 #define OPENDDS_DCPS_TRANSPORT_FRAMEWORK_ENTRYEXIT_H
10 
11 #include "TransportDebug.h"
12 #include "ace/Log_Msg.h"
13 #include "ace/OS_NS_string.h"
14 
15 #define DBG_ENTRY_CORE(CNAME,MNAME) \
16  EntryExit ee_dbg(CNAME,MNAME,this)
17 
18 #define DBG_ENTRY0(CNAME,MNAME)
19 #define DBG_ENTRY1(CNAME,MNAME)
20 #define DBG_ENTRY2(CNAME,MNAME)
21 #define DBG_ENTRY3(CNAME,MNAME)
22 #define DBG_ENTRY4(CNAME,MNAME)
23 #define DBG_ENTRY5(CNAME,MNAME)
24 #define DBG_ENTRY6(CNAME,MNAME)
25 
26 #if DDS_BLD_DEBUG_LEVEL >=0
27 #undef DBG_ENTRY0
28 #define DBG_ENTRY0(CNAME,MNAME) \
29  DBG_ENTRY_CORE(CNAME,MNAME)
30 #endif
31 
32 #if DDS_BLD_DEBUG_LEVEL >=1
33 #undef DBG_ENTRY1
34 #define DBG_ENTRY1(CNAME,MNAME) \
35  DBG_ENTRY_CORE(CNAME,MNAME)
36 #endif
37 
38 #if DDS_BLD_DEBUG_LEVEL >=2
39 #undef DBG_ENTRY2
40 #define DBG_ENTRY2(CNAME,MNAME) \
41  DBG_ENTRY_CORE(CNAME,MNAME)
42 #endif
43 
44 #if DDS_BLD_DEBUG_LEVEL >=3
45 #undef DBG_ENTRY3
46 #define DBG_ENTRY3(CNAME,MNAME) \
47  DBG_ENTRY_CORE(CNAME,MNAME)
48 #endif
49 
50 #if DDS_BLD_DEBUG_LEVEL >=4
51 #undef DBG_ENTRY4
52 #define DBG_ENTRY4(CNAME,MNAME) \
53  DBG_ENTRY_CORE(CNAME,MNAME)
54 #endif
55 
56 #if DDS_BLD_DEBUG_LEVEL >=5
57 #undef DBG_ENTRY5
58 #define DBG_ENTRY5(CNAME,MNAME) \
59  DBG_ENTRY_CORE(CNAME,MNAME)
60 #endif
61 
62 #if DDS_BLD_DEBUG_LEVEL >=6
63 #undef DBG_ENTRY6
64 #define DBG_ENTRY6(CNAME,MNAME) \
65  DBG_ENTRY_CORE(CNAME,MNAME)
66 #endif
67 
68 #define DBG_ENTRY_LVL(CNAME,MNAME,DBG_LVL) \
69  DBG_ENTRY##DBG_LVL(CNAME,MNAME)
70 
71 // deprecated
72 #define DBG_ENTRY(CNAME,MNAME) \
73  DBG_ENTRY_LVL(CNAME,MNAME,6)
74 
75 class EntryExit {
76 public:
77  EntryExit(const char* className, const char* methodName, const void* addr
78  , unsigned recurse_level = 0)
79  : recurse_level_(recurse_level)
80  , addr_(addr)
81  , addr_set_(true) {
82 
83  ACE_UNUSED_ARG(addr_set_);
84 
85  // No processing unless debugging turned on.
87  class_[25] = method_[25] = 0;
88 
89  ACE_OS::strncpy(this->class_, className, 25);
90  ACE_OS::strncpy(this->method_, methodName, 25);
91 
92  if (this->recurse_level_ == 0) {
93  ACE_DEBUG((LM_DEBUG, "(%P|%t) DBG: ENTRY: [%s::%s() ::%@]\n"
94  , this->class_, this->method_, this->addr_));
95 
96  } else {
97  ACE_DEBUG((LM_DEBUG, "(%P|%t) DBG: ENTRY: [%s::%s() ::%@ :%d]\n"
98  , this->class_, this->method_, this->addr_
99  , this->recurse_level_));
100  }
101  }
102  };
103 
106  if (this->recurse_level_ == 0) {
107  ACE_DEBUG((LM_DEBUG, "(%P|%t) DBG: EXIT : [%s::%s() ::%@]\n"
108  , this->class_, this->method_, this->addr_));
109 
110  } else {
111  ACE_DEBUG((LM_DEBUG, "(%P|%t) DBG: EXIT : [%s::%s() ::%@:%d]\n"
112  , this->class_, this->method_, this->addr_
113  , this->recurse_level_));
114  }
115  }
116  };
117 
118 private:
119 
120  char class_[26];
121  char method_[26];
122  unsigned recurse_level_;
123  const void *addr_;
124  bool addr_set_;
125 };
126 
127 #endif /* ENTRYEXIT_H */
#define ACE_DEBUG(X)
char method_[26]
Definition: EntryExit.h:121
OpenDDS_Dcps_Export unsigned int Transport_debug_level
Transport Logging verbosity level.
Definition: debug.cpp:25
LM_DEBUG
unsigned recurse_level_
Definition: EntryExit.h:122
EntryExit(const char *className, const char *methodName, const void *addr, unsigned recurse_level=0)
Definition: EntryExit.h:77
char class_[26]
Definition: EntryExit.h:116
bool addr_set_
Definition: EntryExit.h:124
const void * addr_
Definition: EntryExit.h:123
~EntryExit()
Definition: EntryExit.h:104
char * strncpy(char *s, const char *t, size_t len)