OverSim
Landmark.cc
Go to the documentation of this file.
1 //
2 // Copyright (C) 2008 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
24 #include <cassert>
25 
27 #include <BootstrapList.h>
28 #include <NeighborCache.h>
29 #include <GlobalNodeList.h>
30 #include <GlobalStatistics.h>
31 
32 #include "Landmark.h"
33 
35 
37 }
38 
39 void Landmark::initializeApp(int stage)
40 {
41  if (stage != MAX_STAGE_APP)
42  return;
43 
44  SimpleNodeEntry* entry =
45  dynamic_cast<SimpleInfo*>(globalNodeList->
46  getPeerInfo(thisNode.getIp()))->getEntry();
47 
48  // Get the responsible Landmark churn generator
49  /*
50  ChurnGenerator* lmChurnGen = NULL;
51  for (uint8_t i = 0; i < underlayConfigurator->getChurnGeneratorNum(); i++) {
52  ChurnGenerator* searchedGen;
53  searchedGen = underlayConfigurator->getChurnGenerator(i);
54  if (searchedGen->getNodeType().overlayType == "oversim.common.cbr.LandmarkModules") {
55  lmChurnGen = searchedGen;
56  }
57  }
58  */
59 
60  if (true) { //TODO
61  // magic placement using underlays coords
62  std::vector<double> ownCoords;
63  for (uint8_t i = 0; i < entry->getDim(); i++) {
64  ownCoords.push_back(entry->getCoords(i));
65  }
66 
67  Nps& nps = (Nps&)neighborCache->getNcsAccess();
68  nps.setOwnCoordinates(ownCoords);
69  nps.setOwnLayer(0);
70 
74  } else {
75  //TODO
76  }
77 }
78 
80 {
81  if (((Nps&)(neighborCache->getNcsAccess())).getReceivedCalls() != 0) {
82  globalStatistics->recordOutVector("Calls to Landmarks",
83  ((Nps&)(neighborCache->getNcsAccess())).getReceivedCalls());
84  }
85 }
86