Panda3D

Loading...
Searching...
No Matches
Public Member Functions | List of all members
NotifyCategoryProxy< GetCategory > Class Template Reference

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

`#include "notifyCategoryProxy.h"`

## Public Member Functions
std::ostream & | debug (bool prefix=true)
std::ostream & | error (bool prefix=true)
std::ostream & | fatal (bool prefix=true)
NotifyCategory * | get_safe_ptr ()
| Returns a pointer which is *not* assumed to have been already initialized; if necessary, it will be initialized before it returns.
NotifyCategory * | get_unsafe_ptr ()
| Returns a pointer which is assumed to have been already initialized.
std::ostream & | info (bool prefix=true)
NotifyCategory * | init ()
| Initializes the proxy object by calling get_category() on the template class.
bool | is_debug ()
bool | is_error ()
bool | is_fatal ()
bool | is_info ()
bool | is_on (NotifySeverity severity)
bool | is_spam ()
bool | is_warning ()
| operator NotifyCategory * ()
| This operator handles the case of passing the proxy object to a function that accepts a NotifyCategory pointer.
NotifyCategory & | operator* ()
| This operator handles the case of dereferencing the proxy object as if it were a pointer, e.g.
NotifyCategory * | operator-> ()
| This magic operator function defines the syntax proxy->info(), etc., for all of the methods that are defined for NotifyCategory.
std::ostream & | out (NotifySeverity severity, bool prefix=true)
std::ostream & | spam (bool prefix=true)
std::ostream & | warning (bool prefix=true)

## 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 51 of file notifyCategoryProxy.h.

## Member Function Documentation

## ◆ debug()

template<class GetCategory>

std::ostream & NotifyCategoryProxy< GetCategory >::debug | ( | bool | prefix = true | ) |
| inline

Definition at line 151 of file notifyCategoryProxy.I.

## ◆ error()

template<class GetCategory>

std::ostream & NotifyCategoryProxy< GetCategory >::error | ( | bool | prefix = true | ) |
| inline

Definition at line 178 of file notifyCategoryProxy.I.

## ◆ fatal()

template<class GetCategory>

std::ostream & NotifyCategoryProxy< GetCategory >::fatal | ( | bool | prefix = true | ) |
| inline

Definition at line 187 of file notifyCategoryProxy.I.

## ◆ get_safe_ptr()

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 51 of file notifyCategoryProxy.I.

References init().

Referenced by operator NotifyCategory *(), operator*(), and operator->().

## ◆ get_unsafe_ptr()

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 34 of file notifyCategoryProxy.I.

References init().

## ◆ info()

template<class GetCategory>

std::ostream & NotifyCategoryProxy< GetCategory >::info | ( | bool | prefix = true | ) |
| inline

Definition at line 160 of file notifyCategoryProxy.I.

## ◆ init()

template<class GetCategory>

NotifyCategory * NotifyCategoryProxy< GetCategory >::init | ( |  | ) |

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

Definition at line 19 of file notifyCategoryProxy.I.

Referenced by get_safe_ptr(), and get_unsafe_ptr().

## ◆ is_debug()

template<class GetCategory>

bool NotifyCategoryProxy< GetCategory >::is_debug | ( |  | ) |
| inline

Definition at line 83 of file notifyCategoryProxy.I.

## ◆ is_error()

template<class GetCategory>

bool NotifyCategoryProxy< GetCategory >::is_error | ( |  | ) |
| inline

Definition at line 115 of file notifyCategoryProxy.I.

## ◆ is_fatal()

template<class GetCategory>

bool NotifyCategoryProxy< GetCategory >::is_fatal | ( |  | ) |
| inline

Definition at line 124 of file notifyCategoryProxy.I.

## ◆ is_info()

template<class GetCategory>

bool NotifyCategoryProxy< GetCategory >::is_info | ( |  | ) |
| inline

Definition at line 97 of file notifyCategoryProxy.I.

## ◆ is_on()

template<class GetCategory>

bool NotifyCategoryProxy< GetCategory >::is_on | ( | NotifySeverity | severity | ) |
| inline

Definition at line 60 of file notifyCategoryProxy.I.

## ◆ is_spam()

template<class GetCategory>

bool NotifyCategoryProxy< GetCategory >::is_spam | ( |  | ) |
| inline

Definition at line 69 of file notifyCategoryProxy.I.

## ◆ is_warning()

template<class GetCategory>

bool NotifyCategoryProxy< GetCategory >::is_warning | ( |  | ) |
| inline

Definition at line 106 of file notifyCategoryProxy.I.

## ◆ operator NotifyCategory *()

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 221 of file notifyCategoryProxy.I.

References get_safe_ptr().

## ◆ operator*()

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 210 of file notifyCategoryProxy.I.

References get_safe_ptr().

## ◆ operator->()

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 199 of file notifyCategoryProxy.I.

References get_safe_ptr().

## ◆ out()

template<class GetCategory>

std::ostream & NotifyCategoryProxy< GetCategory >::out | ( | NotifySeverity | severity,
|  | bool | prefix = true )
| inline

Definition at line 133 of file notifyCategoryProxy.I.

## ◆ spam()

template<class GetCategory>

std::ostream & NotifyCategoryProxy< GetCategory >::spam | ( | bool | prefix = true | ) |
| inline

Definition at line 142 of file notifyCategoryProxy.I.

## ◆ warning()

template<class GetCategory>

std::ostream & NotifyCategoryProxy< GetCategory >::warning | ( | bool | prefix = true | ) |
| inline

Definition at line 169 of file notifyCategoryProxy.I.

The documentation for this class was generated from the following files:

- dtool/src/prc/notifyCategoryProxy.h
- dtool/src/prc/notifyCategoryProxy.I