TOBI Interface A  0.1
/home/breidi/Dropbox/libtia/include/tia-private/config/control_message_decoder.h
Go to the documentation of this file.
00001 /*
00002     This file is part of the TOBI Interface A (TiA) library.
00003 
00004     Commercial Usage
00005     Licensees holding valid Graz University of Technology Commercial
00006     licenses may use this file in accordance with the Graz University
00007     of Technology Commercial License Agreement provided with the
00008     Software or, alternatively, in accordance with the terms contained in
00009     a written agreement between you and Graz University of Technology.
00010 
00011     --------------------------------------------------
00012 
00013     GNU Lesser General Public License Usage
00014     Alternatively, this file may be used under the terms of the GNU Lesser
00015     General Public License version 3.0 as published by the Free Software
00016     Foundation and appearing in the file lgpl.txt included in the
00017     packaging of this file.  Please review the following information to
00018     ensure the GNU General Public License version 3.0 requirements will be
00019     met: http://www.gnu.org/copyleft/lgpl.html.
00020 
00021     In case of GNU Lesser General Public License Usage ,the TiA library
00022     is distributed in the hope that it will be useful,
00023     but WITHOUT ANY WARRANTY; without even the implied warranty of
00024     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025     GNU General Public License for more details.
00026 
00027     You should have received a copy of the GNU Lesser General Public License
00028     along with the TiA library. If not, see <http://www.gnu.org/licenses/>.
00029 
00030     Copyright 2010 Graz University of Technology
00031     Contact: TiA@tobi-project.org
00032 */
00033 
00039 #ifndef CONTROLMESSAGEDECODER_H
00040 #define CONTROLMESSAGEDECODER_H
00041 
00042 // Standard
00043 #include <assert.h>
00044 #include <iostream>
00045 
00046 // boost
00047 #include <boost/thread/condition.hpp>
00048 
00049 // TICPP
00050 #include "ticpp/ticpp.h"
00051 
00052 // local
00053 #include "control_messages.h"
00054 
00055 namespace tia
00056 {
00057 //-----------------------------------------------------------------------------
00065 class ControlMsgDecoder
00066 {
00067 public:
00068   virtual ~ControlMsgDecoder() {  };
00069 
00071   void setInputStream(std::istream* stream) { istream_ = stream; }
00072 
00074   virtual ControlMsg* decodeMsg() = 0;
00075 
00077   virtual void decodeMsg(KeepAliveMsg& msg) = 0;
00078 
00080   virtual void decodeMsg(GetConfigMsg& msg) = 0;
00081 
00083   virtual void decodeMsg(GetDataConnectionMsg& msg) = 0;
00084 
00086   virtual void decodeMsg(DataConnectionMsg& msg) = 0;
00087 
00089   virtual void decodeMsg(StartTransmissionMsg& msg) = 0;
00090 
00092   virtual void decodeMsg(StopTransmissionMsg& msg) = 0;
00093 
00095   virtual void decodeMsg(ConfigMsg& msg) = 0;
00096 
00098   virtual void decodeMsg(ReplyMsg& msg) = 0;
00099 
00100 protected:
00101   std::istream* istream_;    
00102 };
00103 
00104 //-----------------------------------------------------------------------------
00105 
00111 class ControlMsgDecoderXML : public ControlMsgDecoder
00112 {
00113 public:
00115   ControlMsgDecoderXML();
00117   virtual ~ControlMsgDecoderXML();
00119   virtual ControlMsg* decodeMsg();
00121   virtual void decodeMsg(KeepAliveMsg& msg);
00123   virtual void decodeMsg(GetConfigMsg& msg);
00125   virtual void decodeMsg(GetDataConnectionMsg& msg);
00127   virtual void decodeMsg(DataConnectionMsg& msg);
00129   virtual void decodeMsg(StartTransmissionMsg& msg);
00131   virtual void decodeMsg(StopTransmissionMsg& msg);
00133   virtual void decodeMsg(ConfigMsg& msg);
00135   virtual void decodeMsg(ReplyMsg& msg);
00136 
00137 private:
00139   ControlMsg* decodeMsgInternal();
00141   bool getXmlMsgType(ticpp::Element& header, std::string& type) const;
00143   bool decodeHeader(ControlMsg& msg);
00144 
00145 private:
00146   TiXmlDocument*                        tixml_doc_;
00147   ticpp::Document*                      xml_doc_;
00148   ticpp::Element*                       xml_msg_header_;
00149 
00150   typedef boost::shared_ptr<ControlMsg> ControlMsgHandle;
00151   std::map<std::string, ControlMsgHandle> prototypes_;
00152 };
00153 
00154 } // Namespace tobiss
00155 
00156 #endif //CONTROLMESSAGEDECODER_H
00157 
00158 // End Of File
 All Data Structures Files Functions Variables Typedefs Enumerations