File: QueuedDecoder.h

package info (click to toggle)
atlas-cpp 0.5.98-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,652 kB
  • ctags: 2,284
  • sloc: sh: 8,305; cpp: 6,372; python: 1,471; makefile: 216
file content (67 lines) | stat: -rw-r--r-- 1,621 bytes parent folder | download | duplicates (3)
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
// This file may be redistributed and modified only under the terms of
// the GNU Lesser General Public License (See COPYING for details).
// Copyright (C) 2000 Stefanus Du Toit

#ifndef ATLAS_MESSAGE_QUEUEDDECODER_H
#define ATLAS_MESSAGE_QUEUEDDECODER_H

#include <Atlas/Message/DecoderBase.h>
#include <Atlas/Message/Element.h>

#include <queue>

namespace Atlas { namespace Message {

class Element;

typedef std::map<std::string, Element> MapType;

/** Decoder that presents a queue of Atlas::Message::Element.
 *
 * This message decoder puts arrived objects into a queue and allows the
 * application to pop them off the front of the queue, peek at the front of 
 * the queue, as well as checking to see how many objects are currently in the
 * queue.
 *
 * @see DecoderBase
 * @see Element
 * @author Stefanus Du Toit <sdt@gmx.net>
 *
 */
    
class QueuedDecoder : public DecoderBase
{
public:

    QueuedDecoder();

    /// Retrieve the current size of the message queue.    
    size_t queueSize() {
	return m_objectQueue.size();
    }
    /// Pop an object from the front of the message queue.
    const MapType popMessage() {
        MapType r = m_objectQueue.front();
        m_objectQueue.pop();
        return r;
    }
    /// Peek at the object at the front of the queue.
    const MapType frontMessage() {
	return m_objectQueue.front();
    }
    /// Clear the message queue.
    void clearQueue();
    
protected:

    /// This adds a message to the queue.
    void messageArrived(const MapType& obj);
    
private:
    
    std::queue<MapType> m_objectQueue;
};

} } // namespace Atlas::Message

#endif