aboutsummaryrefslogtreecommitdiffstats
blob: 848d4af15f5f456b923e380b8a1b6e8f52923e0c (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
 * RTSystemServicesProtocol.h
 *
 *  Created on: 29.08.2012
 *      Author: karlitsc
 */

#ifndef RTSYSTEMSERVICESPROTOCOL_H_
#define RTSYSTEMSERVICESPROTOCOL_H_

#include "common/modelbase/PortBase.h"
#include "common/modelbase/IEventReceiver.h"
#include "common/messaging/Address.h"
#include <vector>
#include <string>

namespace etRuntime {

class RTSystemServicesProtocol {
public:
	class Events {
	public:
		enum eventIDs {
			MSG_MIN = 0,
			OUT_dummy = 1,
			MSG_SEP = 2,
			IN_executeInitialTransition = 2,
			IN_startDebugging = 3,
			IN_stopDebugging = 4,
			MSG_MAX = 5
		};
		static bool isValidEvtID(int evtId) {
			return ((MSG_MIN < evtId) && (evtId < MSG_MAX));
		};
		static bool isValidOutgoingEvtID(int evtId) {
			return ((Events::MSG_MIN < evtId) && (evtId < Events::MSG_SEP));
		};
		static bool isValidIncomingEvtID(int evtId) {
			return ((Events::MSG_SEP <= evtId) && (evtId < Events::MSG_MAX));
		};
		static std::string getMessageString(int msg_id);

	private:
			static std::string s_messageStrings[];
	};

	//---------------------------------------------------
	// interface for port class
	//---------------------------------------------------
	class IRTSystemServicesProtocolPort {
	public:
		virtual void dummy() = 0;
	};

	//---------------------------------------------------
	// interface for conjugated port class
	//---------------------------------------------------
	class IRTSystemServicesProtocolConjPort {
	public:
		virtual void executeInitialTransition() = 0;
		virtual void startDebugging() = 0;
		virtual void stopDebugging() = 0;
	};

public:

	RTSystemServicesProtocol();
	virtual ~RTSystemServicesProtocol();

	//---------------------------------------------------
	// port class
	//---------------------------------------------------
	class RTSystemServicesProtocolPort : public PortBase , public IRTSystemServicesProtocolPort {
	public:
		RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
				int localId, Address addr, Address peerAddress);

		RTSystemServicesProtocolPort(IEventReceiver& actor, IRTObject* parent, std::string name,
				int localId, int idx, Address addr, Address peerAddress);

		virtual void receive(Message* m);
		// sent messages
		void dummy();
	};

	//---------------------------------------------------
	// replicated port class
	//---------------------------------------------------
	class RTSystemServicesProtocolPortRepl: public IRTSystemServicesProtocolPort {
	private:
		int m_replication;
		std::vector<RTSystemServicesProtocolPort> m_ports;

	public:
		//TODO: data type of addr and peerAddress?
		RTSystemServicesProtocolPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId,
										 const std::vector<Address>& addr, const std::vector<Address> peerAddress);

		int getReplication() const { return m_replication; } ;
		RTSystemServicesProtocolPort& get(int i) { return m_ports.at(i); };
		// outgoing messages
		void dummy();
	};


	//---------------------------------------------------
	// conjugated port class
	//---------------------------------------------------
	class RTSystemServicesProtocolConjPort : public PortBase, public IRTSystemServicesProtocolConjPort{
	public:
		RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
				std::string name, int localId, Address addr, Address peerAddress);
		RTSystemServicesProtocolConjPort(IEventReceiver& actor, IRTObject* parent,
				std::string name, int localId, int idx, Address addr,
				Address peerAddress);

		virtual void receive(Message* m);
		void executeInitialTransition();
		void startDebugging();
		void stopDebugging();
	};

	//---------------------------------------------------
	// replicated conjugated port class
	//---------------------------------------------------
	class RTSystemServicesProtocolConjPortRepl : public IRTSystemServicesProtocolConjPort{
	private:
		int m_replication;
		std::vector<RTSystemServicesProtocolConjPort> m_ports;

	public:
		//TODO: data type of addr and peerAddress
		RTSystemServicesProtocolConjPortRepl(IEventReceiver& actor, IRTObject* parent, std::string name, int localId,
											 const std::vector<Address>& addr, const std::vector<Address> peerAddress);

		int getReplication() const { return m_replication; } ;
		RTSystemServicesProtocolConjPort& get(int i) { return m_ports.at(i); };

		void executeInitialTransition();
		void startDebugging();
		void stopDebugging();
	};
};

} /* namespace etRuntime */
#endif /* RTSYSTEMSERVICESPROTOCOL_H_ */