source: source/ariba/utility/addressing/facades/to_bytes_v.hpp@ 5641

Last change on this file since 5641 was 5284, checked in by mies, 15 years ago

+ added new transport modules and adapted ariba to them
+ exchange endpoint descriptors an link establishment
+ clean up of base communication
+ link establishment with in the presence of multiple endpoints
+ local discovery for ipv6, ipv4 and bluetooth mac addresses

File size: 1.8 KB
RevLine 
[5284]1// to_bytes_v.hpp, created on 30.06.2009 by Sebastian Mies
2
3#ifndef TO_BYTES_V_HPP_
4#define TO_BYTES_V_HPP_
5
6#include <memory>
7#include "vfacade.hpp"
8
9/**
10 * TODO: Doc
11 *
12 * @author Sebastian Mies <mies@tm.uka.de>
13 */
14class to_bytes_v {
15public:
16 //--- to_bytes_v ----------------------------------------------------------
17
18 /// returns true, if this address has a fixed size in bytes
19 virtual bool is_bytes_size_static() const = 0;
20
21 /// returns the number of bytes used for serialization of this address
22 virtual size_t to_bytes_size() const = 0;
23
24 /// converts this address to a binary representation
25 virtual void to_bytes(uint8_t* bytes) const = 0;
26
27 /// Assigns an address using a bunch of bytes
28 virtual bool assign(const uint8_t* bytes, size_t size) = 0;
29};
30
31typedef vfacade<to_bytes_v> to_bytes_vf;
32
33template<class NonVirtual, class AdaptorType>
34class vobject_hull<NonVirtual, to_bytes_v, AdaptorType> : public to_bytes_v {
35private:
36 typename AdaptorType::template adaptor_type<NonVirtual> obj;
37
38public:
39 template<typename T>
40 explicit vobject_hull(T& obj) :
41 obj(obj) {
42 }
43
44 explicit vobject_hull() :
45 obj() {
46 }
47
48 //--- to_bytes_v ----------------------------------------------------------
49
50 /// returns true, if this address has a fixed size in bytes
51 virtual bool is_bytes_size_static() const {
52 return obj->is_bytes_size_static();
53 }
54
55 /// returns the number of bytes used for serialization of this address
56 virtual size_t to_bytes_size() const {
57 return obj->to_bytes_size();
58 }
59
60 /// converts this address to a binary representation
61 virtual void to_bytes(uint8_t* bytes) const {
62 obj->to_bytes(bytes);
63 }
64
65 /// Assigns an address using a bunch of bytes
66 virtual bool assign(const uint8_t* bytes, size_t size) {
67 return obj->assign(bytes,size);
68 }
69};
70
71
72#endif /* TO_BYTES_V_HPP_ */
Note: See TracBrowser for help on using the repository browser.