TOBI Interface A  0.1
/home/breidi/Dropbox/libtia/include/tia-private/newtia/server_impl/control_connection_2.h
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 
00034 #ifndef SERVER_CONTROL_CONNECTION_H
00035 #define SERVER_CONTROL_CONNECTION_H
00036 
00037 #include "tia-private/newtia/network/socket.h"
00038 #include "tia-private/newtia/tia_control_command.h"
00039 #include "tia-private/newtia/tia_control_command_context.h"
00040 #include "tia-private/newtia/messages/tia_control_message.h"
00041 #include "tia-private/newtia/messages/tia_control_message_builder.h"
00042 #include "tia-private/newtia/messages/tia_control_message_parser.h"
00043 #include "tia-private/newtia/server/tia_server_state_server.h"
00044 #include "tia-private/newtia/hardware_interface.h"
00045 #include "tia-private/newtia/server/data_server.h"
00046 
00047 #include <boost/thread.hpp>
00048 #include <map>
00049 
00050 namespace tia
00051 {
00052 
00053 //-----------------------------------------------------------------------------
00054 class ControlConnection2
00055 {
00056 public:
00057     ControlConnection2 (boost::shared_ptr<Socket> socket,
00058                         DataServer& data_server,
00059                         TiAServerStateServer& server_state_server,
00060                         HardwareInterface& hardware_interface);
00061     ~ControlConnection2 ();
00062 
00063     void asyncStart ();
00064     void stop ();
00065     bool isRunning () const;
00066     unsigned getId () const {return id_;}
00067     std::string getRemoteEndPointAsString() { return socket_->getRemoteEndPointAsString();}
00068 
00069 private:
00070     void run ();
00071 
00072     bool running_;
00073     boost::shared_ptr<Socket>              socket_;
00074     DataServer&                            data_server_;
00075     TiAServerStateServer&                  server_state_server_;
00076     TiAControlCommandContext               command_context_;
00077 
00078     typedef std::map<std::string, TiAControlCommand*> CommandMap;
00079     CommandMap command_map_;
00080 
00081     std::auto_ptr<TiAControlMessageParser> parser_;
00082     std::auto_ptr<TiAControlMessageBuilder> builder_;
00083     boost::thread* thread_;
00084 
00085     unsigned id_;
00086     static unsigned next_free_id_;
00087 };
00088 
00089 }
00090 
00091 #endif // CONTROL_CONNECTION_SERVER_2_H
 All Data Structures Files Functions Variables Typedefs Enumerations