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

NotifyCategoryProxy< GetCategory > Class Template Reference

A handy wrapper around a NotifyCategory pointer. More...

#include <notifyCategoryProxy.h>

List of all members.

Public Member Functions

NotifyCategoryinit ()
 Initializes the proxy object by calling get_category() on the template class.

NotifyCategoryget_unsafe_ptr ()
 Returns a pointer which is assumed to have been already initialized.

NotifyCategoryget_safe_ptr ()
 Returns a pointer which is *not* assumed to have been already initialized; if necessary, it will be initialized before it returns.

bool is_on (NotifySeverity severity)
bool is_spam ()
bool is_debug ()
bool is_info ()
bool is_warning ()
bool is_error ()
bool is_fatal ()
ostream & out (NotifySeverity severity, bool prefix=true)
ostream & spam (bool prefix=true)
ostream & debug (bool prefix=true)
ostream & info (bool prefix=true)
ostream & warning (bool prefix=true)
ostream & error (bool prefix=true)
ostream & fatal (bool prefix=true)
NotifyCategoryoperator-> ()
 This magic operator function defines the syntax proxy->info(), etc., for all of the methods that are defined for NotifyCategory.

NotifyCategoryoperator * ()
 This operator handles the case of dereferencing the proxy object as if it were a pointer, e.g.

 operator NotifyCategory * ()
 This operator handles the case of passing the proxy object to a function that accepts a NotifyCategory pointer.


Private Attributes

NotifyCategory_ptr


Detailed Description

template<class GetCategory>
class NotifyCategoryProxy< GetCategory >

A handy wrapper around a NotifyCategory pointer.

This wrapper pretends to be a NotifyCategory object itself, except that it is capable of initializing its pointer if it is NULL.

The advantage to this over a normal pointer is that it can be used in functions that run at static init time, without worrying about ordering issues among static init routines. If the pointer hasn't been initialized yet, no sweat; it can initialize itself.

This must be a template class so it can do this magic; it templates on a class with a static method called get_category() that returns a new pointer to the NotifyCategory. This way the compiler can generate correct static-init-independent code to initialize the proxy.

In general, if the proxy object is treated as if it were itself a NotifyCategory object, then it doesn't check whether its category is initialized, and so may not be run at static init time. That is, you may call proxy.info(), but only when you are not running at static init time. This is an optimization so you can avoid this unnecessary check when you know (as in most cases) the code does not run at static init.

On the other hand, if the proxy object is treated as if it were a *pointer* to a NotifyCategory object, then it *does* check whether its category is initialized; you may safely use it in this way at static init time. Thus, you may call proxy->info() safely whenever you like.

Definition at line 103 of file notifyCategoryProxy.h.


Member Function Documentation

template<class GetCategory>
ostream & NotifyCategoryProxy< GetCategory >::debug bool  prefix = true  )  [inline]
 

Definition at line 226 of file notifyCategoryProxy.I.

References NotifyCategory::fatal(), and NotifyCategoryProxy< GetCategory >::get_unsafe_ptr().

template<class GetCategory>
ostream & NotifyCategoryProxy< GetCategory >::error bool  prefix = true  )  [inline]
 

Definition at line 265 of file notifyCategoryProxy.I.

References NotifyCategoryProxy< GetCategory >::get_safe_ptr(), and INLINE.

template<class GetCategory>
ostream & NotifyCategoryProxy< GetCategory >::fatal bool  prefix = true  )  [inline]
 

Definition at line 278 of file notifyCategoryProxy.I.

template<class GetCategory>
NotifyCategory * NotifyCategoryProxy< GetCategory >::get_safe_ptr  )  [inline]
 

Returns a pointer which is *not* assumed to have been already initialized; if necessary, it will be initialized before it returns.

This function may be used in functions that might execute at static init time. All of the category methods that are accessed via the arrow operator, e.g. proxy->info(), use this method.

Definition at line 88 of file notifyCategoryProxy.I.

Referenced by NotifyCategoryProxy< GetCategory >::error(), NotifyCategoryProxy< GetCategory >::info(), and NotifyCategoryProxy< GetCategory >::warning().

template<class GetCategory>
NotifyCategory * NotifyCategoryProxy< GetCategory >::get_unsafe_ptr  )  [inline]
 

Returns a pointer which is assumed to have been already initialized.

This function should only be used in functions that will certainly not execute at static init time. All of the category methods that are accessed via the dot operator, e.g. proxy.info(), use this method.

Definition at line 61 of file notifyCategoryProxy.I.

References NotifyCategoryProxy< GetCategory >::init(), and INLINE.

Referenced by NotifyCategoryProxy< GetCategory >::debug(), NotifyCategoryProxy< GetCategory >::is_debug(), NotifyCategoryProxy< GetCategory >::is_error(), NotifyCategoryProxy< GetCategory >::is_fatal(), NotifyCategoryProxy< GetCategory >::is_info(), NotifyCategoryProxy< GetCategory >::is_on(), NotifyCategoryProxy< GetCategory >::is_spam(), NotifyCategoryProxy< GetCategory >::out(), and NotifyCategoryProxy< GetCategory >::spam().

template<class GetCategory>
ostream & NotifyCategoryProxy< GetCategory >::info bool  prefix = true  )  [inline]
 

Definition at line 239 of file notifyCategoryProxy.I.

References NotifyCategoryProxy< GetCategory >::get_safe_ptr(), and INLINE.

template<class GetCategory>
NotifyCategory * NotifyCategoryProxy< GetCategory >::init  ) 
 

Initializes the proxy object by calling get_category() on the template class.

Definition at line 34 of file notifyCategoryProxy.I.

References NotifyCategoryProxy< GetCategory >::_ptr, INLINE, nassertr, and NULL.

Referenced by NotifyCategoryProxy< GetCategory >::get_unsafe_ptr().

template<class GetCategory>
bool NotifyCategoryProxy< GetCategory >::is_debug  )  [inline]
 

Definition at line 131 of file notifyCategoryProxy.I.

References NotifyCategoryProxy< GetCategory >::get_unsafe_ptr(), INLINE, and NotifyCategory::is_error().

template<class GetCategory>
bool NotifyCategoryProxy< GetCategory >::is_error  )  [inline]
 

Definition at line 174 of file notifyCategoryProxy.I.

References NotifyCategory::debug(), NotifyCategoryProxy< GetCategory >::get_unsafe_ptr(), and INLINE.

template<class GetCategory>
bool NotifyCategoryProxy< GetCategory >::is_fatal  )  [inline]
 

Definition at line 187 of file notifyCategoryProxy.I.

References NotifyCategoryProxy< GetCategory >::get_unsafe_ptr(), NotifyCategory::info(), and INLINE.

template<class GetCategory>
bool NotifyCategoryProxy< GetCategory >::is_info  )  [inline]
 

Definition at line 148 of file notifyCategoryProxy.I.

References NotifyCategoryProxy< GetCategory >::get_unsafe_ptr(), INLINE, and NotifyCategory::is_fatal().

template<class GetCategory>
bool NotifyCategoryProxy< GetCategory >::is_on NotifySeverity  severity  )  [inline]
 

Definition at line 101 of file notifyCategoryProxy.I.

References NotifyCategoryProxy< GetCategory >::get_unsafe_ptr(), and NotifyCategory::is_debug().

template<class GetCategory>
bool NotifyCategoryProxy< GetCategory >::is_spam  )  [inline]
 

Definition at line 114 of file notifyCategoryProxy.I.

References NotifyCategoryProxy< GetCategory >::get_unsafe_ptr(), INLINE, and NotifyCategory::is_info().

template<class GetCategory>
bool NotifyCategoryProxy< GetCategory >::is_warning  )  [inline]
 

Definition at line 161 of file notifyCategoryProxy.I.

template<class GetCategory>
NotifyCategory & NotifyCategoryProxy< GetCategory >::operator *  )  [inline]
 

This operator handles the case of dereferencing the proxy object as if it were a pointer, e.g.

(*proxy).info(). It works the same way as the -> operator, above.

Definition at line 320 of file notifyCategoryProxy.I.

template<class GetCategory>
NotifyCategoryProxy< GetCategory >::operator NotifyCategory *  )  [inline]
 

This operator handles the case of passing the proxy object to a function that accepts a NotifyCategory pointer.

It works the same way as the -> and * operators, above.

Definition at line 340 of file notifyCategoryProxy.I.

template<class GetCategory>
NotifyCategory * NotifyCategoryProxy< GetCategory >::operator->  )  [inline]
 

This magic operator function defines the syntax proxy->info(), etc., for all of the methods that are defined for NotifyCategory.

It's designed to vector through get_safe_ptr(), so this syntax is safe for functions that may execute at static init time.

Definition at line 300 of file notifyCategoryProxy.I.

template<class GetCategory>
ostream & NotifyCategoryProxy< GetCategory >::out NotifySeverity  severity,
bool  prefix = true
[inline]
 

Definition at line 200 of file notifyCategoryProxy.I.

References NotifyCategoryProxy< GetCategory >::get_unsafe_ptr(), INLINE, and NotifyCategory::warning().

template<class GetCategory>
ostream & NotifyCategoryProxy< GetCategory >::spam bool  prefix = true  )  [inline]
 

Definition at line 213 of file notifyCategoryProxy.I.

References NotifyCategory::error(), NotifyCategoryProxy< GetCategory >::get_unsafe_ptr(), and INLINE.

template<class GetCategory>
ostream & NotifyCategoryProxy< GetCategory >::warning bool  prefix = true  )  [inline]
 

Definition at line 252 of file notifyCategoryProxy.I.

References NotifyCategoryProxy< GetCategory >::get_safe_ptr(), and INLINE.


Member Data Documentation

template<class GetCategory>
NotifyCategory* NotifyCategoryProxy< GetCategory >::_ptr [private]
 

Definition at line 149 of file notifyCategoryProxy.h.

Referenced by NotifyCategoryProxy< GetCategory >::init().


The documentation for this class was generated from the following files:
Generated on Thu May 1 22:13:40 2003 for DTool by doxygen1.3