packages/engine/scram-node/src/parameter.h
Parameter expressions that act like a shareable variable.
Namespaces
| Name |
|---|
| scram |
| scram::mef |
Classes
| Name | |
|---|---|
| class | scram::mef::MissionTime <br>The special parameter for system mission time. |
| class | scram::mef::Parameter <br>This class provides a representation of a variable in basic event description. |
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 <cstdint>
#include "element.h"
#include "expression.h"
namespace scram::mef {
enum Units : std::uint8_t {
kUnitless = 0,
kBool,
kInt,
kFloat,
kHours,
kInverseHours,
kYears,
kInverseYears,
kFit,
kDemands
};
const int kNumUnits = 10;
const char* const kUnitsToString[] = {"unitless", "bool", "int", "float",
"hours", "hours-1", "years", "years-1",
"fit", "demands"};
class MissionTime : public Expression {
public:
explicit MissionTime(double time = 0, Units unit = kHours);
Units unit() const { return unit_; }
void value(double time);
double value() noexcept override { return value_; }
Interval interval() noexcept override { return Interval::closed(0, value_); }
bool IsDeviate() noexcept override { return false; }
private:
double DoSample() noexcept override { return value_; }
Units unit_;
double value_;
};
class Parameter : public Expression, public Id, public NodeMark, public Usage {
public:
static constexpr const char* kTypeString = "parameter";
using Id::Id;
void expression(Expression* expression);
Units unit() const { return unit_; }
void unit(Units unit) { unit_ = unit; }
double value() noexcept override { return expression_->value(); }
Interval interval() noexcept override { return expression_->interval(); }
private:
double DoSample() noexcept override { return expression_->Sample(); }
Units unit_ = kUnitless;
Expression* expression_ = nullptr;
};
} // namespace scram::mefUpdated on 2025-11-11 at 16:51:08 +0000
