Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/dconfig/notifyCategoryProxy.I

Go to the documentation of this file.
00001 // Filename: notifyCategoryProxy.I
00002 // Created by:  drose (04Mar00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 ////////////////////////////////////////////////////////////////////
00020 //     Function: NotifyCategoryProxy::init()
00021 //       Access: Public
00022 //  Description: Initializes the proxy object by calling
00023 //               get_category() on the template class.
00024 ////////////////////////////////////////////////////////////////////
00025 template<class GetCategory>
00026 NotifyCategory *NotifyCategoryProxy<GetCategory>::
00027 init() {
00028   if (_ptr == (NotifyCategory *)NULL) {
00029     _ptr = GetCategory::get_category();
00030   }
00031   return _ptr;
00032 }
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //     Function: NotifyCategoryProxy::get_unsafe_ptr()
00036 //       Access: Public
00037 //  Description: Returns a pointer which is assumed to have been
00038 //               already initialized.  This function should only be
00039 //               used in functions that will certainly not execute at
00040 //               static init time.  All of the category methods that
00041 //               are accessed via the dot operator, e.g. proxy.info(),
00042 //               use this method.
00043 ////////////////////////////////////////////////////////////////////
00044 template<class GetCategory>
00045 INLINE NotifyCategory *NotifyCategoryProxy<GetCategory>::
00046 get_unsafe_ptr() {
00047   nassertr(_ptr != (NotifyCategory *)NULL, init());
00048   return _ptr;
00049 }
00050 
00051 ////////////////////////////////////////////////////////////////////
00052 //     Function: NotifyCategoryProxy::get_safe_ptr()
00053 //       Access: Public
00054 //  Description: Returns a pointer which is *not* assumed to have been
00055 //               already initialized; if necessary, it will be
00056 //               initialized before it returns.  This function may be
00057 //               used in functions that might execute at static init
00058 //               time.  All of the category methods that are accessed
00059 //               via the arrow operator, e.g. proxy->info(), use this
00060 //               method.
00061 ////////////////////////////////////////////////////////////////////
00062 template<class GetCategory>
00063 INLINE NotifyCategory *NotifyCategoryProxy<GetCategory>::
00064 get_safe_ptr() {
00065   return init();
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: NotifyCategoryProxy::is_on
00070 //       Access: Public
00071 //  Description:
00072 ////////////////////////////////////////////////////////////////////
00073 template<class GetCategory>
00074 INLINE bool NotifyCategoryProxy<GetCategory>::
00075 is_on(NotifySeverity severity) {
00076   return get_unsafe_ptr()->is_on(severity);
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: NotifyCategoryProxy::is_spam
00081 //       Access: Public
00082 //  Description:
00083 ////////////////////////////////////////////////////////////////////
00084 template<class GetCategory>
00085 INLINE bool NotifyCategoryProxy<GetCategory>::
00086 is_spam() {
00087 #ifdef NOTIFY_DEBUG
00088   return get_unsafe_ptr()->is_spam();
00089 #else
00090   return false;
00091 #endif
00092 }
00093 
00094 ////////////////////////////////////////////////////////////////////
00095 //     Function: NotifyCategoryProxy::is_debug
00096 //       Access: Public
00097 //  Description:
00098 ////////////////////////////////////////////////////////////////////
00099 template<class GetCategory>
00100 INLINE bool NotifyCategoryProxy<GetCategory>::
00101 is_debug() {
00102 #ifdef NOTIFY_DEBUG
00103   return get_unsafe_ptr()->is_debug();
00104 #else
00105   return false;
00106 #endif
00107 }
00108 
00109 ////////////////////////////////////////////////////////////////////
00110 //     Function: NotifyCategoryProxy::is_info
00111 //       Access: Public
00112 //  Description:
00113 ////////////////////////////////////////////////////////////////////
00114 template<class GetCategory>
00115 INLINE bool NotifyCategoryProxy<GetCategory>::
00116 is_info() {
00117   return get_unsafe_ptr()->is_info();
00118 }
00119 
00120 ////////////////////////////////////////////////////////////////////
00121 //     Function: NotifyCategoryProxy::is_warning
00122 //       Access: Public
00123 //  Description:
00124 ////////////////////////////////////////////////////////////////////
00125 template<class GetCategory>
00126 INLINE bool NotifyCategoryProxy<GetCategory>::
00127 is_warning() {
00128   return get_unsafe_ptr()->is_warning();
00129 }
00130 
00131 ////////////////////////////////////////////////////////////////////
00132 //     Function: NotifyCategoryProxy::is_error
00133 //       Access: Public
00134 //  Description:
00135 ////////////////////////////////////////////////////////////////////
00136 template<class GetCategory>
00137 INLINE bool NotifyCategoryProxy<GetCategory>::
00138 is_error() {
00139   return get_unsafe_ptr()->is_error();
00140 }
00141 
00142 ////////////////////////////////////////////////////////////////////
00143 //     Function: NotifyCategoryProxy::is_fatal
00144 //       Access: Public
00145 //  Description:
00146 ////////////////////////////////////////////////////////////////////
00147 template<class GetCategory>
00148 INLINE bool NotifyCategoryProxy<GetCategory>::
00149 is_fatal() {
00150   return get_unsafe_ptr()->is_fatal();
00151 }
00152 
00153 ////////////////////////////////////////////////////////////////////
00154 //     Function: NotifyCategoryProxy::out
00155 //       Access: Public
00156 //  Description:
00157 ////////////////////////////////////////////////////////////////////
00158 template<class GetCategory>
00159 INLINE ostream &NotifyCategoryProxy<GetCategory>::
00160 out(NotifySeverity severity, bool prefix) {
00161   return get_unsafe_ptr()->out(severity, prefix);
00162 }
00163 
00164 ////////////////////////////////////////////////////////////////////
00165 //     Function: NotifyCategoryProxy::spam
00166 //       Access: Public
00167 //  Description:
00168 ////////////////////////////////////////////////////////////////////
00169 template<class GetCategory>
00170 INLINE ostream &NotifyCategoryProxy<GetCategory>::
00171 spam(bool prefix) {
00172   return get_unsafe_ptr()->spam(prefix);
00173 }
00174 
00175 ////////////////////////////////////////////////////////////////////
00176 //     Function: NotifyCategoryProxy::debug
00177 //       Access: Public
00178 //  Description:
00179 ////////////////////////////////////////////////////////////////////
00180 template<class GetCategory>
00181 INLINE ostream &NotifyCategoryProxy<GetCategory>::
00182 debug(bool prefix) {
00183   return get_unsafe_ptr()->debug(prefix);
00184 }
00185 
00186 ////////////////////////////////////////////////////////////////////
00187 //     Function: NotifyCategoryProxy::info
00188 //       Access: Public
00189 //  Description:
00190 ////////////////////////////////////////////////////////////////////
00191 template<class GetCategory>
00192 INLINE ostream &NotifyCategoryProxy<GetCategory>::
00193 info(bool prefix) {
00194   return get_unsafe_ptr()->info(prefix);
00195 }
00196 
00197 ////////////////////////////////////////////////////////////////////
00198 //     Function: NotifyCategoryProxy::warning
00199 //       Access: Public
00200 //  Description:
00201 ////////////////////////////////////////////////////////////////////
00202 template<class GetCategory>
00203 INLINE ostream &NotifyCategoryProxy<GetCategory>::
00204 warning(bool prefix) {
00205   return get_unsafe_ptr()->warning(prefix);
00206 }
00207 
00208 ////////////////////////////////////////////////////////////////////
00209 //     Function: NotifyCategoryProxy::error
00210 //       Access: Public
00211 //  Description:
00212 ////////////////////////////////////////////////////////////////////
00213 template<class GetCategory>
00214 INLINE ostream &NotifyCategoryProxy<GetCategory>::
00215 error(bool prefix) {
00216   return get_unsafe_ptr()->error(prefix);
00217 }
00218 
00219 ////////////////////////////////////////////////////////////////////
00220 //     Function: NotifyCategoryProxy::fatal
00221 //       Access: Public
00222 //  Description:
00223 ////////////////////////////////////////////////////////////////////
00224 template<class GetCategory>
00225 INLINE ostream &NotifyCategoryProxy<GetCategory>::
00226 fatal(bool prefix) {
00227   return get_unsafe_ptr()->fatal(prefix);
00228 }
00229 
00230 ////////////////////////////////////////////////////////////////////
00231 //     Function: NotifyCategoryProxy::Member Access Operator
00232 //       Access: Public
00233 //  Description: This magic operator function defines the syntax
00234 //               proxy->info(), etc., for all of the methods that are
00235 //               defined for NotifyCategory.  It's designed to vector
00236 //               through get_safe_ptr(), so this syntax is safe for
00237 //               functions that may execute at static init time.
00238 ////////////////////////////////////////////////////////////////////
00239 template<class GetCategory>
00240 INLINE NotifyCategory *NotifyCategoryProxy<GetCategory>::
00241 operator -> () {
00242   return get_safe_ptr();
00243 }
00244 
00245 ////////////////////////////////////////////////////////////////////
00246 //     Function: NotifyCategoryProxy::Dereference Operator
00247 //       Access: Public
00248 //  Description: This operator handles the case of dereferencing the
00249 //               proxy object as if it were a pointer,
00250 //               e.g. (*proxy).info().  It works the same way as the
00251 //               -> operator, above.
00252 ////////////////////////////////////////////////////////////////////
00253 template<class GetCategory>
00254 INLINE NotifyCategory &NotifyCategoryProxy<GetCategory>::
00255 operator * () {
00256   return *get_safe_ptr();
00257 }
00258 
00259 ////////////////////////////////////////////////////////////////////
00260 //     Function: NotifyCategoryProxy::Typecast Operator
00261 //       Access: Public
00262 //  Description: This operator handles the case of passing the
00263 //               proxy object to a function that accepts a
00264 //               NotifyCategory pointer.  It works the same way as the
00265 //               -> and * operators, above.
00266 ////////////////////////////////////////////////////////////////////
00267 template<class GetCategory>
00268 INLINE NotifyCategoryProxy<GetCategory>::
00269 operator NotifyCategory * () {
00270   return get_safe_ptr();
00271 }

Generated on Thu May 1 22:12:58 2003 for DTool by doxygen1.3