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 /****************************************************************************/
18 // Container for holding a right-of-way matrix
19 /****************************************************************************/
20 #ifndef MSBitSetLogic_h
21 #define MSBitSetLogic_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <bitset>
30 #include <vector>
31 #include "MSJunctionLogic.h"
32 #include "MSLogicJunction.h"
33 
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
43 template< int N >
45 public:
52  typedef std::vector< std::bitset< N > > Logic;
53 
56  typedef std::vector< std::bitset< N > > Foes;
57 
58 
59 public:
62  Logic* logic,
63  Foes* foes,
64  std::bitset<SUMO_MAX_CONNECTIONS> conts)
65  : MSJunctionLogic(nLinks), myLogic(logic),
66  myInternalLinksFoes(foes), myConts(conts) {}
67 
68 
71  delete myLogic;
72  delete myInternalLinksFoes;
73  }
74 
75 
77  const MSLogicJunction::LinkBits& getResponseFor(int linkIndex) const {
78  return (*myLogic)[linkIndex];
79  }
80 
82  const MSLogicJunction::LinkBits& getFoesFor(int linkIndex) const {
83  return (*myInternalLinksFoes)[linkIndex];
84  }
85 
86  bool getIsCont(int linkIndex) const {
87  return myConts.test(linkIndex);
88  }
89 
90  virtual bool hasFoes() const {
91  for (typename Logic::const_iterator i = myLogic->begin(); i != myLogic->end(); ++i) {
92  if ((*i).any()) {
93  return true;
94  }
95  }
96  return false;
97  }
98 
99 private:
101  Logic* myLogic;
102 
105 
106  std::bitset<SUMO_MAX_CONNECTIONS> myConts;
107 
108 private:
111 
114 
115 };
116 
117 
122 
123 
124 #endif
125 
126 /****************************************************************************/
127 
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:61
MSBitSetLogic< SUMO_MAX_CONNECTIONS > MSBitsetLogic
~MSBitSetLogic()
Destructor.
Definition: MSBitSetLogic.h:70
MSBitSetLogic & operator=(const MSBitSetLogic &)
Invalidated assignment operator.
int nLinks()
Returns the logic&#39;s number of links.
virtual bool hasFoes() const
Definition: MSBitSetLogic.h:90
bool getIsCont(int linkIndex) const
Definition: MSBitSetLogic.h:86
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:56
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:52
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:77
const MSLogicJunction::LinkBits & getFoesFor(int linkIndex) const
Returns the foes for the given link.
Definition: MSBitSetLogic.h:82