Refactor receiving code

This commit is contained in:
2018-07-05 16:56:31 +02:00
parent 88e7c9a79f
commit 48c3f80f8a
2 changed files with 9 additions and 5 deletions
+2 -2
View File
@@ -202,7 +202,7 @@ void copy_value_to_buffer(char* buffer, const size_t offset, const pt::ptree& js
}
}
shared_ptr<char> ZmqReceiver::get_value_from_json(const pt::ptree& json_header, const string& name, const HeaderDataType& header_data_type) const
shared_ptr<char> get_value_from_json(const pt::ptree& json_header, const string& name, const HeaderDataType& header_data_type)
{
char* buffer = new char[header_data_type.value_bytes_size * header_data_type.value_shape];
@@ -214,7 +214,7 @@ shared_ptr<char> ZmqReceiver::get_value_from_json(const pt::ptree& json_header,
for (const auto& item : json_header.get_child(name)) {
auto offset = index * header_data_type.value_bytes_size;
copy_value_to_buffer(buffer, offset, json_header.get_child(name), header_data_type);
copy_value_to_buffer(buffer, offset, item.second, header_data_type);
++index;
}
+7 -3
View File
@@ -23,7 +23,12 @@ struct HeaderDataType
};
size_t get_type_byte_size(const std::string& type);
void copy_value_to_buffer(const char* buffer, size_t offset, const boost::property_tree::ptree& json_value, const HeaderDataType& header_data_type);
void copy_value_to_buffer(const char* buffer, size_t offset, const boost::property_tree::ptree& json_value,
const HeaderDataType& header_data_type);
std::shared_ptr<char> get_value_from_json(const boost::property_tree::ptree& json_header,
const std::string& name, const HeaderDataType& header_data_type);
class ZmqReceiver
{
@@ -40,8 +45,7 @@ class ZmqReceiver
std::shared_ptr<FrameMetadata> read_json_header(const std::string& header);
std::shared_ptr<char> get_value_from_json(const boost::property_tree::ptree& json_header,
const std::string& name, const HeaderDataType& header_data_type) const;
public:
ZmqReceiver(const std::string& connect_address, const int n_io_threads, const int receive_timeout,