Wiselib
wiselib.testing/algorithms/tracking/PLTT_reliable_agent.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 __PLTT_RELIABLE_AGENT_H__
00020 #define __PLTT_RELIABLE_AGENT_H__
00021 #include "PLTT_config.h"
00022 namespace wiselib
00023 {
00024    template<   typename Os_P,
00025             typename Radio_P,
00026             typename Agent_P,
00027             typename Time_P,
00028             typename Debug_P>
00029    class PLTT_ReliableAgentType
00030    {
00031    public:
00032       typedef Os_P Os;
00033       typedef Radio_P Radio;
00034       typedef Agent_P Agent;
00035       typedef Time_P Time;
00036       typedef Debug_P Debug;
00037       typedef typename Radio::node_id_t node_id_t;
00038       typedef typename Radio::message_id_t message_id_t;
00039       typedef typename Time::millis_t millis_t;
00040       typedef PLTT_ReliableAgentType<Os, Radio, Agent, Time, Debug> self_type;
00041       PLTT_ReliableAgentType()
00042       {}
00043       PLTT_ReliableAgentType( Agent _a, node_id_t _r, millis_t _et, millis_t _rt, message_id_t _m )
00044       {
00045          set_all( _a, _r, _et, _rt, _m );
00046       }
00047       inline self_type& operator=( const self_type& _ra)
00048       {
00049          agent = _ra.agent;
00050          receiver = _ra.receiver;
00051          exp_time = _ra.exp_time;
00052          rec_time = _ra.rec_time;
00053          message_id = _ra.message_id;
00054          return *this;
00055       }
00056       Agent get_agent()
00057       {
00058          return agent;
00059       }
00060       node_id_t get_receiver()
00061       {
00062          return receiver;
00063       }
00064       millis_t get_exp_time()
00065       {
00066          return exp_time;
00067       }
00068       millis_t get_rec_time()
00069       {
00070          return rec_time;
00071       }
00072       message_id_t get_message_id()
00073       {
00074          return message_id;
00075       }
00076       void set_agent( Agent _a )
00077       {
00078          agent = _a;
00079       }
00080       void set_receiver( node_id_t _r )
00081       {
00082          receiver = _r;
00083       }
00084       void set_exp_time( millis_t _et )
00085       {
00086          exp_time = _et;
00087       }
00088       void set_rec_time( millis_t _rt )
00089       {
00090          rec_time = _rt;
00091       }
00092       void set_message_id( message_id_t _m )
00093       {
00094          message_id = _m;
00095       }
00096       inline void set_all( Agent _a, node_id_t _r, millis_t _et , millis_t _rt, message_id_t _m )
00097       {
00098          agent = _a;
00099          receiver = _r;
00100          exp_time = _et;
00101          rec_time = _rt;
00102          message_id = _m;
00103       }
00104       void print( Debug& debug )
00105       {
00106          debug.debug( "reliable agent (size %i)\n", sizeof( self_type ) );
00107          agent.print( debug );
00108          debug.debug( "receiver (size %i): %x\n", sizeof( node_id_t ), receiver );
00109          debug.debug( "exp time (size %i): %i\n", sizeof( millis_t ), exp_time );
00110          debug.debug( "recurring time (size %i): %i\n", sizeof( millis_t ), rec_time );
00111          debug.debug( "message_id (size %i): %i\n", sizeof (message_id_t ), message_id );
00112       }
00113    private:
00114       Agent agent;
00115       node_id_t receiver;
00116       millis_t exp_time;
00117       millis_t rec_time;
00118       message_id_t message_id;
00119    };
00120 }
00121 #endif
00122 
00123 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines