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  virtual ~DecoderBase();
46 
47  // Callback functions from Bridge
48  virtual void streamBegin();
49  virtual void streamMessage();
50  virtual void streamEnd();
51 
52  virtual void mapMapItem(const std::string& name);
53  virtual void mapListItem(const std::string& name);
54  virtual void mapIntItem(const std::string& name, long);
55  virtual void mapFloatItem(const std::string& name, double);
56  virtual void mapStringItem(const std::string& name, const std::string&);
57  virtual void mapEnd();
58 
59  virtual void listMapItem();
60  virtual void listListItem();
61  virtual void listIntItem(long);
62  virtual void listFloatItem(double);
63  virtual void listStringItem(const std::string&);
64  virtual void listEnd();
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(const 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
Atlas stream bridge.
Definition: Bridge.h:35
virtual void messageArrived(const MapType &obj)=0
Override this - called when an object was received.
State
Our current decoding state.
Definition: DecoderBase.h:69
virtual void streamMessage()
Start a message in an Atlas stream.
virtual void mapListItem(const std::string &name)
Starts a list object to the currently streamed map.
The Atlas namespace.
Definition: Bridge.h:20
virtual void listStringItem(const std::string &)
Adds a string to the currently streamed list.
std::stack< MapType > m_maps
The map stack.
Definition: DecoderBase.h:78
virtual void listMapItem()
Starts a map object in the currently streamed list.
virtual void mapEnd()
Ends the currently streamed map.
virtual void listFloatItem(double)
Adds a float to the currently streamed list.
virtual void mapIntItem(const std::string &name, long)
Adds an integer to the currently streames map.
std::stack< State > m_state
The state stack.
Definition: DecoderBase.h:76
virtual void listListItem()
Starts a list object in the currently streamed list.
virtual void mapFloatItem(const std::string &name, double)
Adds a float to the currently streamed map.
virtual void listEnd()
Ends the currently streamed list.
virtual void streamBegin()
Begin an Atlas stream.
virtual void mapMapItem(const std::string &name)
Starts a map object to the currently streamed map.
virtual void listIntItem(long)
Adds an integer to the currently streames list.
Base class for decoders that take Atlas::Message::Object.
Definition: DecoderBase.h:40
virtual void mapStringItem(const std::string &name, const std::string &)
Adds a string to the currently streamed map.
virtual void streamEnd()
Ends the Atlas stream.

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.