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 #if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
68 /**
69  * A shorthand way to write is_on(NS_spam).
70  */
71 INLINE bool NotifyCategory::
72 is_spam() const {
73  // Instruct the compiler to optimize for the usual case.
74  return UNLIKELY(is_on(NS_spam));
75 }
76 
77 /**
78  * A shorthand way to write is_on(NS_debug).
79  */
80 INLINE bool NotifyCategory::
81 is_debug() const {
82  // Instruct the compiler to optimize for the usual case.
83  return UNLIKELY(is_on(NS_debug));
84 }
85 #endif
86 
87 /**
88  * A shorthand way to write is_on(NS_info).
89  */
90 INLINE bool NotifyCategory::
91 is_info() const {
92  return is_on(NS_info);
93 }
94 
95 /**
96  * A shorthand way to write is_on(NS_warning).
97  */
98 INLINE bool NotifyCategory::
99 is_warning() const {
100  return is_on(NS_warning);
101 }
102 
103 /**
104  * A shorthand way to write is_on(NS_error).
105  */
106 INLINE bool NotifyCategory::
107 is_error() const {
108  return is_on(NS_error);
109 }
110 
111 /**
112  * A shorthand way to write is_on(NS_fatal).
113  */
114 INLINE bool NotifyCategory::
115 is_fatal() const {
116  return is_on(NS_fatal);
117 }
118 
119 /**
120  * A shorthand way to write out(NS_spam).
121  */
122 INLINE std::ostream &NotifyCategory::
123 spam(bool prefix) const {
124 #if defined(NOTIFY_DEBUG)
125  return out(NS_spam, prefix);
126 #else
127  return Notify::null();
128 #endif
129 }
130 
131 /**
132  * A shorthand way to write out(NS_debug).
133  */
134 INLINE std::ostream &NotifyCategory::
135 debug(bool prefix) const {
136 #if defined(NOTIFY_DEBUG)
137  return out(NS_debug, prefix);
138 #else
139  return Notify::null();
140 #endif
141 }
142 
143 /**
144  * A shorthand way to write out(NS_info).
145  */
146 INLINE std::ostream &NotifyCategory::
147 info(bool prefix) const {
148  return out(NS_info, prefix);
149 }
150 
151 /**
152  * A shorthand way to write out(NS_warning).
153  */
154 INLINE std::ostream &NotifyCategory::
155 warning(bool prefix) const {
156  return out(NS_warning, prefix);
157 }
158 
159 /**
160  * A shorthand way to write out(NS_error).
161  */
162 INLINE std::ostream &NotifyCategory::
163 error(bool prefix) const {
164  return out(NS_error, prefix);
165 }
166 
167 /**
168  * A shorthand way to write out(NS_fatal).
169  */
170 INLINE std::ostream &NotifyCategory::
171 fatal(bool prefix) const {
172  return out(NS_fatal, prefix);
173 }
174 
175 INLINE std::ostream &
176 operator << (std::ostream &out, const NotifyCategory &cat) {
177  return out << cat.get_fullname();
178 }
bool is_error() const
A shorthand way to write is_on(NS_error).
std::ostream & error(bool prefix=true) const
A shorthand way to write out(NS_error).
static std::ostream & out()
A convenient way to get the ostream that should be written to for a Notify- type message.
Definition: notify.cxx:261
std::ostream & spam(bool prefix=true) const
A shorthand way to write out(NS_spam).
A particular category of error messages.
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:270
std::ostream & fatal(bool prefix=true) const
A shorthand way to write out(NS_fatal).
set_severity
Sets the severity level of messages that will be reported from this Category.
bool is_info() const
A shorthand way to write is_on(NS_info).
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).
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 & warning(bool prefix=true) const
A shorthand way to write out(NS_warning).
std::ostream & debug(bool prefix=true) const
A shorthand way to write out(NS_debug).