Wiselib
wiselib.testing/algorithms/localization/distance_based/util/localization_shared_data.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_UTIL_SHARED_DATA_H
00020 #define __ALGORITHMS_LOCALIZATION_DISTANCE_BASED_UTIL_SHARED_DATA_H
00021 
00022 #include "algorithms/localization/distance_based/math/vec.h"
00023 #include "algorithms/localization/distance_based/util/localization_defutils.h"
00024 #include <float.h>
00025 
00026 namespace wiselib
00027 {
00028 
00029    template<typename OsModel_P,
00030             typename Radio_P,
00031             typename Clock_P,
00032             typename Neighborhood_P,
00033             typename NeighborInfoList_P,
00034             typename NodeSet_P,
00035             typename NodeList_P,
00036             typename DistanceMap_P,
00037             typename LocationMap_P,
00038             typename Arithmatic_P >
00039    class LocalizationSharedData
00040    {
00041       public:
00042          typedef OsModel_P OsModel;
00043          typedef Radio_P Radio;
00044          typedef Clock_P Clock;
00045 
00046          typedef Neighborhood_P Neighborhood;
00047          typedef typename Neighborhood::NeighborInfo NeighborInfo;
00048 
00049          typedef NeighborInfoList_P NeighborInfoList;
00050          typedef typename NeighborInfoList::iterator NeighborInfoListIterator;
00051 
00052          typedef NodeList_P NodeList;
00053          typedef NodeSet_P NodeSet;
00054          typedef DistanceMap_P DistanceMap;
00055          typedef LocationMap_P LocationMap;
00056          typedef Arithmatic_P Arithmatic;
00057 
00058          typedef LocalizationSharedData<OsModel, Radio, Clock, NeighborInfo, NeighborInfoList, NodeSet, NodeList, DistanceMap, LocationMap, Arithmatic> self_type;
00059 
00060          typedef typename Radio::node_id_t node_id_t;
00061          typedef typename Radio::size_t size_t;
00062          typedef typename Radio::block_data_t block_data_t;
00063 
00064          typedef typename Clock_P::time_t time_t;
00065 
00066          typedef LocalizationLocalCoordinateSystem<OsModel, node_id_t, Neighborhood, LocationMap, Arithmatic> LocalCoordinateSystem;
00067          // -----------------------------------------------------------------
00068          LocalizationSharedData()
00069             : anchor_      ( false ),
00070                confidence_ ( 0.1 ),
00071                position_   ( UNKNOWN_POSITION ),
00072                floodlimit_ ( 5 ),
00073                communication_range_ ( 15 ),
00074                check_residue_ ( true )
00075          {}
00076          // -----------------------------------------------------------------
00077          void set_position( const Vec<Arithmatic_P>& position )
00078          { position_ = position; }
00079          // -----------------------------------------------------------------
00080          const Vec<Arithmatic_P>& position( void )
00081          { return position_; }
00082          // -----------------------------------------------------------------
00083          void set_anchor( bool anchor )
00084          { anchor_ = anchor; }
00085          // -----------------------------------------------------------------
00086          bool is_anchor( void )
00087          { return anchor_; }
00088          // -----------------------------------------------------------------
00089          void set_confidence( Arithmatic confidence )
00090          { confidence_ = confidence; }
00091          // -----------------------------------------------------------------
00092          Arithmatic confidence( void )
00093          { return confidence_; }
00094          // -----------------------------------------------------------------
00095          void set_idle_time( time_t idle_time )
00096          { idle_time_ = idle_time; }
00097          // -----------------------------------------------------------------
00098          time_t idle_time( void )
00099          { return idle_time_; }
00100          // -----------------------------------------------------------------
00101          void set_floodlimit( unsigned int floodlimit )
00102          { floodlimit_ = floodlimit; }
00103          // -----------------------------------------------------------------
00104          unsigned int floodlimit( void )
00105          { return floodlimit_; }
00106          // -----------------------------------------------------------------
00107          void set_communication_range( int communication_range )
00108          { communication_range_ = communication_range; }
00109          // -----------------------------------------------------------------
00110          int communication_range( void )
00111          { return communication_range_; }
00112          // --------------------------------------------------------------------
00113          void set_check_residue( bool check_residue )
00114          { check_residue_ = check_residue; }
00115          // -----------------------------------------------------------------
00116          bool check_residue( void )
00117          { return check_residue_; }
00118          // -----------------------------------------------------------------
00119          Neighborhood& neighborhood( void )
00120          { return neighborhood_; }
00121          // -----------------------------------------------------------------
00122          LocalCoordinateSystem& local_coord_sys( void )
00123          { return local_coord_sys_; }
00124 
00125          void reset_neighborhood_( void )
00126          { neighborhood_.get_neighborhood().clear(); }
00127 
00128       private:
00129          bool anchor_;
00130          Arithmatic confidence_;
00131          Vec<Arithmatic_P> position_;
00132          unsigned int floodlimit_;
00133          int communication_range_;
00134          bool check_residue_;
00135          time_t idle_time_;
00136          Neighborhood neighborhood_;
00137          LocalCoordinateSystem local_coord_sys_;
00138    };
00139 
00140 }// namespace wiselib
00141 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines