11 std::list<size_t>::const_iterator
const& iterDependency, std::list<size_t>::const_iterator nonConflictEnd,
12 std::list<size_t>::const_iterator conflictBegin)
13 : dependency(dependency), conflicting(conflicting), itBE(iterBE), itDep(iterDependency), nonConflictEnd(nonConflictEnd), conflictBegin(conflictBegin) {
14 STORM_LOG_ASSERT(conflicting || itDep != nonConflictEnd,
"No non-conflicting dependencies present.");
20 if (!conflicting && itDep == nonConflictEnd) {
23 itDep = conflictBegin;
40 if (dependency != other.dependency) {
44 if (conflicting != other.conflicting) {
47 return itDep != other.itDep;
50 return itBE != other.itBE;
55 return !(*
this != other);
66template<
typename ValueType>
69 size_t nextFailId = **
this;
70 STORM_LOG_ASSERT(!isFailureDueToDependency(),
"The current iterator is not a BE failure but a dependency failure.");
74template<
typename ValueType>
77 size_t nextFailId = **
this;
78 STORM_LOG_ASSERT(isFailureDueToDependency(),
"The current iterator is not a dependency failure but a BE failure.");
83 currentlyFailableBE.
set(
id);
87 std::list<size_t>& failableList = (isConflicting ? failableConflictingDependencies : failableNonconflictingDependencies);
88 for (
auto it = failableList.begin(); it != failableList.end(); ++it) {
90 failableList.insert(it,
id);
92 }
else if (*it ==
id) {
97 failableList.push_back(
id);
101 currentlyFailableBE.
set(
id,
false);
105 auto iter = std::find(failableConflictingDependencies.begin(), failableConflictingDependencies.end(),
id);
106 if (iter != failableConflictingDependencies.end()) {
107 failableConflictingDependencies.erase(iter);
110 iter = std::find(failableNonconflictingDependencies.begin(), failableNonconflictingDependencies.end(),
id);
111 if (iter != failableNonconflictingDependencies.end()) {
112 failableNonconflictingDependencies.erase(iter);
118 currentlyFailableBE.
clear();
119 failableConflictingDependencies.clear();
120 failableNonconflictingDependencies.clear();
125 bool conflicting = failableNonconflictingDependencies.empty();
126 auto itDep = conflicting ? failableConflictingDependencies.begin() : failableNonconflictingDependencies.begin();
128 failableConflictingDependencies.begin());
134 failableNonconflictingDependencies.end(), failableConflictingDependencies.begin());
138 return !failableConflictingDependencies.empty() || !failableNonconflictingDependencies.empty();
142 return !currentlyFailableBE.
empty();
146 std::stringstream stream;
149 stream <<
"Dependencies: ";
151 for (
auto it =
begin(forceBE); it !=
end(forceBE); ++it) {
152 stream << *it <<
", ";
Represents a Dynamic Fault Tree.
std::shared_ptr< storm::dft::storage::elements::DFTDependency< ValueType > const > getDependency(size_t index) const
std::shared_ptr< storm::dft::storage::elements::DFTBE< ValueType > const > getBasicElement(size_t index) const
Iterator for failable elements.
uint_fast64_t operator*() const
Returns the id of the current failable element.
std::shared_ptr< storm::dft::storage::elements::DFTBE< ValueType > const > asBE(storm::dft::storage::DFT< ValueType > const &dft) const
Return the current iterator as a BE which fails next.
const_iterator & operator++()
Increment the iterator.
bool operator==(const_iterator const &other) const
Compares the iterator with another iterator for equality.
bool isConflictingDependency() const
Return whether the current dependency failure is conflicting.
bool isFailureDueToDependency() const
Return whether the current failure is due to a dependency (or the BE itself).
const_iterator(bool dependency, bool conflicting, storm::storage::BitVector::const_iterator const &iterBE, std::list< size_t >::const_iterator const &iterDependency, std::list< size_t >::const_iterator nonConflictEnd, std::list< size_t >::const_iterator conflictBegin)
Construct a new iterator.
std::shared_ptr< storm::dft::storage::elements::DFTDependency< ValueType > const > asDependency(storm::dft::storage::DFT< ValueType > const &dft) const
Return the current iterator as a dependency which triggers next.
bool operator!=(const_iterator const &other) const
Compares the iterator with another iterator for inequality.
void removeBE(size_t id)
Remove BE from list of failable elements.
void removeDependency(size_t id)
Remove dependency from list of failable elements.
bool hasDependencies() const
Whether failable dependencies are present.
FailableElements::const_iterator end(bool forceBE=false) const
Iterator after last failable element.
std::string getCurrentlyFailableString(bool forceBE=false) const
Get a string representation of the currently failable elements.
void addBE(size_t id)
Add failable BE.
void addDependency(size_t id, bool isConflicting)
Add failable dependency.
void clear()
Clear list of currently failable elements.
FailableElements::const_iterator begin(bool forceBE=false) const
Iterator to first failable element.
bool hasBEs() const
Whether failable BEs are present.
A class that enables iterating over the indices of the bit vector whose corresponding bits are set to...
const_iterator end() const
Returns an iterator pointing at the element past the back of the bit vector.
bool empty() const
Retrieves whether no bits are set to true in this bit vector.
void clear()
Removes all set bits from the bit vector.
const_iterator begin() const
Returns an iterator to the indices of the set bits in the bit vector.
void set(uint_fast64_t index, bool value=true)
Sets the given truth value at the given index.
#define STORM_LOG_ASSERT(cond, message)