ManaPlus
Macros
baselistener.hpp File Reference

(986a3bf)

#include "utils/vector.h"

Go to the source code of this file.

Macros

#define defineListener(name)
 
#define defineListenerHeader(name)
 

Macro Definition Documentation

◆ defineListener

#define defineListener (   name)
Value:
STD_VECTOR<name*> name::mListeners; \
\
name::name() \
{ \
addListener(this); \
} \
\
name::~name() \
{ \
removeListener(this); \
} \
\
void name::addListener(name *const listener) \
{ \
if (listener) \
mListeners.push_back(listener); \
} \
\
void name::removeListener(const name *const listener) \
{ \
STD_VECTOR<name*>::iterator it = mListeners.begin(); \
while (it != mListeners.end()) \
{ \
if (*it == listener) \
it = mListeners.erase(it); \
else \
++ it; \
} \
}

Definition at line 27 of file baselistener.hpp.

◆ defineListenerHeader

#define defineListenerHeader (   name)
Value:
public: \
name(); \
\
virtual ~name(); \
\
static void addListener(name *const listener); \
\
static void removeListener(const name *const listener); \
\
private: \
static STD_VECTOR<name*> mListeners;

Definition at line 58 of file baselistener.hpp.