Go to the documentation of this file.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
00028
00029
00030 #ifndef RVE_PROPERTIES_MESSAGES_H
00031 #define RVE_PROPERTIES_MESSAGES_H
00032
00033 #include "property_value.h"
00034
00035 #include <rve_msgs/Vector3.h>
00036 #include <rve_msgs/Quaternion.h>
00037
00038 namespace rve_properties
00039 {
00040
00041 template<typename T>
00042 struct Vector3Traits
00043 {
00044 inline static const char* typeName() { return "vector3"; }
00045
00046 inline static std::string toString(void* mem)
00047 {
00048 T* t = reinterpret_cast<T*>(mem);
00049 std::ostringstream os;
00050 os << t->x << " " << t->y << " " << t->z;
00051 return os.str();
00052 }
00053
00054 inline static void fromString(void* mem, const std::string& str)
00055 {
00056 T* t = reinterpret_cast<T*>(mem);
00057 std::istringstream is(str);
00058 is >> t->x;
00059 is.ignore();
00060 is >> t->y;
00061 is.ignore();
00062 is >> t->z;
00063 }
00064 };
00065
00066 template<typename T>
00067 struct QuaternionTraits
00068 {
00069 inline static const char* typeName() { return "quaternion"; }
00070
00071 inline static std::string toString(void* mem)
00072 {
00073 T* t = reinterpret_cast<T*>(mem);
00074 std::ostringstream os;
00075 os << t->x << " " << t->y << " " << t->z << " " << t->w;
00076 return os.str();
00077 }
00078
00079 inline static void fromString(void* mem, const std::string& str)
00080 {
00081 T* t = reinterpret_cast<T*>(mem);
00082 std::istringstream is(str);
00083 is >> t->x;
00084 is.ignore();
00085 is >> t->y;
00086 is.ignore();
00087 is >> t->z;
00088 is.ignore();
00089 is >> t->w;
00090 }
00091 };
00092
00093 template<>
00094 struct ValueTraits<rve_msgs::Vector3> : public Vector3Traits<rve_msgs::Vector3>
00095 {
00096 };
00097
00098 template<>
00099 struct ValueTraits<rve_msgs::Quaternion> : public QuaternionTraits<rve_msgs::Quaternion>
00100 {
00101 };
00102
00103 }
00104
00105 #endif // RVE_PROPERTIES_MESSAGES_H