packages/engine/scram-node/src/substitution.h
The MEF Substitution constructs.
Namespaces
| Name |
|---|
| scram |
| scram::mef |
Classes
| Name | |
|---|---|
| class | scram::mef::Substitution <br>The general representation for Delete Terms, Recovery Rules, and Exchange Events. |
Source code
cpp
/*
* Copyright (C) 2014-2018 Olzhas Rakhimov
* Copyright (C) 2023 OpenPRA ORG Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <memory>
#include <optional>
#include <variant>
#include <vector>
#include "element.h"
#include "event.h"
namespace scram::mef {
class Substitution : public Element {
public:
static constexpr const char* kTypeString = "substitution";
using Target = std::variant<BasicEvent*, bool>;
enum Type { kDeleteTerms, kRecoveryRule, kExchangeEvent };
using Element::Element;
const Formula& hypothesis() const {
assert(hypothesis_ && "Substitution hypothesis is not set.");
return *hypothesis_;
}
void hypothesis(std::unique_ptr<Formula> formula) {
assert(formula && "Cannot unset the hypothesis of substitution.");
hypothesis_ = std::move(formula);
}
const Target& target() const { return target_; }
void target(Target target_event) { target_ = std::move(target_event); }
const std::vector<BasicEvent*>& source() const { return source_; }
bool declarative() const { return source_.empty(); }
void Add(BasicEvent* source_event);
void Validate() const;
std::optional<Type> type() const;
private:
std::unique_ptr<Formula> hypothesis_;
std::vector<BasicEvent*> source_;
Target target_;
};
const char* const kSubstitutionTypeToString[] = {
"delete-terms", "recovery-rule", "exchange-event"};
} // namespace scram::mefUpdated on 2025-11-11 at 16:51:09 +0000
