iSpike  2.1
Spike conversion library for robotics
D:/Home/Programs/iSpike/include/iSpike/YarpConnection.hpp
Go to the documentation of this file.
00001 #ifndef YARPINTERFACE_HPP_
00002 #define YARPINTERFACE_HPP_
00003 
00004 //iSpike includes
00005 #include <iSpike/YarpPortDetails.hpp>
00006 #include <iSpike/Bitmap.hpp>
00007 
00008 //Other includes
00009 #include <string>
00010 #include <boost/asio.hpp>
00011 #include <boost/mpl/vector.hpp>
00012 using namespace std;
00013 using boost::asio::ip::tcp;
00014 
00015 namespace ispike {
00016 
00018         class YarpConnection {
00019                 public:
00020                         YarpConnection(std::string ip, unsigned port);
00021                         ~YarpConnection();
00022                         int connect_to_port(std::string ip, unsigned port);
00023                         map<string, YarpPortDetails>& getPortMap() { return portMap; }
00024                         string getSocketString();
00025                         void prepare_to_read_binary();
00026                         void prepare_to_read_text();
00027                         bool read_image(Bitmap& bitmap);
00028                         std::string read_until(string until);
00029                         int write_text(std::string message);
00030 
00031 
00032                 private:
00033                         //==========================  VARIABLES  ===========================
00035                         map<string, YarpPortDetails> portMap;
00036 
00037                         tcp::socket* connectionSocket;
00038                         boost::asio::io_service io_service;
00039 
00040                         //===========================  METHODS  ============================
00041                         void disconnect();
00042                         int read_binary(unsigned char* buffer, int length);
00043                         unsigned char read_char();
00044                         int read_data_header();
00045                         int read_int(unsigned char* buf);
00046                         string read_text();
00047                         int write_binary(unsigned char* buffer, int length);
00048 
00049         };
00050 
00051 }
00052 
00053 #endif /* YARPINTERFACE_HPP_ */
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines