node-core.h

Go to the documentation of this file.
00001 /* -*- Mode:C++; -*- */
00002 /*
00003  * Copyright (c) 2006 Regents of the SIGNET lab, University of Padova.
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. Neither the name of the University of Padova (SIGNET lab) nor the 
00015  *    names of its contributors may be used to endorse or promote products 
00016  *    derived from this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00019  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
00020  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
00021  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
00022  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00023  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00024  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
00025  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
00026  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
00027  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00028  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  */
00030 
00037 #ifndef _NODECORE_
00038 #define _NODECORE_
00039 
00040 #include <object.h>
00041 #include <clsap.h>
00042 #include <clmessage.h>
00043 
00052 class Position : public TclObject
00053 {
00054         public:
00058                 Position();
00062                 virtual ~Position();
00069                 virtual double getX();
00076                 virtual double getY();
00083                 virtual double getZ();
00084 
00092                 virtual double getDist(Position* p);
00093 
00102   virtual double getRelAzimuth(Position* p);
00103 
00112   virtual double getRelZenith(Position* p);
00113 
00120                 virtual void setX(double x);
00127                 virtual void setY(double y);
00134                 virtual void setZ(double z);
00157                 virtual int command(int argc, const char*const* argv);
00158         protected:
00160                 double x_;
00162                 double y_;
00164                 double z_;
00165 };
00166 
00174 class NodeCore : public TclObject, public Handler {
00175 public:
00179         NodeCore();
00183         virtual ~NodeCore();
00190         virtual void battery(double battery);
00197         inline double battery() { return battery_; }    // return the current level of the battery
00207         virtual int crLayCommand(ClMessage* m);
00217         virtual int synchronousCrLayCommand(ClMessage* m);
00238         virtual int command(int argc, const char*const* argv);
00245         virtual Position *getPosition();
00246 private:
00248         ClSAP*** crossLayerSAPlist_;
00250         int nLayer_;
00252         int *clsapPerLayer_;
00263         void sendClSAP(int i, int j, ClMessage *m);
00274         void sendSynchronousClSAP(int i, int j, ClMessage *m);
00285         int addClSAP(ClSAP *clsap, int level);          // PRIVATE ???
00293         int getNLayer();
00303         int getNClSAP(int layer);
00314         int getPluginID(int i, int j);
00324         int getLayer(int pluginId);
00334         int getIdInLayer(int pluginId);
00335         void handle(Event *e);
00337         int *pluginLayer_;
00339         int *pluginIdInLayer_;
00341         int pluginNum_;
00343         Position *position_;
00345         double battery_;        // level of the battery
00346         // ...other node parameters
00347 };
00348 
00349 #endif

Generated on Wed Nov 26 15:47:28 2008 for NS-MIRACLE library by  doxygen 1.5.2