libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
binarycodec.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2013 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6 
7 #ifndef _QI_TYPE_BINARYCODEC_HPP_
8 #define _QI_TYPE_BINARYCODEC_HPP_
9 
10 #include <qi/atomic.hpp>
11 
12 #include <qi/api.hpp>
13 #include <boost/function.hpp>
14 #include <qi/buffer.hpp>
15 #include <qi/anyvalue.hpp>
16 #include <qi/type/metaobject.hpp>
17 #include <qi/objectuid.hpp>
18 
19 namespace qi {
20 
23  {
25  : transmitMetaObject(true),
27  {}
28 
34  boost::optional<ObjectUid> objectUid;
35  static const qi::uint32_t notCached = 0xFFFFFFFF;
36  };
37 
38  class StreamContext;
39 
41  using DeserializeObjectCallback = boost::function<AnyObject(const ObjectSerializationInfo&)>;
42 
44  using SerializeObjectCallback = boost::function<ObjectSerializationInfo(const AnyObject&)>;
45 
46  template <typename T>
49  StreamContext* streamContext = 0
50  );
51 
59  QI_API void encodeBinary(qi::Buffer *buf, const AutoAnyReference &gvp, SerializeObjectCallback onObject=SerializeObjectCallback(), StreamContext* ctx=0);
60 
61 
72 
73  template <typename T>
74  AnyReference decodeBinary(qi::BufferReader *buf, T* value, DeserializeObjectCallback onObject, StreamContext* ctx) {
75  return decodeBinary(buf, AnyReference::fromPtr(value), onObject, ctx);
76  }
77 }
78 
79 #endif // _QITYPE_BINARYCODEC_HPP_
AnyReference decodeBinary(qi::BufferReader *buf, T *value, DeserializeObjectCallback onObject=DeserializeObjectCallback(), StreamContext *streamContext=0)
Definition: binarycodec.hpp:74
#define QI_API
Definition: api.hpp:33
uint32_t uint32_t
Definition: types.hpp:65
boost::function< AnyObject(const ObjectSerializationInfo &)> DeserializeObjectCallback
Type of callback invoked by sdeerializer when it encounters an object.
Definition: binarycodec.hpp:41
void encodeBinary(qi::Buffer *buf, const AutoAnyReference &gvp, SerializeObjectCallback onObject=SerializeObjectCallback(), StreamContext *ctx=0)
static const qi::uint32_t notCached
Definition: binarycodec.hpp:35
dll import/export and compiler message
Informations passed when serializing an object.
Definition: binarycodec.hpp:22
boost::optional< ObjectUid > objectUid
Definition: binarycodec.hpp:34
boost::function< ObjectSerializationInfo(const AnyObject &)> SerializeObjectCallback
Type of callback invoked by serializer when it encounters an object.
Definition: binarycodec.hpp:44
Class to read const buffer. <includename>qi/buffer.hpp</includename> This class is intendeed to rea...
Definition: buffer.hpp:227
static AnyReference fromPtr(const T *ptr)
Class to store buffer. <includename>qi/buffer.hpp</includename> .
Definition: buffer.hpp:76
Description of the signals and methods accessible on an ObjectTypeInterface.
Definition: metaobject.hpp:25