SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MSBitSetLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Container for holding a right-of-way matrix
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSBitSetLogic_h
24 #define MSBitSetLogic_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <bitset>
37 #include <vector>
38 #include "MSJunctionLogic.h"
39 #include "MSLogicJunction.h"
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
50 template< size_t N >
52 public:
59  typedef std::vector< std::bitset< N > > Logic;
60 
63  typedef std::vector< std::bitset< N > > Foes;
64 
65 
66 public:
68  MSBitSetLogic(unsigned int nLinks,
69  Logic* logic,
70  Foes* foes,
71  std::bitset<64> conts)
72  : MSJunctionLogic(nLinks), myLogic(logic),
73  myInternalLinksFoes(foes), myConts(conts) {}
74 
75 
78  delete myLogic;
79  delete myInternalLinksFoes;
80  }
81 
82 
84  const MSLogicJunction::LinkFoes& getFoesFor(unsigned int linkIndex) const {
85  return (*myLogic)[linkIndex];
86  }
87 
88  const std::bitset<64>& getInternalFoesFor(unsigned int linkIndex) const {
89  return (*myInternalLinksFoes)[linkIndex];
90  }
91 
92  bool getIsCont(unsigned int linkIndex) const {
93  return myConts.test(linkIndex);
94  }
95 
96  virtual bool hasFoes() const {
97  for (typename Logic::const_iterator i = myLogic->begin(); i != myLogic->end(); ++i) {
98  if ((*i).any()) {
99  return true;
100  }
101  }
102  return false;
103  }
104 
105 private:
107  Logic* myLogic;
108 
111 
112  std::bitset<64> myConts;
113 
114 private:
117 
120 
121 };
122 
123 
128 
129 
130 #endif
131 
132 /****************************************************************************/
133 
MSBitSetLogic(unsigned int nLinks, Logic *logic, Foes *foes, std::bitset< 64 > conts)
Use this constructor only.
Definition: MSBitSetLogic.h:68
unsigned int nLinks()
Returns the logic's number of links.
virtual bool hasFoes() const
Definition: MSBitSetLogic.h:96
Logic * myLogic
junctions logic based on std::bitset
bool getIsCont(unsigned int linkIndex) const
Definition: MSBitSetLogic.h:92
~MSBitSetLogic()
Destructor.
Definition: MSBitSetLogic.h:77
MSBitSetLogic & operator=(const MSBitSetLogic &)
Invalidated assignment operator.
std::vector< std::bitset< N > > Foes
Container holding the information which internal lanes prohibt which links Build the same way as Logi...
Definition: MSBitSetLogic.h:63
std::bitset< 64 > myConts
MSBitSetLogic< 64 > MSBitsetLogic
std::bitset< 64 > LinkFoes
Container for link foes.
std::vector< std::bitset< N > > Logic
Container that holds the right of way bitsets. Each link has it's own bitset. The bits in the bitsets...
Definition: MSBitSetLogic.h:59
Foes * myInternalLinksFoes
internal lanes logic
const MSLogicJunction::LinkFoes & getFoesFor(unsigned int linkIndex) const
Returns the foes of the given link.
Definition: MSBitSetLogic.h:84
const std::bitset< 64 > & getInternalFoesFor(unsigned int linkIndex) const
Definition: MSBitSetLogic.h:88