SUMO - Simulation of Urban MObility
MSBitSetLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // Container for holding a right-of-way matrix
21 /****************************************************************************/
22 #ifndef MSBitSetLogic_h
23 #define MSBitSetLogic_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <bitset>
36 #include <vector>
37 #include "MSJunctionLogic.h"
38 #include "MSLogicJunction.h"
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
49 template< int N >
51 public:
58  typedef std::vector< std::bitset< N > > Logic;
59 
62  typedef std::vector< std::bitset< N > > Foes;
63 
64 
65 public:
68  Logic* logic,
69  Foes* foes,
70  std::bitset<SUMO_MAX_CONNECTIONS> conts)
71  : MSJunctionLogic(nLinks), myLogic(logic),
72  myInternalLinksFoes(foes), myConts(conts) {}
73 
74 
77  delete myLogic;
78  delete myInternalLinksFoes;
79  }
80 
81 
83  const MSLogicJunction::LinkBits& getResponseFor(int linkIndex) const {
84  return (*myLogic)[linkIndex];
85  }
86 
88  const MSLogicJunction::LinkBits& getFoesFor(int linkIndex) const {
89  return (*myInternalLinksFoes)[linkIndex];
90  }
91 
92  bool getIsCont(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<SUMO_MAX_CONNECTIONS> myConts;
113 
114 private:
117 
120 
121 };
122 
123 
128 
129 
130 #endif
131 
132 /****************************************************************************/
133 
Logic * myLogic
junctions logic based on std::bitset
MSBitSetLogic(int nLinks, Logic *logic, Foes *foes, std::bitset< SUMO_MAX_CONNECTIONS > conts)
Use this constructor only.
Definition: MSBitSetLogic.h:67
MSBitSetLogic< SUMO_MAX_CONNECTIONS > MSBitsetLogic
~MSBitSetLogic()
Destructor.
Definition: MSBitSetLogic.h:76
MSBitSetLogic & operator=(const MSBitSetLogic &)
Invalidated assignment operator.
int nLinks()
Returns the logic&#39;s number of links.
virtual bool hasFoes() const
Definition: MSBitSetLogic.h:96
bool getIsCont(int linkIndex) const
Definition: MSBitSetLogic.h:92
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:62
std::bitset< SUMO_MAX_CONNECTIONS > myConts
std::vector< std::bitset< N > > Logic
Container that holds the right of way bitsets. Each link has it&#39;s own bitset. The bits in the bitsets...
Definition: MSBitSetLogic.h:58
Foes * myInternalLinksFoes
internal lanes logic
std::bitset< SUMO_MAX_CONNECTIONS > LinkBits
Container for link response and foes.
const MSLogicJunction::LinkBits & getResponseFor(int linkIndex) const
Returns the response for the given link.
Definition: MSBitSetLogic.h:83
const MSLogicJunction::LinkBits & getFoesFor(int linkIndex) const
Returns the foes for the given link.
Definition: MSBitSetLogic.h:88