Atlas 0.7.0
Networking protocol for the Worldforge system.
QueuedDecoder.h
1// This file may be redistributed and modified only under the terms of
2// the GNU Lesser General Public License (See COPYING for details).
3// Copyright (C) 2000 Stefanus Du Toit
4
5// $Id$
6
7#ifndef ATLAS_MESSAGE_QUEUEDDECODER_H
8#define ATLAS_MESSAGE_QUEUEDDECODER_H
9
10#include <Atlas/Message/DecoderBase.h>
11#include <Atlas/Message/Element.h>
12
13#include <queue>
14
15namespace Atlas { namespace Message {
16
17class Element;
18
19typedef std::map<std::string, Element> MapType;
20
35{
36public:
37
38 QueuedDecoder() = default;
39
41 size_t queueSize() {
42 return m_objectQueue.size();
43 }
45 MapType popMessage() {
46 MapType r = std::move(m_objectQueue.front());
47 m_objectQueue.pop();
48 return r;
49 }
51 const MapType& frontMessage() {
52 return m_objectQueue.front();
53 }
54
55protected:
56
58 void messageArrived(MapType obj) override;
59
60private:
61
62 std::queue<MapType> m_objectQueue;
63};
64
65} } // namespace Atlas::Message
66
67#endif
MapType popMessage()
Pop an object from the front of the message queue.
Definition: QueuedDecoder.h:45
const MapType & frontMessage()
Peek at the object at the front of the queue.
Definition: QueuedDecoder.h:51
size_t queueSize()
Retrieve the current size of the message queue.
Definition: QueuedDecoder.h:41
void messageArrived(MapType obj) override
This adds a message to the queue.
Definition: Bridge.h:20