• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/diffusion3/apps/gear_examples/gear_sender.hh

00001 //
00002 // gear_sender.hh : Gear Sender Include File
00003 // author         : Fabio Silva
00004 //
00005 // Copyright (C) 2000-2003 by the University of Southern California
00006 // $Id: gear_sender.hh,v 1.3 2005/09/13 04:53:46 tomh Exp $
00007 //
00008 // This program is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU General Public License,
00010 // version 2, as published by the Free Software Foundation.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License along
00018 // with this program; if not, write to the Free Software Foundation, Inc.,
00019 // 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00020 //
00021 // Linking this file statically or dynamically with other modules is making
00022 // a combined work based on this file.  Thus, the terms and conditions of
00023 // the GNU General Public License cover the whole combination.
00024 //
00025 // In addition, as a special exception, the copyright holders of this file
00026 // give you permission to combine this file with free software programs or
00027 // libraries that are released under the GNU LGPL and with code included in
00028 // the standard release of ns-2 under the Apache 2.0 license or under
00029 // otherwise-compatible licenses with advertising requirements (or modified
00030 // versions of such code, with unchanged license).  You may copy and
00031 // distribute such a system following the terms of the GNU GPL for this
00032 // file and the licenses of the other code concerned, provided that you
00033 // include the source code of that other code when and as the GNU GPL
00034 // requires distribution of source code.
00035 //
00036 // Note that people who make modified versions of this file are not
00037 // obligated to grant this special exception for their modified versions;
00038 // it is their choice whether to do so.  The GNU General Public License
00039 // gives permission to release a modified version without this exception;
00040 // this exception also makes it possible to release a modified version
00041 // which carries forward this exception.
00042 
00043 #ifndef _GEAR_SENDER_HH_
00044 #define _GEAR_SENDER_HH_
00045 
00046 #ifdef HAVE_CONFIG_H
00047 #include "config.h"
00048 #endif // HAVE_CONFIG_H
00049 
00050 #include "gear_common.hh"
00051 
00052 class GearSenderReceive;
00053 class GearSenderApp;
00054 
00055 #define SEND_DATA_INTERVAL 5
00056 
00057 #ifdef NS_DIFFUSION
00058 class GearSendDataTimer : public TimerHandler {
00059   public:
00060   GearSendDataTimer(GearSenderApp *a) : TimerHandler() { a_ = a; }
00061   void expire(Event *e);
00062 protected:
00063   GearSenderApp *a_;
00064 };
00065 #endif //NS_DIFFUSION
00066 
00067 class GearSenderApp : public DiffApp {
00068 public:
00069 #ifdef NS_DIFFUSION
00070   GearSenderApp();
00071   int command(int argc, const char*const* argv);
00072   void send();
00073 #else
00074   GearSenderApp(int argc, char **argv);
00075 #endif // NS_DIFFUSION
00076   
00077   virtual ~GearSenderApp()
00078   {
00079     // Nothing to do
00080   };
00081 
00082   void run();
00083   void recv(NRAttrVec *data, NR::handle my_handle);
00084 
00085 private:
00086   // NR Specific variables
00087   GearSenderReceive *mr_;
00088   handle subHandle_;
00089   handle pubHandle_;
00090 
00091   // Gear Sender App variables
00092   bool using_points_;
00093   bool using_push_;
00094   int num_subscriptions_;
00095   int last_seq_sent_;
00096   float lat_min_;
00097   float lat_max_;
00098   float long_min_;
00099   float long_max_;
00100   float lat_pt_;
00101   float long_pt_;
00102   NRAttrVec data_attr_;
00103   NRSimpleAttribute<void *> *timeAttr_;
00104   NRSimpleAttribute<int> *counterAttr_;
00105   EventTime *lastEventTime_;
00106 
00107   handle setupSubscription();
00108   handle setupPublication();
00109   void parseCommandLine(int argc, char **argv);
00110   void readGeographicCoordinates();
00111   void usage(char *s);
00112 #ifdef NS_DIFFUSION
00113   GearSendDataTimer sdt_;
00114 #endif // NS_DIFFUSION
00115 };
00116 
00117 class GearSenderReceive : public NR::Callback {
00118 public:
00119   GearSenderReceive(GearSenderApp *app) : app_(app) {};
00120   void recv(NRAttrVec *data, NR::handle my_handle);
00121 
00122   GearSenderApp *app_;
00123 };
00124 
00125 #endif // !_GEAR_SENDER_HH_

Generated on Tue Aug 10 2010 16:16:06 for ns-2.33 by  doxygen 1.7.1