Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
delegatetable.h
Go to the documentation of this file.
1
#pragma once
2
//------------------------------------------------------------------------------
14
#include "
util/delegate.h
"
15
#include "
messaging/id.h
"
16
#include "messaging/message.h"
17
18
//------------------------------------------------------------------------------
19
namespace
Messaging
20
{
21
class
DelegateTable
22
{
23
public
:
25
template
<
class
CLASS,
void
(CLASS::*METHOD)(const Ptr<Message>&)>
void
Bind
(
const
Id
& msgId, CLASS* obj);
27
bool
Invoke
(
const
Ptr<Message>
& msg);
28
29
private
:
31
void
AddDelegate
(
const
Id
& msgId,
const
Util::Delegate
<
void
(
const
Ptr<Message>
&)>& del);
32
33
Util::Array
<
Util::Array
<
Util::Delegate
<void(
const
Ptr<Message>
&)> > >
delegateArray
;
34
Util::Dictionary<const Id*, IndexT>
idIndexMap
;
35
};
36
37
//------------------------------------------------------------------------------
40
template
<
class
CLASS,
void
(CLASS::*METHOD)(const Ptr<Message>&)>
41
void
42
DelegateTable::Bind
(
const
Id
& msgId, CLASS* obj)
43
{
44
// setup a new delegate
45
Util::Delegate
<void(
const
Ptr<Message>
&)> del =
Util::Delegate
<void(
const
Ptr<Message>
&)>::FromMethod<CLASS,METHOD>(obj);
46
this->
AddDelegate
(msgId, del);
47
}
48
49
}
// namespace Messaging
50
//------------------------------------------------------------------------------
Messaging::DelegateTable
Associates message ids with handler delegates.
Definition
delegatetable.h:22
Messaging::DelegateTable::Invoke
bool Invoke(const Ptr< Message > &msg)
invoke delegates bound to msg, returns false if no delegates bound to msg id
Definition
delegatetable.cc:37
Messaging::DelegateTable::delegateArray
Util::Array< Util::Array< Util::Delegate< void(const Ptr< Message > &)> > > delegateArray
Definition
delegatetable.h:33
Messaging::DelegateTable::Bind
void Bind(const Id &msgId, CLASS *obj)
bind a message id to a method call
Definition
delegatetable.h:42
Messaging::DelegateTable::idIndexMap
Util::Dictionary< const Id *, IndexT > idIndexMap
Definition
delegatetable.h:34
Messaging::DelegateTable::AddDelegate
void AddDelegate(const Id &msgId, const Util::Delegate< void(const Ptr< Message > &)> &del)
add a delegate
Definition
delegatetable.cc:17
Messaging::Id
A message identifier.
Definition
id.h:19
Ptr
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition
ptr.h:38
Util::Array
Nebula's dynamic array class.
Definition
array.h:61
Util::Delegate
Nebula delegate class, allows to store a function, method or lambda call into a C++ object for later ...
Definition
delegate.h:39
Util::Dictionary
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition
dictionary.h:35
delegate.h
id.h
Messaging
Definition
asyncport.cc:10
code
foundation
messaging
delegatetable.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.