Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 56b5eabb143d434ba307620d20fc0c6336f9219c (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
/*******************************************************************************
 * Copyright (c) 2016 protos software gmbh (http://www.protos.de).
 * 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:
 * 		Jan Belle (initial contribution)
 *
 *******************************************************************************/

#ifndef SRC_COMMON_MESSAGING_STATICMESSAGEMEMORY_H_
#define SRC_COMMON_MESSAGING_STATICMESSAGEMEMORY_H_

#include "common/messaging/IMessageMemory.h"
#include "common/messaging/RTObject.h"
#include "common/messaging/MessageSeQueue.h"

namespace etRuntime {

class StaticMessageMemory : public IMessageMemory, public RTObject {
public:
	StaticMessageMemory(IRTObject* parent, const std::string& name, size_t size, int number);
	virtual ~StaticMessageMemory();

	// returns a buffer of the specified size in bytes
	Message* getMessageBuffer(size_t size);
	// frees the buffer
	void returnMessageBuffer(const Message* buffer);

	// return the size in bytes of one message buffer
	int getBufferSize(void) { return m_size; }
	// returns the number of free message buffers
	int getMessagePoolSize(void) { return m_msgPool.getSize(); }

private:
	size_t m_size;
	MessageSeQueue m_msgPool;
	uint8_t* m_buffer;
};

} /* namespace etRuntime */

#endif /* SRC_COMMON_MESSAGING_STATICMESSAGEMEMORY_H_ */

Back to the top