blob: 52f6c0b1314108cb1f6ed9b6dd150151e473f8a6 (
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
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
|
/*******************************************************************************
* 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 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* CONTRIBUTORS:
* Peter Karlitschek (initial contribution)
*
*******************************************************************************/
#ifndef MESSAGE_H_
#define MESSAGE_H_
#include "common/messaging/Address.h"
#include "stddef.h"
#include "common/containers/String.h"
namespace etRuntime {
class Message {
public:
Message(const Address& addr, int evtId, void* dataPtr);
Message(const Address& addr, int evtId);
virtual ~Message();
const Address& getAddress() const {
return m_address;
}
int getEvtId() const {
return m_evtId;
}
/** Pointer to data */
void* getData() const {
return m_data;
}
String toString() const;
protected:
friend class MessageSeQueue;
void setNext(Message* msg) {
m_next = msg;
}
Message* getNext() const {
return m_next;
}
private:
Address m_address;
int m_evtId;
Message* m_next;
size_t m_dataSize;
void* m_data;
Message();
Message(Message const&);
Message& operator =(Message const&);
};
template<class T>
class DataMessage : public Message {
public:
DataMessage(const Address& addr, int evtId, const T& dataToCopy) :
Message(addr, evtId, &m_data), m_data(dataToCopy) {}
private:
T m_data;
DataMessage(void);
DataMessage(DataMessage const&);
DataMessage& operator=(DataMessage const&);
};
} /* namespace etRuntime */
#endif /* MESSAGE_H_ */
|