Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Container for holding a right-of-way matrix
18 /****************************************************************************/
19 #ifndef MSBitSetLogic_h
20 #define MSBitSetLogic_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <bitset>
29 #include <vector>
30 #include "MSJunctionLogic.h"
31 #include "MSLogicJunction.h"
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
42 template< int N >
44 public:
51  typedef std::vector< std::bitset< N > > Logic;
52 
55  typedef std::vector< std::bitset< N > > Foes;
56 
57 
58 public:
61  Logic* logic,
62  Foes* foes,
63  std::bitset<SUMO_MAX_CONNECTIONS> conts)
64  : MSJunctionLogic(nLinks), myLogic(logic),
65  myInternalLinksFoes(foes), myConts(conts) {}
66 
67 
70  delete myLogic;
71  delete myInternalLinksFoes;
72  }
73 
74 
76  const MSLogicJunction::LinkBits& getResponseFor(int linkIndex) const {
77  return (*myLogic)[linkIndex];
78  }
79 
81  const MSLogicJunction::LinkBits& getFoesFor(int linkIndex) const {
82  return (*myInternalLinksFoes)[linkIndex];
83  }
84 
85  bool getIsCont(int linkIndex) const {
86  return myConts.test(linkIndex);
87  }
88 
89  virtual bool hasFoes() const {
90  for (typename Logic::const_iterator i = myLogic->begin(); i != myLogic->end(); ++i) {
91  if ((*i).any()) {
92  return true;
93  }
94  }
95  return false;
96  }
97 
98 private:
101 
104 
105  std::bitset<SUMO_MAX_CONNECTIONS> myConts;
106 
107 private:
110 
113 
114 };
115 
116 
121 
122 
123 #endif
124 
125 /****************************************************************************/
126 
MSBitSetLogic::operator=
MSBitSetLogic & operator=(const MSBitSetLogic &)
Invalidated assignment operator.
MSJunctionLogic.h
MSBitSetLogic
Definition: MSBitSetLogic.h:43
MSBitSetLogic::Foes
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:55
MSBitSetLogic::~MSBitSetLogic
~MSBitSetLogic()
Destructor.
Definition: MSBitSetLogic.h:69
MSJunctionLogic
Definition: MSJunctionLogic.h:38
MSBitSetLogic::Logic
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:51
MSBitSetLogic::MSBitSetLogic
MSBitSetLogic(int nLinks, Logic *logic, Foes *foes, std::bitset< SUMO_MAX_CONNECTIONS > conts)
Use this constructor only.
Definition: MSBitSetLogic.h:60
MSJunctionLogic::nLinks
int nLinks()
Returns the logic's number of links.
Definition: MSJunctionLogic.cpp:38
MSBitsetLogic
MSBitSetLogic< SUMO_MAX_CONNECTIONS > MSBitsetLogic
Definition: MSBitSetLogic.h:120
MSBitSetLogic::myInternalLinksFoes
Foes * myInternalLinksFoes
internal lanes logic
Definition: MSBitSetLogic.h:103
MSBitSetLogic::getResponseFor
const MSLogicJunction::LinkBits & getResponseFor(int linkIndex) const
Returns the response for the given link.
Definition: MSBitSetLogic.h:76
config.h
MSLogicJunction.h
MSBitSetLogic::myConts
std::bitset< SUMO_MAX_CONNECTIONS > myConts
Definition: MSBitSetLogic.h:105
MSBitSetLogic::getIsCont
bool getIsCont(int linkIndex) const
Definition: MSBitSetLogic.h:85
MSLogicJunction::LinkBits
std::bitset< SUMO_MAX_CONNECTIONS > LinkBits
Container for link response and foes.
Definition: MSLogicJunction.h:58
MSBitSetLogic::hasFoes
virtual bool hasFoes() const
Definition: MSBitSetLogic.h:89
MSBitSetLogic::getFoesFor
const MSLogicJunction::LinkBits & getFoesFor(int linkIndex) const
Returns the foes for the given link.
Definition: MSBitSetLogic.h:81
MSBitSetLogic::myLogic
Logic * myLogic
junctions logic based on std::bitset
Definition: MSBitSetLogic.h:100