event_record.cpp

Go to the documentation of this file.
00001 #ifndef EVENT_RECORD_IMPLEMENTATION_FILE
00002 #define EVENT_RECORD_IMPLEMENTATION_FILE
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : event_record                                                      *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2005-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "event_record.h"
00019 
00020 #include <basis/set.cpp>
00021 
00022 using namespace basis;
00023 
00024 event_record::event_record(int id, int event)
00025 : _id(id), _event(event), _data(), _targets() {}
00026 
00027 event_record::event_record(int id, int event,
00028     const byte_array &data, const int_set &targets)
00029 : _id(id), _event(event), _data(data), _targets(targets) {}
00030 
00031 event_record::~event_record() {}
00032 
00033 void event_record::pack(byte_array &packed_form) const
00034 {
00035   attach(packed_form, _id);
00036   attach(packed_form, _event);
00037   attach(packed_form, _data);
00038   ::pack_simple(packed_form, _targets);
00039 }
00040 
00041 bool event_record::unpack(byte_array &packed_form)
00042 {
00043   if (!detach(packed_form, _id)) return false;
00044   if (!detach(packed_form, _event)) return false;
00045   if (!detach(packed_form, _data)) return false;
00046   if (!::unpack_simple(packed_form, _targets)) return false;
00047   return true;
00048 }
00049 
00050 
00051 #endif //EVENT_RECORD_IMPLEMENTATION_FILE
00052 

Generated on Thu Nov 20 04:28:47 2008 for HOOPLE Libraries by  doxygen 1.5.1