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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // Container for holding a right-of-way matrix
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <bitset>
27 #include <vector>
28 #include "MSJunctionLogic.h"
29 #include "MSLogicJunction.h"
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
40 template< int N >
42 public:
49  typedef std::vector< std::bitset< N > > Logic;
50 
53  typedef std::vector< std::bitset< N > > Foes;
54 
55 
56 public:
59  Logic* logic,
60  Foes* foes,
61  std::bitset<SUMO_MAX_CONNECTIONS> conts)
62  : MSJunctionLogic(nLinks), myLogic(logic),
63  myInternalLinksFoes(foes), myConts(conts) {}
64 
65 
68  delete myLogic;
69  delete myInternalLinksFoes;
70  }
71 
72 
74  const MSLogicJunction::LinkBits& getResponseFor(int linkIndex) const {
75  return (*myLogic)[linkIndex];
76  }
77 
79  const MSLogicJunction::LinkBits& getFoesFor(int linkIndex) const {
80  return (*myInternalLinksFoes)[linkIndex];
81  }
82 
83  bool getIsCont(int linkIndex) const {
84  return myConts.test(linkIndex);
85  }
86 
87  virtual bool hasFoes() const {
88  for (typename Logic::const_iterator i = myLogic->begin(); i != myLogic->end(); ++i) {
89  if ((*i).any()) {
90  return true;
91  }
92  }
93  return false;
94  }
95 
96 private:
99 
102 
103  std::bitset<SUMO_MAX_CONNECTIONS> myConts;
104 
105 private:
108 
111 
112 };
113 
114 
MSBitSetLogic< SUMO_MAX_CONNECTIONS > MSBitsetLogic
MSBitSetLogic & operator=(const MSBitSetLogic &)
Invalidated assignment operator.
const MSLogicJunction::LinkBits & getResponseFor(int linkIndex) const
Returns the response for the given link.
Definition: MSBitSetLogic.h:74
Logic * myLogic
junctions logic based on std::bitset
Definition: MSBitSetLogic.h:98
virtual bool hasFoes() const
Definition: MSBitSetLogic.h:87
const MSLogicJunction::LinkBits & getFoesFor(int linkIndex) const
Returns the foes for the given link.
Definition: MSBitSetLogic.h:79
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:53
Foes * myInternalLinksFoes
internal lanes logic
MSBitSetLogic(const MSBitSetLogic &)
Invalidated copy constructor.
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:49
MSBitSetLogic(int nLinks, Logic *logic, Foes *foes, std::bitset< SUMO_MAX_CONNECTIONS > conts)
Use this constructor only.
Definition: MSBitSetLogic.h:58
std::bitset< SUMO_MAX_CONNECTIONS > myConts
~MSBitSetLogic()
Destructor.
Definition: MSBitSetLogic.h:67
bool getIsCont(int linkIndex) const
Definition: MSBitSetLogic.h:83
int nLinks()
Returns the logic's number of links.
std::bitset< SUMO_MAX_CONNECTIONS > LinkBits
Container for link response and foes.