Panda3D
notifyCategory.I
1 // Filename: notifyCategory.I
2 // Created by: drose (29Feb00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: NotifyCategory::get_fullname
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE string NotifyCategory::
22 get_fullname() const {
23  return _fullname;
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: NotifyCategory::get_basename
28 // Access: Public
29 // Description:
30 ////////////////////////////////////////////////////////////////////
31 INLINE string NotifyCategory::
32 get_basename() const {
33  return _basename;
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: NotifyCategory::get_severity
38 // Access: Public
39 // Description:
40 ////////////////////////////////////////////////////////////////////
41 NotifySeverity NotifyCategory::
42 get_severity() const {
43  TAU_PROFILE("NotifyCategory NotifyCategory::get_severity() const", " ", TAU_USER);
44  if (!is_cache_valid(_local_modified)) {
45  ((NotifyCategory *)this)->update_severity_cache();
46  }
47  return _severity_cache;
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: NotifyCategory::set_severity
52 // Access: Public
53 // Description: Sets the severity level of messages that will be
54 // reported from this Category. This allows any message
55 // of this severity level or higher.
56 ////////////////////////////////////////////////////////////////////
57 INLINE void NotifyCategory::
58 set_severity(NotifySeverity severity) {
59 #if defined(NOTIFY_DEBUG)
60  _severity = severity;
61 #else
62  // enforce the no-debug, no-spam rule.
63  _severity = max(severity, NS_info);
64 #endif
65  invalidate_cache();
66 }
67 
68 ////////////////////////////////////////////////////////////////////
69 // Function: NotifyCategory::is_on
70 // Access: Public
71 // Description: Returns true if messages of the indicated severity
72 // level ought to be reported for this Category.
73 ////////////////////////////////////////////////////////////////////
74 INLINE bool NotifyCategory::
75 is_on(NotifySeverity severity) const {
76  TAU_PROFILE("bool NotifyCategory::is_on(NotifySeverity) const", " ", TAU_USER);
77  return (int)severity >= (int)get_severity();
78 }
79 
80 #if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
81 ////////////////////////////////////////////////////////////////////
82 // Function: NotifyCategory::is_spam
83 // Access: Public
84 // Description: A shorthand way to write is_on(NS_spam).
85 ////////////////////////////////////////////////////////////////////
86 INLINE bool NotifyCategory::
87 is_spam() const {
88  return is_on(NS_spam);
89 }
90 
91 ////////////////////////////////////////////////////////////////////
92 // Function: NotifyCategory::is_debug
93 // Access: Public
94 // Description: A shorthand way to write is_on(NS_debug).
95 ////////////////////////////////////////////////////////////////////
96 INLINE bool NotifyCategory::
97 is_debug() const {
98  return is_on(NS_debug);
99 }
100 #else
101 ////////////////////////////////////////////////////////////////////
102 // Function: NotifyCategory::is_spam
103 // Access: Public, Static
104 // Description: When NOTIFY_DEBUG is not defined, the categories are
105 // never set to "spam" or "debug" severities, and these
106 // methods are redefined to be static to make it more
107 // obvious to the compiler.
108 ////////////////////////////////////////////////////////////////////
109 CONSTEXPR bool NotifyCategory::
111  return false;
112 }
113 
114 ////////////////////////////////////////////////////////////////////
115 // Function: NotifyCategory::is_debug
116 // Access: Public
117 // Description: When NOTIFY_DEBUG is not defined, the categories are
118 // never set to "spam" or "debug" severities, and these
119 // methods are redefined to be static to make it more
120 // obvious to the compiler.
121 ////////////////////////////////////////////////////////////////////
122 CONSTEXPR bool NotifyCategory::
124  return false;
125 }
126 #endif
127 
128 ////////////////////////////////////////////////////////////////////
129 // Function: NotifyCategory::is_info
130 // Access: Public
131 // Description: A shorthand way to write is_on(NS_info).
132 ////////////////////////////////////////////////////////////////////
133 INLINE bool NotifyCategory::
134 is_info() const {
135  return is_on(NS_info);
136 }
137 
138 ////////////////////////////////////////////////////////////////////
139 // Function: NotifyCategory::is_warning
140 // Access: Public
141 // Description: A shorthand way to write is_on(NS_warning).
142 ////////////////////////////////////////////////////////////////////
143 INLINE bool NotifyCategory::
144 is_warning() const {
145  return is_on(NS_warning);
146 }
147 
148 ////////////////////////////////////////////////////////////////////
149 // Function: NotifyCategory::is_error
150 // Access: Public
151 // Description: A shorthand way to write is_on(NS_error).
152 ////////////////////////////////////////////////////////////////////
153 INLINE bool NotifyCategory::
154 is_error() const {
155  return is_on(NS_error);
156 }
157 
158 ////////////////////////////////////////////////////////////////////
159 // Function: NotifyCategory::is_fatal
160 // Access: Public
161 // Description: A shorthand way to write is_on(NS_fatal).
162 ////////////////////////////////////////////////////////////////////
163 INLINE bool NotifyCategory::
164 is_fatal() const {
165  return is_on(NS_fatal);
166 }
167 
168 ////////////////////////////////////////////////////////////////////
169 // Function: NotifyCategory::spam
170 // Access: Public
171 // Description: A shorthand way to write out(NS_spam).
172 ////////////////////////////////////////////////////////////////////
173 INLINE ostream &NotifyCategory::
174 spam(bool prefix) const {
175 #if defined(NOTIFY_DEBUG)
176  return out(NS_spam, prefix);
177 #else
178  return Notify::null();
179 #endif
180 }
181 
182 ////////////////////////////////////////////////////////////////////
183 // Function: NotifyCategory::debug
184 // Access: Public
185 // Description: A shorthand way to write out(NS_debug).
186 ////////////////////////////////////////////////////////////////////
187 INLINE ostream &NotifyCategory::
188 debug(bool prefix) const {
189 #if defined(NOTIFY_DEBUG)
190  return out(NS_debug, prefix);
191 #else
192  return Notify::null();
193 #endif
194 }
195 
196 ////////////////////////////////////////////////////////////////////
197 // Function: NotifyCategory::info
198 // Access: Public
199 // Description: A shorthand way to write out(NS_info).
200 ////////////////////////////////////////////////////////////////////
201 INLINE ostream &NotifyCategory::
202 info(bool prefix) const {
203  return out(NS_info, prefix);
204 }
205 
206 ////////////////////////////////////////////////////////////////////
207 // Function: NotifyCategory::warning
208 // Access: Public
209 // Description: A shorthand way to write out(NS_warning).
210 ////////////////////////////////////////////////////////////////////
211 INLINE ostream &NotifyCategory::
212 warning(bool prefix) const {
213  return out(NS_warning, prefix);
214 }
215 
216 ////////////////////////////////////////////////////////////////////
217 // Function: NotifyCategory::error
218 // Access: Public
219 // Description: A shorthand way to write out(NS_error).
220 ////////////////////////////////////////////////////////////////////
221 INLINE ostream &NotifyCategory::
222 error(bool prefix) const {
223  return out(NS_error, prefix);
224 }
225 
226 ////////////////////////////////////////////////////////////////////
227 // Function: NotifyCategory::fatal
228 // Access: Public
229 // Description: A shorthand way to write out(NS_fatal).
230 ////////////////////////////////////////////////////////////////////
231 INLINE ostream &NotifyCategory::
232 fatal(bool prefix) const {
233  return out(NS_fatal, prefix);
234 }
235 
236 INLINE ostream &
237 operator << (ostream &out, const NotifyCategory &cat) {
238  return out << cat.get_fullname();
239 }
bool is_error() const
A shorthand way to write is_on(NS_error).
ostream & warning(bool prefix=true) const
A shorthand way to write out(NS_warning).
static CONSTEXPR bool is_debug()
When NOTIFY_DEBUG is not defined, the categories are never set to "spam" or "debug" severities...
void set_severity(NotifySeverity severity)
Sets the severity level of messages that will be reported from this Category.
ostream & debug(bool prefix=true) const
A shorthand way to write out(NS_debug).
A particular category of error messages.
bool is_warning() const
A shorthand way to write is_on(NS_warning).
ostream & info(bool prefix=true) const
A shorthand way to write out(NS_info).
static ostream & null()
A convenient way to get an ostream that doesn&#39;t do anything.
Definition: notify.cxx:313
ostream & error(bool prefix=true) const
A shorthand way to write out(NS_error).
ostream & spam(bool prefix=true) const
A shorthand way to write out(NS_spam).
bool is_info() const
A shorthand way to write is_on(NS_info).
ostream & fatal(bool prefix=true) const
A shorthand way to write out(NS_fatal).
bool is_on(NotifySeverity severity) const
Returns true if messages of the indicated severity level ought to be reported for this Category...
bool is_fatal() const
A shorthand way to write is_on(NS_fatal).
ostream & out(NotifySeverity severity, bool prefix=true) const
Begins a new message to this Category at the indicated severity level.
static CONSTEXPR bool is_spam()
When NOTIFY_DEBUG is not defined, the categories are never set to "spam" or "debug" severities...