- Main Page
- Classes
- Files
- Directories
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# grinliz::Publisher< LISTENER_CLASS > Class Template Reference

A Publisher communicates to a Listener by calling its methods. More...

`#include <glpublisher.h>`

List of all members.

## Public Types
typedef std::set< LISTENER_CLASS * >::const_iterator | const_iterator
| Used to iterate through the listeners.
## Public Member Functions
void | AddListener (LISTENER_CLASS *add)
| Add a listener.
void | RemoveListener (LISTENER_CLASS *remove)
| Remove a listener.
const_iterator | begin ()
| An iterator for the publisher to emit messages.
const_iterator | end ()
| An iterator for the publisher to emit messages.

## Detailed Description

### template<class LISTENER_CLASS>
class grinliz::Publisher< LISTENER_CLASS >

A Publisher communicates to a Listener by calling its methods.

If a publisher is deleted, it will clear the pointers to its listener, and if a listener is deleted it will clear the pointes to its publisher. Therefore they can have independent lifespans.

A publisher is aggregated into the class that wants to publish:

    	class Switch
    	{
    		Publisher<SwitchListener> publish;
    	}

## Member Function Documentation

template<class LISTENER_CLASS>

const_iterator grinliz::Publisher< LISTENER_CLASS >::begin | ( |  | ) | `[inline]`

An iterator for the publisher to emit messages.

The code usually looks like:

    		for( Publisher<SwitchListener>::const_iterator it = publish.begin();
    			 it != publish.end();
    			 ++it )
    		{
    			(*it)->Click();
    		}

template<class LISTENER_CLASS>

void grinliz::Publisher< LISTENER_CLASS >::RemoveListener | ( | LISTENER_CLASS * | remove | ) | `[inline]`

Remove a listener.

This is safe to call at any time, even during a callback.

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

- glpublisher.h