00001 #ifndef DIVINE_MESSAGE_HH
00002 #define DIVINE_MESSAGE_HH
00003
00006 #ifndef DOXYGEN_PROCESSING
00007 #include "common/types.hh"
00008 #include "system/state.hh"
00009 #include "storage/explicit_storage.hh"
00010
00011 namespace divine {
00012 #endif // DOXYGEN_PROCESSING
00013
00015
00026 class message_t
00027 {
00028 private:
00029 byte_t * data;
00030 size_int_t size;
00031 size_int_t alloc_step;
00032 size_int_t first;
00033 size_int_t end;
00034 void potentially_realloc(const size_int_t increment);
00035 public:
00037
00042 message_t(const size_int_t number_of_preallocated_bytes=1024,
00043 const size_int_t reallocation_step=1024);
00044
00046
00047 ~message_t() { delete [] data; }
00048
00050 byte_t * get_data() { return data; }
00052 const byte_t * get_data() const { return data; }
00054
00063 void set_data(byte_t * const new_data, const size_int_t new_allocated_size,
00064 const size_int_t new_written_size);
00066
00073 void set_data(byte_t * const new_data, const size_int_t new_allocated_size);
00074
00076
00083 void load_data(byte_t * const new_data, const size_int_t new_allocated_size)
00084 { rewind(); append_data(new_data, new_allocated_size); }
00085
00087 size_int_t get_allocated_size() const { return size; }
00090 size_int_t get_written_size() const { return end; }
00092
00095 void set_written_size(const size_int_t new_size) { end = new_size; }
00096
00098
00102 void append_data(const byte_t * const data_to_copy,
00103 const size_int_t size_to_copy);
00105
00110 void append_state(const state_t state);
00112 void append_state_ref(const state_ref_t state_ref);
00114
00116 void append_bool(const bool flag);
00118 void append_byte(const byte_t number);
00120 void append_sbyte(const sbyte_t number);
00122 void append_sshort_int(const sshort_int_t number);
00124 void append_ushort_int(const ushort_int_t number);
00126 void append_slong_int(const slong_int_t number);
00128 void append_ulong_int(const ulong_int_t number);
00130 void append_size_int(const size_int_t number);
00131
00133
00137 void read_data(char * const data_to_copy, const std::size_t size_to_copy);
00139
00146 void read_state(state_t & state);
00148 void read_state_ref(state_ref_t & ref);
00150 void read_bool(bool & flag);
00152 void read_byte(byte_t & number);
00154 void read_sbyte(sbyte_t & number);
00156 void read_sshort_int(sshort_int_t & number);
00158 void read_ushort_int(ushort_int_t & number);
00160 void read_slong_int(slong_int_t & number);
00162 void read_ulong_int(ulong_int_t & number);
00164 void read_size_int(size_int_t & number);
00165
00167
00168 void rewind_read() { first = 0; }
00170
00175 void rewind_append() { end = 0; }
00177
00183 void rewind() { first = 0; end = 0; }
00184 };
00185
00186
00187
00188 #ifndef DOXYGEN_PROCESSING
00189 }
00190 #endif // DOXYGEN_PROCESSING
00191
00192 #endif
00193
00194
00195
00196