Skip to content

scram::mef::Model

This class represents a risk analysis model.

#include <model.h>

Inherits from scram::mef::Element, scram::mef::Composite< Model, InitiatingEvent, EventTree, Sequence, Rule, Alignment, Substitution, FaultTree, BasicEvent, Gate, HouseEvent, Parameter, CcfGroup, ExternLibrary, ExternFunction< void > >, scram::mef::ContainerElement, boost::noncopyable

Public Functions

Name
const MissionTime &mission_time() const
MissionTime &mission_time()
autoinitiating_events() const
autoevent_trees() const
autosequences() const
autorules() const
autofault_trees() const
autoalignments() const
autosubstitutions() const
autoparameters() const
autohouse_events() const
autobasic_events() const
autogates() const
autoccf_groups() const
autolibraries() const
autoextern_functions() const
voidAdd(std::unique_ptr< HouseEvent > element)<br>Adds MEF constructs into the model container.
voidAdd(std::unique_ptr< BasicEvent > element)
voidAdd(std::unique_ptr< Gate > element)
voidAdd(std::unique_ptr< Expression > element)
voidAdd(std::unique_ptr< Instruction > element)
Model(std::string name ="")<br>Creates a model container.
boolHasDefaultName() const
const std::string &GetOptionalName() const
voidSetOptionalName(std::string name ="")<br>Sets the optional name of the model.
Context *context() const
Formula::ArgEventGetEvent(std::string_view id)<br>Convenience function to retrieve an event with its ID.

Public Attributes

Name
constexpr const char *kTypeString <br>Container type identifier string for error messages.
constexpr const char[]kDefaultName <br>Only Model is allowed to have an optional name, while all other Elements require names.

Additional inherited members

Public Types inherited from scram::mef::Element

Name
using ext::linear_set< Attribute, AttributeKey >AttributeMap <br>Unique attribute map keyed with the attribute names.

Public Functions inherited from scram::mef::Element

Name
Element(std::string name)<br>Constructs an element with an original name.
const std::string &name() const
std::string_viewname_view() const
const std::string &label() const
voidlabel(std::string label)<br>Sets the element label.
const AttributeMap &attributes() const
voidAddAttribute(Attribute attr)<br>Adds an attribute to the attribute map of this element.
voidSetAttribute(Attribute attr)<br>Sets an attribute to the attribute map.
const Attribute *GetAttribute(std::string_view name) const
std::optional< Attribute >RemoveAttribute(std::string_view name)<br>Removes an attribute of this element.

Protected Functions inherited from scram::mef::Element

Name
~Element() =default
voidname(std::string name)<br>Resets the element name.

Public Functions inherited from scram::mef::Composite< Model, InitiatingEvent, EventTree, Sequence, Rule, Alignment, Substitution, FaultTree, BasicEvent, Gate, HouseEvent, Parameter, CcfGroup, ExternLibrary, ExternFunction< void > >

Name
template <class T > <br>autotable() const
template <class T > <br>autotable()
template <class T ,class ContainerType =typename detail::container_of<T, Ts...>::type> <br>const T &Get(const typename ContainerType::key_type & id) const<br>Retrieves an element from the container.
template <class T ,class ContainerType =typename detail::container_of<T, Ts...>::type> <br>T &Get(const typename ContainerType::key_type & id)

Protected Functions inherited from scram::mef::Composite< Model, InitiatingEvent, EventTree, Sequence, Rule, Alignment, Substitution, FaultTree, BasicEvent, Gate, HouseEvent, Parameter, CcfGroup, ExternLibrary, ExternFunction< void > >

Name
template <class T > <br>decltype(auto)data() const

Protected Functions inherited from scram::mef::ContainerElement

Name
const Element *container() const

Friends inherited from scram::mef::ContainerElement

Name
classContainer

Public Functions Documentation

function mission_time

cpp
inline const MissionTime & mission_time() const

Return: The mission time expression for the whole model.

function mission_time

cpp
inline MissionTime & mission_time()

function initiating_events

cpp
inline auto initiating_events() const

Return: Table ranges of the elements in the model.

function event_trees

cpp
inline auto event_trees() const

function sequences

cpp
inline auto sequences() const

function rules

cpp
inline auto rules() const

function fault_trees

cpp
inline auto fault_trees() const

function alignments

cpp
inline auto alignments() const

function substitutions

cpp
inline auto substitutions() const

function parameters

cpp
inline auto parameters() const

function house_events

cpp
inline auto house_events() const

function basic_events

cpp
inline auto basic_events() const

function gates

cpp
inline auto gates() const

function ccf_groups

cpp
inline auto ccf_groups() const

function libraries

cpp
inline auto libraries() const

function extern_functions

cpp
inline auto extern_functions() const

function Add

cpp
inline void Add(
    std::unique_ptr< HouseEvent > element
)

Adds MEF constructs into the model container.

Parameters:

  • element An element defined in this model.

Exceptions:

function Add

cpp
inline void Add(
    std::unique_ptr< BasicEvent > element
)

function Add

cpp
inline void Add(
    std::unique_ptr< Gate > element
)

function Add

cpp
inline void Add(
    std::unique_ptr< Expression > element
)

function Add

cpp
inline void Add(
    std::unique_ptr< Instruction > element
)

function Model

cpp
explicit Model(
    std::string name =""
)

Creates a model container.

Parameters:

  • name The optional name for the model.

Exceptions:

function HasDefaultName

cpp
inline bool HasDefaultName() const

Return: true if the model name has not been set.

function GetOptionalName

cpp
inline const std::string & GetOptionalName() const

Return: The model name or an empty string for the optional name.

function SetOptionalName

cpp
inline void SetOptionalName(
    std::string name =""
)

Sets the optional name of the model.

function context

cpp
inline Context * context() const

Return: The context to be used by test-event expressions for event-tree walks.

Note: There's only single context for the whole model (i.e., global); two event-trees cannot be walked concurrently.

function GetEvent

cpp
Formula::ArgEvent GetEvent(
    std::string_view id
)

Convenience function to retrieve an event with its ID.

Parameters:

  • id The valid ID string of the event.

Exceptions:

Return: The event with its type encoded in variant suitable for formulas.

Public Attributes Documentation

variable kTypeString

cpp
static constexpr const char * kTypeString = "model";

Container type identifier string for error messages.

variable kDefaultName

cpp
static constexpr const char[] kDefaultName = "__unnamed-model__";

Only Model is allowed to have an optional name, while all other Elements require names.

An empty name is an error for Element class invariants as well. This leads to a nasty magic string based optional name for a model.


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