2 #include "BlockEvent.h"
3 #include "exception/EventException.h"
4 #include "misc/StreamAsString.h"
8 /* serialization format:
9 first bit is taken by BasicEvent
10 second and third bits are block_type
11 rest of the first byte is reserved
12 after that, depends on type . . .
14 Block
*BlockEvent::serialize() {
15 Block
*serialized
= BasicEvent::serialize();
17 serialized
->get_data()[0] |= (block_type
<< 1) & 0x06;
19 serialized
->push_word(get_address());
21 switch(get_block_type()) {
23 std::cout
<< "first byte of address is " << std::hex
<< (address
& 0xff) << std::endl
;
24 std::cout
<< "second byte of address is " << std::hex
<< ((address
& 0xff00) >> 8) << std::endl
;
25 serialized
->push_word(get_size());
28 /* NOTE: the new address first makes it easier to deserialize later */
29 serialized
->push_word(get_new_address());
30 serialized
->push_word(get_size());
32 case FREE_EVENT
: break;
34 throw Exception::EventException("Asked to serialize invalid Block event");