Panda3D

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. More...
NotifyCategory * | get_unsafe_ptr ()
| Returns a pointer which is assumed to have been already initialized. More...
std::ostream & | info (bool prefix=true)
NotifyCategory * | init ()
| Initializes the proxy object by calling get_category() on the template class. More...
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. More...
NotifyCategory & | operator* ()
| This operator handles the case of dereferencing the proxy object as if it were a pointer, e.g. More...
NotifyCategory * | operator-> ()
| This magic operator function defines the syntax proxy->info(), etc., for all of the methods that are defined for NotifyCategory. More...
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

## ◆ 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.

## ◆ 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.

## ◆ 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.

## ◆ 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.

## ◆ 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.

## ◆ 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.

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

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