13#ifndef ML_EVENT_SOURCE_H
14#define ML_EVENT_SOURCE_H
64 struct ListenerEntry {
65 ListenerEntry() : cb(nullptr), userData(nullptr) {}
66 ListenerEntry(BaseEventCallback* aCB,
void* aUserData) : cb(aCB), userData(aUserData) {}
67 void sendEvent(BaseEvent* event)
const { (*cb)(userData, event); }
68 bool isValid()
const {
return (cb !=
nullptr); }
69 bool operator==(
const ListenerEntry& b)
const {
return cb == b.cb && userData == b.userData; }
76 std::vector<ListenerEntry> _eventListeners;
77 bool _inEventListenerIteration;
78 bool _eventListenersRemovedInIteration;
122template<
typename ToTypePtr>
125 if (from->getTypeId()->isDerivedFrom((
static_cast<ToTypePtr
>(0))->getClassTypeId())) {
126 return static_cast<ToTypePtr
>(from);
136template<
typename ToTypePtr>
139 if (from->getTypeId()->isDerivedFrom((
static_cast<ToTypePtr
>(0))->getClassTypeId())) {
140 return static_cast<ToTypePtr
>(from);
BaseEvent is the base class for all events emitted from EventSourceBase.
EventSource * source() const
get the Base object emitting this event
Class representing general ML objects that support import/export via strings (setPersistentState() an...
EventSourceRemovedEvent is used to indicate when the EventSourceBase object is removed.
EventSourceDeletedEvent()
EventSourceBase class adds event listener handling to Base.
EventSource(const EventSource &evSource)
void addEventListener(BaseEventCallback *cb, void *userData)
add event listener callback to this Base object - the userData will be the first argument when the ca...
void sendEvent(BaseEvent *event, void *skipListener=nullptr)
Macro for the declaration of the runtime type system methods, defined in mlRuntimeSubClass....
bool hasEventListeners() const
check if any event listeners have been added to this Base object; this can be used to skip the sendEv...
void removeEventListener(BaseEventCallback *cb, void *userData)
remove event listener callback from this Base object - arguments must be the same as for the addEvent...
#define ML_ABSTRACT_CLASS_HEADER(className)
Same like ML_ABSTRACT_CLASS_HEADER_EXPORTED with a non existing export symbol.
ToTypePtr mlbaseevent_cast(ml::BaseEvent *from)
cast operation for safely casting BaseEvents to derived types
#define ML_CLASS_HEADER(className)
Same like ML_CLASS_HEADER_EXPORTED with a non existing export symbol.
#define ML_ABSTRACT_ROOT_CLASS_HEADER(className)
#define ML_UTILS_EXPORT
Defines platform dependent DLL export macro for mlUtils.
bool operator==(const Tmat2< DT > &a, const Tmat2< DT > &b)
a == b ? Return true if yes.
void BaseEventCallback(void *, BaseEvent *)