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
Atlas::Message::DecoderBase
Base class for decoders that take Atlas::Message::Object.
Definition: DecoderBase.h:41
Atlas::Message::DecoderBase::mapStringItem
virtual void mapStringItem(const std::string &name, const std::string &)
Adds a string to the currently streamed map.
Atlas::Bridge
Atlas stream bridge.
Definition: Bridge.h:36
Atlas::Message::DecoderBase::streamMessage
virtual void streamMessage()
Start a message in an Atlas stream.
Atlas::Message::DecoderBase::mapFloatItem
virtual void mapFloatItem(const std::string &name, double)
Adds a float to the currently streamed map.
Atlas::Message::DecoderBase::listEnd
virtual void listEnd()
Ends the currently streamed list.
Atlas::Message::DecoderBase::listStringItem
virtual void listStringItem(const std::string &)
Adds a string to the currently streamed list.
Atlas::Message::DecoderBase::m_maps
std::stack< MapType > m_maps
The map stack.
Definition: DecoderBase.h:78
Atlas::Message::DecoderBase::listFloatItem
virtual void listFloatItem(double)
Adds a float to the currently streamed list.
Atlas::Message::DecoderBase::messageArrived
virtual void messageArrived(const MapType &obj)=0
Override this - called when an object was received.
Atlas::Message::DecoderBase::m_state
std::stack< State > m_state
The state stack.
Definition: DecoderBase.h:76
Atlas::Message::DecoderBase::mapMapItem
virtual void mapMapItem(const std::string &name)
Starts a map object to the currently streamed map.
Atlas::Message::DecoderBase::mapEnd
virtual void mapEnd()
Ends the currently streamed map.
Atlas::Message::DecoderBase::m_names
std::stack< std::string > m_names
Names for maps and lists.
Definition: DecoderBase.h:82
Atlas::Message::DecoderBase::m_lists
std::stack< ListType > m_lists
The list stack.
Definition: DecoderBase.h:80
Atlas::Message::DecoderBase::listListItem
virtual void listListItem()
Starts a list object in the currently streamed list.
Atlas::Message::DecoderBase::streamEnd
virtual void streamEnd()
Ends the Atlas stream.
Atlas::Message::DecoderBase::mapListItem
virtual void mapListItem(const std::string &name)
Starts a list object to the currently streamed map.
Atlas
The Atlas namespace.
Definition: Bridge.h:20
Atlas::Message::DecoderBase::mapIntItem
virtual void mapIntItem(const std::string &name, long)
Adds an integer to the currently streames map.
Atlas::Message::DecoderBase::streamBegin
virtual void streamBegin()
Begin an Atlas stream.
Atlas::Message::DecoderBase::listIntItem
virtual void listIntItem(long)
Adds an integer to the currently streames list.
Atlas::Message::DecoderBase::State
State
Our current decoding state.
Definition: DecoderBase.h:69
Atlas::Message::DecoderBase::listMapItem
virtual void listMapItem()
Starts a map object in the currently streamed list.

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.