Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0e2d6a9f8bc87a97b1ad4dffdf6963b35fc2bd21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*******************************************************************************
 * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * CONTRIBUTORS:
 * 		Peter Karlitschek (initial contribution)
 *
 *******************************************************************************/

#ifndef MESSAGEDISPATCHER_H_
#define MESSAGEDISPATCHER_H_

#include "common/containers/Vector.h"
#include "common/containers/Set.h"
#include "common/containers/Map.h"
#include "common/messaging/Address.h"
#include "common/messaging/IMessageReceiver.h"
#include "common/messaging/RTObject.h"



namespace etRuntime {

class MessageDispatcher : public RTObject, public virtual IMessageReceiver {
	public:
		MessageDispatcher(IRTObject* parent, const Address& addr, const String& name);
		virtual ~MessageDispatcher() {}

		Address getFreeAddress();
		void freeAddress(const Address& addr);
		void addMessageReceiver(IMessageReceiver& receiver);
		void removeMessageReceiver(IMessageReceiver& receiver);
		void addPollingMessageReceiver(IMessageReceiver& receiver);
		void removePollingMessageReceiver(IMessageReceiver& receiver);
		void receive(const Message* msg);

		const Address& getAddress() const { return m_address; };

	protected:
		String toString() const;

	private:
		Map<int, IMessageReceiver*> m_local_map;
		Vector<Address> m_freeAdresses;
		Set<IMessageReceiver*> m_pollingMessageReceiver;
		Address m_address;
		int m_nextFreeObjId;

		MessageDispatcher();
		MessageDispatcher(MessageDispatcher const&);
		MessageDispatcher& operator=(MessageDispatcher const&);
};

} /* namespace etRuntime */
#endif /* MESSAGEDISPATCHER_H_ */


Back to the top