source: source/ariba/DataMessage.h@ 12756

Last change on this file since 12756 was 12060, checked in by hock@…, 11 years ago

Reintegrate branch: 20130111-hock-message_classes

improvements:

  • new message classes (reboost, zero-copy)
  • "fast path" for direct links (skip overlay layer)
  • link-properties accessible from the application
  • SystemQueue can call boost::bind functions
  • protlib compatibility removed (32bit overhead saved in every message)
  • addressing2
  • AddressDiscovery discoveres only addresses on which we're actually listening
  • ariba serialization usage reduced (sill used in OverlayMsg)
  • Node::connect, easier and cleaner interface to start-up ariba from the application
  • ariba configs via JSON, XML, etc (boost::property_tree)
  • keep-alive overhead greatly reduced
  • (relayed) overlay links can actually be closed now
  • lost messages are detected in most cases
  • notification to the application when link is transformed into direct-link
  • overlay routing: send message to second best hop if it would be dropped otherwise
  • SequenceNumbers (only mechanisms, so for: upward compatibility)
  • various small fixes


regressions:

  • bluetooth is not yet working again
  • bootstrap modules deactivated
  • liblog4xx is not working (use cout-logging)

This patch brings great performance and stability improvements at cost of backward compatibility.
Also bluetooth and the bootstrap modules have not been ported to the new interfaces, yet.

File size: 3.4 KB
RevLine 
[2393]1#ifndef DATAMESSAGE_H_
2#define DATAMESSAGE_H_
3
4#define USE_MESSAGE_UTILITY
5
6#include <memory>
7#include <inttypes.h>
8
9// use message utility
10#ifdef USE_MESSAGE_UTILITY
[12060]11// #include "ariba/utility/messages.h"
12 #include "ariba/utility/messages/Message.h"
[2393]13 namespace ariba {
14 typedef utility::Message Message;
15 }
16#endif
17
18namespace ariba {
19
20// define sequence number type
21typedef uint16_t seqnum_t;
22
23/**
[9684]24 * \addtogroup public
25 * @{
[2393]26 * This class wraps different representations of a message. In its current
27 * version is allows to specify binary data (as void*) with a size specifying
28 * the number of bytes of data or an message object that can be
29 * serialized if necessary. The main idea is, that simulation environments
30 * do not necessarily need to serialize messages.
31 *
32 * For performance reasons methods of this class are inlined where possible!
33 *
34 * @author Sebastian Mies <mies@tm.uka.de>
35 */
36class DataMessage {
37private:
[7535]38 void* data; //< internal buffer pointer
39 size_t size; //< internal buffer pointer size
[2393]40public:
[7535]41 static const DataMessage UNSPECIFIED; //< default implementation of a data message
[2393]42
[7535]43 /**
44 * Default constructor for a data message
45 */
[2393]46 inline DataMessage() {
47 this->data = NULL;
48 this->size = 0;
49 }
50
[7535]51 /**
52 * Constructor for a data message
53 * @param data Data buffer to carry in the message
54 * @param size Size of the buffer pointed to
55 */
[2393]56 inline DataMessage( const void* data, const size_t size ) {
57 this->data = const_cast<void*>(data);
58 this->size = size;
59 }
60
[7535]61 /**
62 * Copy constructor for a data message
63 * @param message The other message to copy from
64 */
[7497]65 inline DataMessage(const DataMessage& message){
66 this->data = message.data;
67 this->size = message.size;
68 }
69
[2393]70#ifdef USE_MESSAGE_UTILITY
[7535]71 /**
72 * Construct a data message from a normal message
73 * @param message The normal message to store
74 */
[2393]75 inline DataMessage( const Message* message ) {
76 this->data = (void*)const_cast<Message*>(message);
77 this->size = ~0;
78 }
79
[7535]80 /**
81 * Construct a data message from a normal message
82 * @param message The normal message to store
83 */
[2473]84 inline DataMessage( const Message& message ) {
85 this->data = (void*)const_cast<Message*>(&message);
86 this->size = ~0;
87 }
88
[7535]89 /**
90 * Get the internal message when constructued through one
91 * @return pointer to the message
92 */
[2393]93 inline Message* getMessage() const {
[7499]94 if (isData()) {
95 return new Message( Data((uint8_t*)data,size*8) );
96 }
[2393]97 return (Message*)data;
98 }
99
[7535]100 /**
101 * Conversion function to convert to Message*
102 * @return internal message
103 */
[2393]104 inline operator Message* () const {
[7499]105 return getMessage();
[2393]106 }
107#endif
108
[7535]109 /**
110 * Is the data message a normal message?
111 * @return true, if the data message is a normal message
112 */
[2393]113 inline bool isMessage() const {
[7500]114 return size == ~(size_t)0;
[2393]115 }
116
[7535]117 /**
118 * Is the data message a data message
119 * @return true, if the data message is not a normal message
120 */
[2393]121 inline bool isData() const {
[7500]122 return !isMessage();
[2393]123 }
124
[7535]125 /**
126 * Directly access the internal data pointer
127 * @return internal data pointer
128 */
[2393]129 inline void* getData() const {
130 return data;
131 }
132
[7535]133 /**
134 * Get the size of the internal buffer
135 * @return internal buffer size
136 */
[2393]137 inline size_t getSize() const {
138 return size;
139 }
140
[7535]141 /**
142 * Is the data message invalid?
143 * @return true, if data message is invalid
144 */
[2393]145 inline bool isUnspecified() const {
146 return data == NULL;
147 }
[7535]148
[2393]149};
[2435]150
[2393]151} // namespace ariba
152
[9684]153/** @} */
154
[2393]155#endif /* DATAMESSAGE_H_ */
Note: See TracBrowser for help on using the repository browser.