Atlas-C++
DecoderBase.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_DECODERBASE_H
8 #define ATLAS_MESSAGE_DECODERBASE_H
9 
10 #include <Atlas/Bridge.h>
11 
12 #include <map>
13 #include <string>
14 #include <vector>
15 #include <stack>
16 
17 namespace Atlas { namespace Message {
18 
19 class Element;
20 
21 typedef std::map<std::string, Element> MapType;
22 typedef std::vector<Element> ListType;
23 
24 
40 class DecoderBase : public Bridge
41 {
42 public:
43  DecoderBase();
44 
45  ~DecoderBase() override = default;
46 
47  // Callback functions from Bridge
48  void streamBegin() override;
49  void streamMessage() override;
50  void streamEnd() override;
51 
52  void mapMapItem(std::string name) override;
53  void mapListItem(std::string name) override;
54  void mapIntItem(std::string name, long) override;
55  void mapFloatItem(std::string name, double) override;
56  void mapStringItem(std::string name, std::string) override;
57  void mapEnd() override;
58 
59  void listMapItem() override;
60  void listListItem() override;
61  void listIntItem(long) override;
62  void listFloatItem(double) override;
63  void listStringItem(std::string) override;
64  void listEnd() override;
65 
66 protected:
67 
69  enum State {
70  STATE_STREAM,
71  STATE_MAP,
72  STATE_LIST
73  };
74 
76  std::stack<State> m_state;
78  std::stack<MapType> m_maps;
80  std::stack<ListType> m_lists;
82  std::stack<std::string> m_names;
83 
85  virtual void messageArrived(MapType obj) = 0;
86 };
87 
88 } } // namespace Atlas::Message
89 
90 #endif
std::stack< std::string > m_names
Names for maps and lists.
Definition: DecoderBase.h:82
std::stack< ListType > m_lists
The list stack.
Definition: DecoderBase.h:80
void listListItem() override
Starts a list object in the currently streamed list.
Atlas stream bridge.
Definition: Bridge.h:35
void streamEnd() override
Ends the Atlas stream.
State
Our current decoding state.
Definition: DecoderBase.h:69
void listFloatItem(double) override
Adds a float to the currently streamed list.
void mapIntItem(std::string name, long) override
Adds an integer to the currently streames map.
void listMapItem() override
Starts a map object in the currently streamed list.
The Atlas namespace.
Definition: Bridge.h:20
void mapStringItem(std::string name, std::string) override
Adds a string to the currently streamed map.
void streamBegin() override
Begin an Atlas stream.
std::stack< MapType > m_maps
The map stack.
Definition: DecoderBase.h:78
void mapMapItem(std::string name) override
Starts a map object to the currently streamed map.
void mapEnd() override
Ends the currently streamed map.
void listIntItem(long) override
Adds an integer to the currently streames list.
virtual void messageArrived(MapType obj)=0
Override this - called when an object was received.
std::stack< State > m_state
The state stack.
Definition: DecoderBase.h:76
void streamMessage() override
Start a message in an Atlas stream.
void listStringItem(std::string) override
Adds a string to the currently streamed list.
void mapFloatItem(std::string name, double) override
Adds a float to the currently streamed map.
void listEnd() override
Ends the currently streamed list.
Base class for decoders that take Atlas::Message::Object.
Definition: DecoderBase.h:40
void mapListItem(std::string name) override
Starts a list object to the currently streamed map.

Copyright 2000-2004 the respective authors.

This document can be licensed under the terms of the GNU Free Documentation License or the GNU General Public License and may be freely distributed under the terms given by one of these licenses.