Skip to content

packages/engine/scram-node/src/expression/test_event.h

Event tree analysis expressions to test functional and initiating events.

Namespaces

Name
scram
scram::mef

Classes

Name
structscram::mef::Context <br>The context for test-event expressions.
classscram::mef::TestEvent <br>The abstract base class for non-deviate test-event expressions.
classscram::mef::TestInitiatingEvent <br>Upon event-tree walk, tests whether an initiating event has occurred.
classscram::mef::TestFunctionalEvent <br>Upon event-tree walk, tests whether a functional event has occurred.

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 <string>
#include <unordered_map>

#include "src/expression.h"

namespace scram::mef {

struct Context {
  std::string initiating_event;  
  std::unordered_map<std::string, std::string> functional_events;
};

class TestEvent : public Expression {
 public:
  explicit TestEvent(const Context* context) : context_(*context) {}

  Interval interval() noexcept override { return Interval::closed(0, 1); }
  bool IsDeviate() noexcept override { return false; }

 protected:
  const Context& context_;  

 private:
  double DoSample() noexcept override { return false; }
};

class TestInitiatingEvent : public TestEvent {
 public:
  TestInitiatingEvent(std::string name, const Context* context)
      : TestEvent(context), name_(std::move(name)) {}

  double value() noexcept override;

 private:
  std::string name_;  
};

class TestFunctionalEvent : public TestEvent {
 public:
  TestFunctionalEvent(std::string name, std::string state,
                      const Context* context)
      : TestEvent(context), name_(std::move(name)), state_(std::move(state)) {}

  double value() noexcept override;

 private:
  std::string name_;  
  std::string state_;  
};

}  // namespace scram::mef

Updated on 2025-11-11 at 16:51:08 +0000