1
/* Copyright (C) 2020 Nikolaj J. Ulrik <nikolaj@njulrik.dk>,
2
* Simon M. Virenfeldt <simon@simwir.dk>
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#ifndef VERIFYPN_PRODUCTSTATE_H
19
#define VERIFYPN_PRODUCTSTATE_H
21
#include "PetriEngine/Structures/State.h"
24
class ProductSuccessorGenerator;
26
namespace LTL::Structures {
28
* State on the form (M, q) for marking M and NBA state q.
29
* Represented as array of size nplaces + 1, where the last element is the number
30
* of NBA state q, and the first nplaces elements are the actual marking.
32
class ProductState : public PetriEngine::Structures::State {
34
ProductState() : PetriEngine::Structures::State() {}
36
void setMarking(PetriEngine::MarkVal* marking, size_t nplaces)
38
State::setMarking(marking);
39
// because zero-indexing
40
buchi_state_idx = nplaces;
43
//TODO override equality operators to handle both marking and NBA state
44
size_t getBuchiState() const {
45
return marking()[buchi_state_idx];
48
void setBuchiState(size_t state) {
49
marking()[buchi_state_idx] = state;
52
[[nodiscard]] bool markingEqual(const PetriEngine::MarkVal *rhs) const {
53
for (size_t i = 0; i < buchi_state_idx; ++i) {
54
if (marking()[i] != rhs[i]) {
61
bool operator==(const ProductState &rhs) const {
62
for (size_t i = 0; i <= buchi_state_idx; ++i) {
63
if (marking()[i] != rhs.marking()[i]) {
70
size_t size() const { return buchi_state_idx + 1; }
72
bool operator!=(const ProductState &rhs) const {
73
return !(rhs == *this);
76
friend class LTL::ProductSuccessorGenerator;
77
size_t buchi_state_idx;
81
#endif //VERIFYPN_PRODUCTSTATE_H