18 #ifndef INCLUDED_RPC_COMMON_HPP 19 #define INCLUDED_RPC_COMMON_HPP 21 #define USE_BINARY_ARCHIVE 0 27 #if (USE_BINARY_ARCHIVE) 28 #include <boost/archive/binary_oarchive.hpp> 29 #include <boost/archive/binary_iarchive.hpp> 31 #include <boost/archive/text_oarchive.hpp> 32 #include <boost/archive/text_iarchive.hpp> 35 namespace uhd {
namespace usrprio_rpc {
41 #define build_client_id(host_id, process_id) \ 42 ((static_cast<boost::uint64_t>(host_id) << 32) | static_cast<boost::uint64_t>(process_id)) 43 #define get_process_id_from_client_id(client_id) \ 44 (static_cast<boost::int32_t>(client_id)) 45 #define get_host_id_from_client_id(client_id) \ 46 (static_cast<boost::uint32_t>(client_id >> 32)) 80 template<
typename data_t>
81 void push(
const data_t& d) {
85 template<
typename data_t>
91 void store(std::vector<char>& data)
const {
92 const std::string& str = _stream.str();
93 data.resize(str.length());
94 data.assign((
char*)str.c_str(), ((
char*)str.c_str()) + str.length());
98 std::ostringstream _stream;
99 #if (USE_BINARY_ARCHIVE) 100 boost::archive::binary_oarchive _archive;
102 boost::archive::text_oarchive _archive;
111 template<
typename data_t>
113 if (_archive) (*_archive) >> d;
116 template<
typename data_t>
122 void load(
const std::vector<char>& data) {
123 _stream.str(std::string(data.begin(), data.end()));
124 #if (USE_BINARY_ARCHIVE) 125 _archive.reset(
new boost::archive::binary_iarchive(_stream, boost::archive::no_header));
127 _archive.reset(
new boost::archive::text_iarchive(_stream, boost::archive::no_header));
132 std::istringstream _stream;
133 #if (USE_BINARY_ARCHIVE) 134 boost::scoped_ptr<boost::archive::binary_iarchive> _archive;
136 boost::scoped_ptr<boost::archive::text_iarchive> _archive;
143 #if (USE_BINARY_ARCHIVE) 144 typedef boost::archive::binary_oarchive archive_t;
146 typedef boost::archive::text_oarchive archive_t;
148 std::ostringstream stream;
149 archive_t dummy_archive(stream, boost::archive::no_header);
150 return static_cast<boost::int32_t
>(dummy_archive.get_library_version());
156 #undef USE_BINARY_ARCHIVE Definition: rpc_common.hpp:76
void pull(data_t &d) const
Definition: rpc_common.hpp:112
void push(const data_t &d)
Definition: rpc_common.hpp:81
static boost::int32_t get_version()
Definition: rpc_common.hpp:142
Definition: rpc_common.hpp:107
client_id_t client_id
Definition: rpc_common.hpp:53
Definition: rpc_common.hpp:49
boost::int32_t boost_archive_version
Definition: rpc_common.hpp:52
Definition: convert.hpp:28
func_args_header_t header
Definition: rpc_common.hpp:71
void store(std::vector< char > &data) const
Definition: rpc_common.hpp:91
void load(const std::vector< char > &data)
Definition: rpc_common.hpp:122
boost::uint32_t version
Definition: rpc_common.hpp:50
func_args_writer_t()
Definition: rpc_common.hpp:78
boost::uint64_t client_id_t
Definition: rpc_common.hpp:39
boost::int32_t func_id_t
Definition: rpc_common.hpp:38
boost::uint32_t oldest_comp_version
Definition: rpc_common.hpp:51
Definition: rpc_common.hpp:140
std::vector< char > data
Definition: rpc_common.hpp:72
func_args_reader_t()
Definition: rpc_common.hpp:109
Definition: rpc_common.hpp:69