Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSBitSetLogic.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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// ===========================================================================
40template< int N >
42public:
49 typedef std::vector< std::bitset< N > > Logic;
50
53 typedef std::vector< std::bitset< N > > Foes;
54
55
56public:
58 MSBitSetLogic(int nLinks, const Logic& logic, const Foes& foes,
59 std::bitset<SUMO_MAX_CONNECTIONS> conts)
60 : MSJunctionLogic(nLinks), myLogic(logic),
61 myInternalLinksFoes(foes), myConts(conts) {}
62
64 const MSLogicJunction::LinkBits& getResponseFor(int linkIndex) const {
65 return myLogic[linkIndex];
66 }
67
69 const MSLogicJunction::LinkBits& getFoesFor(int linkIndex) const {
70 return myInternalLinksFoes[linkIndex];
71 }
72
73 bool getIsCont(int linkIndex) const {
74 return myConts.test(linkIndex);
75 }
76
77 bool hasFoes() const {
78 for (const auto& i : myLogic) {
79 if (i.any()) {
80 return true;
81 }
82 }
83 return false;
84 }
85
86private:
89
92
93 const std::bitset<SUMO_MAX_CONNECTIONS> myConts;
94
95private:
97 MSBitSetLogic(const MSBitSetLogic&) = delete;
98
101
102};
103
104
MSBitSetLogic< SUMO_MAX_CONNECTIONS > MSBitsetLogic
MSBitSetLogic(const MSBitSetLogic &)=delete
Invalidated copy constructor.
bool hasFoes() const
const Logic myLogic
junctions logic based on std::bitset
const MSLogicJunction::LinkBits & getFoesFor(int linkIndex) const
Returns the foes for the given link.
MSBitSetLogic & operator=(const MSBitSetLogic &)=delete
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...
std::vector< std::bitset< N > > Logic
Container that holds the right of way bitsets. Each link has its own bitset. The bits in the bitsets ...
const MSLogicJunction::LinkBits & getResponseFor(int linkIndex) const
Returns the response for the given link.
const Foes myInternalLinksFoes
internal lanes logic
const std::bitset< SUMO_MAX_CONNECTIONS > myConts
bool getIsCont(int linkIndex) const
MSBitSetLogic(int nLinks, const Logic &logic, const Foes &foes, std::bitset< SUMO_MAX_CONNECTIONS > conts)
Use this constructor only.
std::bitset< SUMO_MAX_CONNECTIONS > LinkBits
Container for link response and foes.