Panda3D
|
00001 // Filename: notifyCategory.I 00002 // Created by: drose (29Feb00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: NotifyCategory::get_fullname 00018 // Access: Public 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE string NotifyCategory:: 00022 get_fullname() const { 00023 return _fullname; 00024 } 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Function: NotifyCategory::get_basename 00028 // Access: Public 00029 // Description: 00030 //////////////////////////////////////////////////////////////////// 00031 INLINE string NotifyCategory:: 00032 get_basename() const { 00033 return _basename; 00034 } 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Function: NotifyCategory::get_severity 00038 // Access: Public 00039 // Description: 00040 //////////////////////////////////////////////////////////////////// 00041 NotifySeverity NotifyCategory:: 00042 get_severity() const { 00043 TAU_PROFILE("NotifyCategory NotifyCategory::get_severity() const", " ", TAU_USER); 00044 if (!is_cache_valid(_local_modified)) { 00045 ((NotifyCategory *)this)->update_severity_cache(); 00046 } 00047 return _severity_cache; 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function: NotifyCategory::set_severity 00052 // Access: Public 00053 // Description: Sets the severity level of messages that will be 00054 // reported from this Category. This allows any message 00055 // of this severity level or higher. 00056 //////////////////////////////////////////////////////////////////// 00057 INLINE void NotifyCategory:: 00058 set_severity(NotifySeverity severity) { 00059 #if defined(NOTIFY_DEBUG) 00060 _severity = severity; 00061 #else 00062 // enforce the no-debug, no-spam rule. 00063 _severity = max(severity, NS_info); 00064 #endif 00065 invalidate_cache(); 00066 } 00067 00068 //////////////////////////////////////////////////////////////////// 00069 // Function: NotifyCategory::is_on 00070 // Access: Public 00071 // Description: Returns true if messages of the indicated severity 00072 // level ought to be reported for this Category. 00073 //////////////////////////////////////////////////////////////////// 00074 INLINE bool NotifyCategory:: 00075 is_on(NotifySeverity severity) const { 00076 TAU_PROFILE("bool NotifyCategory::is_on(NotifySeverity) const", " ", TAU_USER); 00077 return (int)severity >= (int)get_severity(); 00078 } 00079 00080 #if defined(NOTIFY_DEBUG) || defined(CPPPARSER) 00081 //////////////////////////////////////////////////////////////////// 00082 // Function: NotifyCategory::is_spam 00083 // Access: Public 00084 // Description: A shorthand way to write is_on(NS_spam). 00085 //////////////////////////////////////////////////////////////////// 00086 INLINE bool NotifyCategory:: 00087 is_spam() const { 00088 return is_on(NS_spam); 00089 } 00090 00091 //////////////////////////////////////////////////////////////////// 00092 // Function: NotifyCategory::is_debug 00093 // Access: Public 00094 // Description: A shorthand way to write is_on(NS_debug). 00095 //////////////////////////////////////////////////////////////////// 00096 INLINE bool NotifyCategory:: 00097 is_debug() const { 00098 return is_on(NS_debug); 00099 } 00100 #else 00101 //////////////////////////////////////////////////////////////////// 00102 // Function: NotifyCategory::is_spam 00103 // Access: Public, Static 00104 // Description: When NOTIFY_DEBUG is not defined, the categories are 00105 // never set to "spam" or "debug" severities, and these 00106 // methods are redefined to be static to make it more 00107 // obvious to the compiler. 00108 //////////////////////////////////////////////////////////////////// 00109 INLINE bool NotifyCategory:: 00110 is_spam() { 00111 return false; 00112 } 00113 00114 //////////////////////////////////////////////////////////////////// 00115 // Function: NotifyCategory::is_debug 00116 // Access: Public 00117 // Description: When NOTIFY_DEBUG is not defined, the categories are 00118 // never set to "spam" or "debug" severities, and these 00119 // methods are redefined to be static to make it more 00120 // obvious to the compiler. 00121 //////////////////////////////////////////////////////////////////// 00122 INLINE bool NotifyCategory:: 00123 is_debug() { 00124 return false; 00125 } 00126 #endif 00127 00128 //////////////////////////////////////////////////////////////////// 00129 // Function: NotifyCategory::is_info 00130 // Access: Public 00131 // Description: A shorthand way to write is_on(NS_info). 00132 //////////////////////////////////////////////////////////////////// 00133 INLINE bool NotifyCategory:: 00134 is_info() const { 00135 return is_on(NS_info); 00136 } 00137 00138 //////////////////////////////////////////////////////////////////// 00139 // Function: NotifyCategory::is_warning 00140 // Access: Public 00141 // Description: A shorthand way to write is_on(NS_warning). 00142 //////////////////////////////////////////////////////////////////// 00143 INLINE bool NotifyCategory:: 00144 is_warning() const { 00145 return is_on(NS_warning); 00146 } 00147 00148 //////////////////////////////////////////////////////////////////// 00149 // Function: NotifyCategory::is_error 00150 // Access: Public 00151 // Description: A shorthand way to write is_on(NS_error). 00152 //////////////////////////////////////////////////////////////////// 00153 INLINE bool NotifyCategory:: 00154 is_error() const { 00155 return is_on(NS_error); 00156 } 00157 00158 //////////////////////////////////////////////////////////////////// 00159 // Function: NotifyCategory::is_fatal 00160 // Access: Public 00161 // Description: A shorthand way to write is_on(NS_fatal). 00162 //////////////////////////////////////////////////////////////////// 00163 INLINE bool NotifyCategory:: 00164 is_fatal() const { 00165 return is_on(NS_fatal); 00166 } 00167 00168 //////////////////////////////////////////////////////////////////// 00169 // Function: NotifyCategory::spam 00170 // Access: Public 00171 // Description: A shorthand way to write out(NS_spam). 00172 //////////////////////////////////////////////////////////////////// 00173 INLINE ostream &NotifyCategory:: 00174 spam(bool prefix) const { 00175 #if defined(NOTIFY_DEBUG) 00176 return out(NS_spam, prefix); 00177 #else 00178 return Notify::null(); 00179 #endif 00180 } 00181 00182 //////////////////////////////////////////////////////////////////// 00183 // Function: NotifyCategory::debug 00184 // Access: Public 00185 // Description: A shorthand way to write out(NS_debug). 00186 //////////////////////////////////////////////////////////////////// 00187 INLINE ostream &NotifyCategory:: 00188 debug(bool prefix) const { 00189 #if defined(NOTIFY_DEBUG) 00190 return out(NS_debug, prefix); 00191 #else 00192 return Notify::null(); 00193 #endif 00194 } 00195 00196 //////////////////////////////////////////////////////////////////// 00197 // Function: NotifyCategory::info 00198 // Access: Public 00199 // Description: A shorthand way to write out(NS_info). 00200 //////////////////////////////////////////////////////////////////// 00201 INLINE ostream &NotifyCategory:: 00202 info(bool prefix) const { 00203 return out(NS_info, prefix); 00204 } 00205 00206 //////////////////////////////////////////////////////////////////// 00207 // Function: NotifyCategory::warning 00208 // Access: Public 00209 // Description: A shorthand way to write out(NS_warning). 00210 //////////////////////////////////////////////////////////////////// 00211 INLINE ostream &NotifyCategory:: 00212 warning(bool prefix) const { 00213 return out(NS_warning, prefix); 00214 } 00215 00216 //////////////////////////////////////////////////////////////////// 00217 // Function: NotifyCategory::error 00218 // Access: Public 00219 // Description: A shorthand way to write out(NS_error). 00220 //////////////////////////////////////////////////////////////////// 00221 INLINE ostream &NotifyCategory:: 00222 error(bool prefix) const { 00223 return out(NS_error, prefix); 00224 } 00225 00226 //////////////////////////////////////////////////////////////////// 00227 // Function: NotifyCategory::fatal 00228 // Access: Public 00229 // Description: A shorthand way to write out(NS_fatal). 00230 //////////////////////////////////////////////////////////////////// 00231 INLINE ostream &NotifyCategory:: 00232 fatal(bool prefix) const { 00233 return out(NS_fatal, prefix); 00234 } 00235 00236 INLINE ostream & 00237 operator << (ostream &out, const NotifyCategory &cat) { 00238 return out << cat.get_fullname(); 00239 }