00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __GLOVE_COMM_COMMANDINTERFACE_HPP_
00028 #define __GLOVE_COMM_COMMANDINTERFACE_HPP_
00029
00030 #include "../config.hpp"
00031
00032 #include <sstream>
00033 #include <string>
00034 #include <vector>
00035
00036 #include <boost/cstdint.hpp>
00037 #include <boost/foreach.hpp>
00038
00039 namespace glove {
00040 namespace comm {
00041
00048 class API CommandInterface {
00049 public:
00051 typedef std::vector<boost::uint8_t> result_type;
00052
00056 CommandInterface();
00060 virtual ~CommandInterface();
00061
00066 virtual void requestDeviceList(result_type& result) = 0;
00072 virtual void connect(result_type& result, const int deviceId) = 0;
00078 virtual void disconnect(result_type& result, const int deviceId) = 0;
00084 virtual void isConnected(result_type& result, const int deviceId) = 0;
00085
00091 virtual void numSensors(result_type& result, const int deviceId) = 0;
00097 virtual void isRightHanded(result_type& result, const int deviceId) = 0;
00103 virtual void isLeftHanded(result_type& result, const int deviceId) = 0;
00104
00111 virtual void getValue(result_type& result, const int deviceId, const int sensor) = 0;
00117 virtual void getValues(result_type& result, const int deviceId) = 0;
00118
00124 virtual void info(result_type& result, const int deviceId) = 0;
00130 virtual void version(result_type& result, const int deviceId) = 0;
00131
00138 template<typename T>
00139 static std::vector<boost::uint8_t> toByteVector(const T t) {
00140 std::ostringstream oss;
00141 oss << t;
00142 return toByteVector(oss.str());
00143 }
00150 template<typename T>
00151 static std::vector<boost::uint8_t> toByteVectorN(const std::vector<T> v) {
00152 std::ostringstream oss;
00153
00154 BOOST_FOREACH(T t, v)
00155 {
00156 oss << t << ",";
00157 }
00158
00159 return toByteVector(oss.str(), oss.str().size() - 1);
00160 }
00161
00169 static std::vector<boost::uint8_t> toByteVector(const std::string& str, const int length = -1);
00170
00171 };
00172
00173 }
00174 }
00175
00176 #endif