00001
00002
00003 #ifndef TO_BYTES_V_HPP_
00004 #define TO_BYTES_V_HPP_
00005
00006 #include <memory>
00007 #include "vfacade.hpp"
00008
00014 class to_bytes_v {
00015 public:
00016
00017
00019 virtual bool is_bytes_size_static() const = 0;
00020
00022 virtual size_t to_bytes_size() const = 0;
00023
00025 virtual void to_bytes(uint8_t* bytes) const = 0;
00026
00028 virtual bool assign(const uint8_t* bytes, size_t size) = 0;
00029 };
00030
00031 typedef vfacade<to_bytes_v> to_bytes_vf;
00032
00033 template<class NonVirtual, class AdaptorType>
00034 class vobject_hull<NonVirtual, to_bytes_v, AdaptorType> : public to_bytes_v {
00035 private:
00036 typename AdaptorType::template adaptor_type<NonVirtual> obj;
00037
00038 public:
00039 template<typename T>
00040 explicit vobject_hull(T& obj) :
00041 obj(obj) {
00042 }
00043
00044 explicit vobject_hull() :
00045 obj() {
00046 }
00047
00048
00049
00051 virtual bool is_bytes_size_static() const {
00052 return obj->is_bytes_size_static();
00053 }
00054
00056 virtual size_t to_bytes_size() const {
00057 return obj->to_bytes_size();
00058 }
00059
00061 virtual void to_bytes(uint8_t* bytes) const {
00062 obj->to_bytes(bytes);
00063 }
00064
00066 virtual bool assign(const uint8_t* bytes, size_t size) {
00067 return obj->assign(bytes,size);
00068 }
00069 };
00070
00071
00072 #endif