#pragma once #include "ros_bridge/rapidjson/include/rapidjson/document.h" #include namespace ros_bridge { //! @brief Namespace containing classes and methodes ros message generation. namespace messages { //! @brief Namespace containing classes and methodes for geometry_msgs generation. namespace nemo_msgs { //! @brief Namespace containing methodes for geometry_msgs/Point32 message generation. namespace progress { std::string messageType(){ return "nemo_msgs/Progress"; } //! @brief C++ representation of nemo_msgs/Progress message template class ContainterType = std::vector> class GenericProgress{ public: GenericProgress() {} GenericProgress(const ContainterType &progress) : _progress(progress){} GenericProgress(const GenericProgress &p) : _progress(p.progress()){} virtual const ContainterType &progress(void) const {return _progress;} virtual ContainterType &progress(void) {return _progress;} protected: ContainterType _progress; }; typedef GenericProgress<> Progress; template bool toJson(const ProgressType &p, rapidjson::Value &value, rapidjson::Document::AllocatorType &allocator) { rapidjson::Value jProgress(rapidjson::kArrayType); for(unsigned long i=0; i < std::uint64_t(p.progress().size()); ++i){ jProgress.PushBack(rapidjson::Value().SetInt(std::int32_t(p.progress()[i])), allocator); } value.AddMember("progress", jProgress, allocator); value.AddMember("type", rapidjson::Value().SetString(messageType().c_str()), allocator); return true; } template bool fromJson(const rapidjson::Value &value, ProgressType &p) { if (!value.HasMember("progress") || !value["progress"].IsArray()){ assert(false); return false; } const auto& jsonProgress = value["progress"]; unsigned long sz = jsonProgress.Size(); p.progress().clear(); p.progress().reserve(sz); for (unsigned long i=0; i < sz; ++i) p.progress().push_back(std::int32_t(jsonProgress[i].GetInt())); return true; } } // namespace progress } // namespace nemo_msgs } // namespace messages } // namespace ros_bridge