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

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.