Landmark.cc

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2008 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00024 #include <cassert>
00025 
00026 #include <SimpleUnderlayConfigurator.h>
00027 #include <BootstrapList.h>
00028 #include <NeighborCache.h>
00029 #include <GlobalNodeList.h>
00030 #include <GlobalStatistics.h>
00031 
00032 #include "Landmark.h"
00033 
00034 Define_Module(Landmark);
00035 
00036 Landmark::~Landmark() {
00037 }
00038 
00039 void Landmark::initializeApp(int stage)
00040 {
00041     if (stage != MIN_STAGE_APP)
00042         return;
00043 
00044     SimpleNodeEntry* entry =
00045         dynamic_cast<SimpleInfo*>(globalNodeList->
00046                                   getPeerInfo(thisNode.getAddress()))->getEntry();
00047 
00048     // Get the responsible Landmark churn generator
00049     /*
00050     ChurnGenerator* lmChurnGen = NULL;
00051     for (uint8_t i = 0; i < underlayConfigurator->getChurnGeneratorNum(); i++) {
00052         ChurnGenerator* searchedGen;
00053         searchedGen = underlayConfigurator->getChurnGenerator(i);
00054         if (searchedGen->getNodeType().overlayType == "oversim.common.cbr.LandmarkModules") {
00055             lmChurnGen = searchedGen;
00056         }
00057     }
00058     */
00059 
00060     if (true) { //TODO
00061         // magic placement using underlays coords
00062         std::vector<double> ownCoords;
00063         for (uint8_t i = 0; i < entry->getDim(); i++) {
00064             ownCoords.push_back(entry->getCoords(i));
00065         }
00066 
00067         Nps& nps = (Nps&)neighborCache->getNcsAccess();
00068         nps.setOwnCoordinates(ownCoords);
00069         nps.setOwnLayer(0);
00070 
00071         thisNode = overlay->getThisNode();
00072         globalNodeList->setOverlayReadyIcon(getThisNode(), true);
00073         globalNodeList->refreshEntry(getThisNode());
00074     } else {
00075         //TODO
00076     }
00077 }
00078 
00079 void Landmark::finishApp()
00080 {
00081     if (((Nps&)(neighborCache->getNcsAccess())).getReceivedCalls() != 0) {
00082         globalStatistics->recordOutVector("Calls to Landmarks",
00083             ((Nps&)(neighborCache->getNcsAccess())).getReceivedCalls());
00084     }
00085 }
00086 
Generated on Wed May 26 16:21:14 2010 for OverSim by  doxygen 1.6.3