12template<
typename ValueType>
14 using DFTElementPointer = std::shared_ptr<DFTElement<ValueType>>;
15 using DFTElementVector = std::vector<DFTElementPointer>;
38 mChildren.push_back(element);
50 return mChildren.size();
59 auto it = std::find_if(this->mChildren.begin(), this->mChildren.end(), [&
id](DFTElementPointer element) ->
bool { return element->id() == id; });
60 return it != this->mChildren.end();
64 std::set<size_t> unit = {this->
mId};
65 for (
auto const& child : mChildren) {
66 child->extendUnit(unit);
68 return std::vector<size_t>(unit.begin(), unit.end());
71 virtual void extendUnit(std::set<size_t>& unit)
const override {
73 for (
auto const& child : mChildren) {
74 child->extendUnit(unit);
78 virtual std::vector<size_t>
independentSubDft(
bool blockParents,
bool sparesAsLeaves =
false)
const override {
80 if (prelRes.empty()) {
84 std::set<size_t> unit(prelRes.begin(), prelRes.end());
85 std::vector<size_t> pids = this->
parentIds();
86 for (
auto const& child : mChildren) {
87 child->extendSubDft(unit, pids, blockParents, sparesAsLeaves);
93 return std::vector<size_t>(unit.begin(), unit.end());
96 virtual void extendSubDft(std::set<size_t>& elemsInSubtree, std::vector<size_t>
const& parentsOfSubRoot,
bool blockParents,
97 bool sparesAsLeaves)
const override {
98 if (elemsInSubtree.count(this->id()) > 0)
101 if (elemsInSubtree.empty()) {
105 for (
auto const& child : mChildren) {
106 child->extendSubDft(elemsInSubtree, parentsOfSubRoot, blockParents, sparesAsLeaves);
107 if (elemsInSubtree.empty()) {
130 std::stringstream stream;
131 stream <<
"{" << this->
name() <<
"} " << this->
typestring() <<
"(";
132 typename DFTElementVector::const_iterator it = mChildren.begin();
133 stream << (*it)->name();
135 while (it != mChildren.end()) {
136 stream <<
", " << (*it)->name();
150 for (
auto const& child : mChildren) {
164 for (
auto const& child : mChildren) {
177 DFTElementVector mChildren;
bool hasFailed(size_t id) const
bool isFailsafe(size_t id) const
Abstract base class for a DFT element with children.
virtual void extendUnit(std::set< size_t > &unit) const override
Helper to independent unit computation.
bool hasFailsafeChild(storm::dft::storage::DFTState< ValueType > &state) const
Check whether it has a failsafe child.
virtual ~DFTChildren()=default
Destructor.
DFTElementVector const & children() const
Get children.
virtual std::string toString() const override
Print information about element to string.
size_t nrChildren() const override
Get number of children.
virtual void extendSubDft(std::set< size_t > &elemsInSubtree, std::vector< size_t > const &parentsOfSubRoot, bool blockParents, bool sparesAsLeaves) const override
Helper to the independent subtree computation.
bool hasFailedChild(storm::dft::storage::DFTState< ValueType > &state) const
Check whether it has a failed child.
virtual std::vector< size_t > independentSubDft(bool blockParents, bool sparesAsLeaves=false) const override
Computes independent subtrees starting with this element (this), that is, all elements (x) which are ...
DFTChildren(size_t id, std::string const &name, DFTElementVector const &children)
Constructor.
void addChild(DFTElementPointer element)
Add child.
virtual void checkFailsafe(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const =0
Check failsafe status.
virtual void fail(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const =0
virtual void checkFails(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const =0
Check failed status.
bool containsChild(size_t id)
Check whether the given element is contained in the list of children.
virtual void failsafe(storm::dft::storage::DFTState< ValueType > &state, storm::dft::storage::DFTStateSpaceGenerationQueues< ValueType > &queues) const =0
virtual std::vector< size_t > independentUnit() const override
Computes the independent unit of this element, that is, all elements which are direct or indirect suc...
Abstract base class for DFT elements.
virtual size_t id() const
Get id.
virtual void extendUnit(std::set< size_t > &unit) const
Helper to independent unit computation.
virtual std::string typestring() const
Get type as string.
virtual std::string const & name() const
Get name.
std::vector< size_t > parentIds() const
Return Ids of parents.
virtual void extendSubDft(std::set< size_t > &elemsInSubtree, std::vector< size_t > const &parentsOfSubRoot, bool blockParents, bool sparesAsLeaves) const
Helper to the independent subtree computation.
virtual std::vector< size_t > independentSubDft(bool blockParents, bool sparesAsLeaves=false) const
Computes independent subtrees starting with this element (this), that is, all elements (x) which are ...