Panda3D
notifyCategory.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file notifyCategory.I
10  * @author drose
11  * @date 2000-02-29
12  */
13 
14 /**
15  *
16  */
17 INLINE std::string NotifyCategory::
18 get_fullname() const {
19  return _fullname;
20 }
21 
22 /**
23  *
24  */
25 INLINE std::string NotifyCategory::
26 get_basename() const {
27  return _basename;
28 }
29 
30 /**
31  *
32  */
33 NotifySeverity NotifyCategory::
34 get_severity() const {
35  TAU_PROFILE("NotifyCategory NotifyCategory::get_severity() const", " ", TAU_USER);
36  if (!is_cache_valid(_local_modified)) {
37  ((NotifyCategory *)this)->update_severity_cache();
38  }
39  return _severity_cache;
40 }
41 
42 /**
43  * Sets the severity level of messages that will be reported from this
44  * Category. This allows any message of this severity level or higher.
45  */
46 INLINE void NotifyCategory::
47 set_severity(NotifySeverity severity) {
48 #if defined(NOTIFY_DEBUG)
49  _severity = severity;
50 #else
51  // enforce the no-debug, no-spam rule.
52  _severity = std::max(severity, NS_info);
53 #endif
54  invalidate_cache();
55 }
56 
57 /**
58  * Returns true if messages of the indicated severity level ought to be
59  * reported for this Category.
60  */
61 INLINE bool NotifyCategory::
62 is_on(NotifySeverity severity) const {
63  TAU_PROFILE("bool NotifyCategory::is_on(NotifySeverity) const", " ", TAU_USER);
64  return (int)severity >= (int)get_severity();
65 }
66 
67 /**
68  * A shorthand way to write is_on(NS_spam).
69  */
70 INLINE bool NotifyCategory::
71 is_spam() const {
72 #if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
73  // Instruct the compiler to optimize for the usual case.
74  return UNLIKELY(is_on(NS_spam));
75 #else
76  return false;
77 #endif
78 }
79 
80 /**
81  * A shorthand way to write is_on(NS_debug).
82  */
83 INLINE bool NotifyCategory::
84 is_debug() const {
85 #if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
86  // Instruct the compiler to optimize for the usual case.
87  return UNLIKELY(is_on(NS_debug));
88 #else
89  return false;
90 #endif
91 }
92 
93 /**
94  * A shorthand way to write is_on(NS_info).
95  */
96 INLINE bool NotifyCategory::
97 is_info() const {
98  return is_on(NS_info);
99 }
100 
101 /**
102  * A shorthand way to write is_on(NS_warning).
103  */
104 INLINE bool NotifyCategory::
105 is_warning() const {
106  return is_on(NS_warning);
107 }
108 
109 /**
110  * A shorthand way to write is_on(NS_error).
111  */
112 INLINE bool NotifyCategory::
113 is_error() const {
114  return is_on(NS_error);
115 }
116 
117 /**
118  * A shorthand way to write is_on(NS_fatal).
119  */
120 INLINE bool NotifyCategory::
121 is_fatal() const {
122  return is_on(NS_fatal);
123 }
124 
125 /**
126  * A shorthand way to write out(NS_spam).
127  */
128 INLINE std::ostream &NotifyCategory::
129 spam(bool prefix) const {
130 #if defined(NOTIFY_DEBUG)
131  return out(NS_spam, prefix);
132 #else
133  return Notify::null();
134 #endif
135 }
136 
137 /**
138  * A shorthand way to write out(NS_debug).
139  */
140 INLINE std::ostream &NotifyCategory::
141 debug(bool prefix) const {
142 #if defined(NOTIFY_DEBUG)
143  return out(NS_debug, prefix);
144 #else
145  return Notify::null();
146 #endif
147 }
148 
149 /**
150  * A shorthand way to write out(NS_info).
151  */
152 INLINE std::ostream &NotifyCategory::
153 info(bool prefix) const {
154  return out(NS_info, prefix);
155 }
156 
157 /**
158  * A shorthand way to write out(NS_warning).
159  */
160 INLINE std::ostream &NotifyCategory::
161 warning(bool prefix) const {
162  return out(NS_warning, prefix);
163 }
164 
165 /**
166  * A shorthand way to write out(NS_error).
167  */
168 INLINE std::ostream &NotifyCategory::
169 error(bool prefix) const {
170  return out(NS_error, prefix);
171 }
172 
173 /**
174  * A shorthand way to write out(NS_fatal).
175  */
176 INLINE std::ostream &NotifyCategory::
177 fatal(bool prefix) const {
178  return out(NS_fatal, prefix);
179 }
180 
181 INLINE std::ostream &
182 operator << (std::ostream &out, const NotifyCategory &cat) {
183  return out << cat.get_fullname();
184 }
A particular category of error messages.
set_severity
Sets the severity level of messages that will be reported from this Category.
std::ostream & fatal(bool prefix=true) const
A shorthand way to write out(NS_fatal).
bool is_error() const
A shorthand way to write is_on(NS_error).
bool is_on(NotifySeverity severity) const
Returns true if messages of the indicated severity level ought to be reported for this Category.
bool is_spam() const
A shorthand way to write is_on(NS_spam).
std::ostream & debug(bool prefix=true) const
A shorthand way to write out(NS_debug).
std::ostream & info(bool prefix=true) const
A shorthand way to write out(NS_info).
std::ostream & out(NotifySeverity severity, bool prefix=true) const
Begins a new message to this Category at the indicated severity level.
std::ostream & spam(bool prefix=true) const
A shorthand way to write out(NS_spam).
std::ostream & warning(bool prefix=true) const
A shorthand way to write out(NS_warning).
bool is_debug() const
A shorthand way to write is_on(NS_debug).
bool is_info() const
A shorthand way to write is_on(NS_info).
std::ostream & error(bool prefix=true) const
A shorthand way to write out(NS_error).
bool is_fatal() const
A shorthand way to write is_on(NS_fatal).
bool is_warning() const
A shorthand way to write is_on(NS_warning).
static std::ostream & null()
A convenient way to get an ostream that doesn't do anything.
Definition: notify.cxx:274