Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
dispatcher.h
Go to the documentation of this file.
1
#pragma once
2
//------------------------------------------------------------------------------
29
#include "
core/ptr.h
"
30
#include "
messaging/port.h
"
31
32
//------------------------------------------------------------------------------
33
namespace
Messaging
34
{
35
class
Dispatcher
:
public
Port
36
{
37
__DeclareClass
(
Dispatcher
);
38
public
:
40
Dispatcher
();
42
virtual
void
HandleMessage
(
const
Ptr<Messaging::Message>
& msg);
44
void
AttachPort
(
const
Ptr<Port>
& port);
46
void
RemovePort
(
const
Ptr<Port>
& port);
48
bool
HasPort
(
const
Ptr<Port>
& port)
const
;
49
50
private
:
51
Util::Array<Ptr<Port>
>
portArray
;
52
Util::Array<Util::Array<Ptr<Port>
> >
idPorts
;
// one entry per message, contains ports which accepts the message
53
Util::Dictionary<const Id*,IndexT>
idPortMap
;
// maps message id's to indices in the msgIdPorts array
54
};
55
56
}
// namespace Message
57
//------------------------------------------------------------------------------
Messaging::Dispatcher::HasPort
bool HasPort(const Ptr< Port > &port) const
return true if a port exists
Definition
dispatcher.cc:98
Messaging::Dispatcher::__DeclareClass
__DeclareClass(Dispatcher)
Messaging::Dispatcher::portArray
Util::Array< Ptr< Port > > portArray
Definition
dispatcher.h:51
Messaging::Dispatcher::AttachPort
void AttachPort(const Ptr< Port > &port)
attach a message port
Definition
dispatcher.cc:30
Messaging::Dispatcher::idPorts
Util::Array< Util::Array< Ptr< Port > > > idPorts
Definition
dispatcher.h:52
Messaging::Dispatcher::HandleMessage
virtual void HandleMessage(const Ptr< Messaging::Message > &msg)
handle a single message (distribute to ports which accept the message)
Definition
dispatcher.cc:110
Messaging::Dispatcher::Dispatcher
Dispatcher()
constructor
Definition
dispatcher.cc:17
Messaging::Dispatcher::idPortMap
Util::Dictionary< const Id *, IndexT > idPortMap
Definition
dispatcher.h:53
Messaging::Dispatcher::RemovePort
void RemovePort(const Ptr< Port > &port)
remove a message port
Definition
dispatcher.cc:64
Messaging::Port
A message port is a receiving point for messages.
Definition
port.h:32
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::Dictionary
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition
dictionary.h:35
Messaging
Definition
asyncport.cc:10
port.h
ptr.h
code
foundation
messaging
dispatcher.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.