Wiselib
wiselib.testing/algorithms/localization/distance_based/modules/distance/localization_gpsfree_lcs_messages.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  ** This file is part of the generic algorithm library Wiselib.           **
00003  ** Copyright (C) 2008,2009 by the Wisebed (www.wisebed.eu) project.      **
00004  **                                                                       **
00005  ** The Wiselib is free software: you can redistribute it and/or modify   **
00006  ** it under the terms of the GNU Lesser General Public License as        **
00007  ** published by the Free Software Foundation, either version 3 of the    **
00008  ** License, or (at your option) any later version.                       **
00009  **                                                                       **
00010  ** The Wiselib is distributed in the hope that it will be useful,        **
00011  ** but WITHOUT ANY WARRANTY; without even the implied warranty of        **
00012  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         **
00013  ** GNU Lesser General Public License for more details.                   **
00014  **                                                                       **
00015  ** You should have received a copy of the GNU Lesser General Public      **
00016  ** License along with the Wiselib.                                       **
00017  ** If not, see <http://www.gnu.org/licenses/>.                           **
00018  ***************************************************************************/
00019 #ifndef __ALGORITHMS_LOCALIZATION_DISTANCE_BASED_LOCALIZATION_GPSFREE_LCS_MESSAGES_H
00020 #define __ALGORITHMS_LOCALIZATION_DISTANCE_BASED_LOCALIZATION_GPSFREE_LCS_MESSAGES_H
00021 
00022 #include "util/serialization/simple_types.h"
00023 #include "util/serialization/math_vec.h"
00024 #include "algorithms/localization/distance_based/util/localization_defutils.h"
00025 
00026 namespace wiselib
00027 {
00028 
00029    template<typename OsModel_P,
00030             typename Radio_P>
00031    class LocalizationGpsFreeLcsInitMessage
00032    {
00033    public:
00034       typedef OsModel_P OsModel;
00035       typedef Radio_P Radio;
00036       typedef typename Radio::node_id_t node_id_t;
00037       typedef typename Radio::block_data_t block_data_t;
00038       typedef typename Radio::size_t size_t;
00039       typedef typename Radio::message_id_t message_id_t;
00040       // --------------------------------------------------------------------
00041       inline LocalizationGpsFreeLcsInitMessage();
00042       // --------------------------------------------------------------------
00043       inline message_id_t msg_id()
00044       { return read<OsModel, block_data_t, message_id_t>( buffer ); };
00045       // --------------------------------------------------------------------
00046       inline void set_msg_id( message_id_t id )
00047       { write<OsModel, block_data_t, message_id_t>( buffer, id ); }
00048       // --------------------------------------------------------------------
00049       inline Vec position()
00050       { return read<OsModel, block_data_t, Vec>(buffer + POSITION_POS); }
00051       // --------------------------------------------------------------------
00052       inline void set_position( Vec pos )
00053       { write<OsModel, block_data_t, Vec>(buffer + POSITION_POS, pos); }
00054       // --------------------------------------------------------------------
00055       inline size_t buffer_size()
00056       { return MSGEND_POS; }
00057 
00058    private:
00059       enum data_positions
00060       {
00061          POSITION_POS = sizeof(message_id_t),
00062          MSGEND_POS = POSITION_POS + 3 * sizeof(double)
00063       };
00064 
00065       block_data_t buffer[MSGEND_POS];
00066    };
00067    // -----------------------------------------------------------------------
00068    template<typename OsModel_P,
00069             typename Radio_P>
00070    LocalizationGpsFreeLcsInitMessage<OsModel_P, Radio_P>::
00071    LocalizationGpsFreeLcsInitMessage()
00072    {
00073       set_msg_id( 0 );
00074    }
00075    // -----------------------------------------------------------------------
00076    // -----------------------------------------------------------------------
00077    // -----------------------------------------------------------------------
00078    template<typename OsModel_P,
00079             typename Radio_P,
00080             typename DistanceMap_P>
00081    class LocalizationGpsFreeLcsNeighborMessage
00082    {
00083    public:
00084       typedef OsModel_P OsModel;
00085       typedef Radio_P Radio;
00086       typedef DistanceMap_P DistanceMap;
00087       typedef typename Radio::node_id_t node_id_t;
00088       typedef typename Radio::block_data_t block_data_t;
00089       typedef typename Radio::size_t size_t;
00090       typedef typename Radio::message_id_t message_id_t;
00091       // --------------------------------------------------------------------
00092       inline LocalizationGpsFreeLcsNeighborMessage();
00093       // --------------------------------------------------------------------
00094       inline message_id_t msg_id()
00095       { return read<OsModel, block_data_t, message_id_t>( buffer ); };
00096       // --------------------------------------------------------------------
00097       inline void set_msg_id( message_id_t id )
00098       { write<OsModel, block_data_t, message_id_t>( buffer, id ); }
00099       // --------------------------------------------------------------------
00100       inline DistanceMap& neighbors()
00101       { return neighbors_; }
00102       // --------------------------------------------------------------------
00103       inline void set_neighbors( DistanceMap& neighbors )
00104       { neighbors_ = neighbors; }
00105       // --------------------------------------------------------------------
00106       inline size_t buffer_size()
00107       { return MSGEND_POS; }
00108 
00109    private:
00110       enum data_positions
00111       {
00112          NEIGHBORS_POS = sizeof(message_id_t),
00113          MSGEND_POS = NEIGHBORS_POS + 1
00114       };
00115 
00116       block_data_t buffer[MSGEND_POS];
00117       // TODO: write this in buffer - as done in euclidean_neighbor_message
00118       DistanceMap neighbors_;
00119    };
00120    // -----------------------------------------------------------------------
00121    template<typename OsModel_P,
00122             typename Radio_P,
00123             typename DistanceMap_P>
00124    LocalizationGpsFreeLcsNeighborMessage<OsModel_P, Radio_P, DistanceMap_P>::
00125    LocalizationGpsFreeLcsNeighborMessage()
00126    {
00127       set_msg_id( 0 );
00128    }
00129 
00130 }// namespace wiselib
00131 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines