DecoderBase.h

00001 // This file may be redistributed and modified only under the terms of
00002 // the GNU Lesser General Public License (See COPYING for details).
00003 // Copyright (C) 2000 Stefanus Du Toit
00004 
00005 #ifndef ATLAS_MESSAGE_DECODERBASE_H
00006 #define ATLAS_MESSAGE_DECODERBASE_H
00007 
00008 #include <Atlas/Bridge.h>
00009 
00010 #include <map>
00011 #include <string>
00012 #include <vector>
00013 #include <stack>
00014 
00015 namespace Atlas { namespace Message {
00016 
00017 class Element;
00018 
00019 typedef std::map<std::string, Element> MapType;
00020 typedef std::vector<Element> ListType;
00021 
00022 
00038 class DecoderBase : public Bridge
00039 {
00040 public:
00041     DecoderBase();
00042 
00043     virtual ~DecoderBase();
00044 
00045     // Callback functions from Bridge
00046     virtual void streamBegin();
00047     virtual void streamMessage();
00048     virtual void streamEnd();
00049 
00050     virtual void mapMapItem(const std::string& name);
00051     virtual void mapListItem(const std::string& name);
00052     virtual void mapIntItem(const std::string& name, long);
00053     virtual void mapFloatItem(const std::string& name, double);
00054     virtual void mapStringItem(const std::string& name, const std::string&);
00055     virtual void mapEnd();
00056     
00057     virtual void listMapItem();
00058     virtual void listListItem();
00059     virtual void listIntItem(long);
00060     virtual void listFloatItem(double);
00061     virtual void listStringItem(const std::string&);
00062     virtual void listEnd();
00063     
00064 protected:
00065 
00067     enum State {
00068         STATE_STREAM,
00069         STATE_MAP,
00070         STATE_LIST
00071     };
00072 
00074     std::stack<State> m_state;
00076     std::stack<MapType> m_maps;
00078     std::stack<ListType> m_lists;
00080     std::stack<std::string> m_names;
00081 
00083     virtual void messageArrived(const MapType& obj) = 0;
00084 };
00085 
00086 } } // namespace Atlas::Message
00087 
00088 #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.