scram::mef::Element
The MEF Element with attributes and a label. More...
#include <element.h>
Inherits from scram::mef::ContainerElement, boost::noncopyable
Inherited by scram::mef::Alignment, scram::mef::Component, scram::mef::EventTree, scram::mef::ExternFunction< void >, scram::mef::ExternLibrary, scram::mef::FunctionalEvent, scram::mef::Id, scram::mef::InitiatingEvent, scram::mef::Model, scram::mef::NamedBranch, scram::mef::Phase, scram::mef::Rule, scram::mef::Sequence, scram::mef::Substitution
Public Types
| Name | |
|---|---|
| using ext::linear_set< Attribute, AttributeKey > | AttributeMap <br>Unique attribute map keyed with the attribute names. |
Public Functions
| Name | |
|---|---|
| Element(std::string name)<br>Constructs an element with an original name. | |
| const std::string & | name() const |
| std::string_view | name_view() const |
| const std::string & | label() const |
| void | label(std::string label)<br>Sets the element label. |
| const AttributeMap & | attributes() const |
| void | AddAttribute(Attribute attr)<br>Adds an attribute to the attribute map of this element. |
| void | SetAttribute(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
| Name | |
|---|---|
| ~Element() =default | |
| void | name(std::string name)<br>Resets the element name. |
Additional inherited members
Protected Functions inherited from scram::mef::ContainerElement
| Name | |
|---|---|
| const Element * | container() const |
Friends inherited from scram::mef::ContainerElement
| Name | |
|---|---|
| class | Container |
Detailed Description
class scram::mef::Element;The MEF Element with attributes and a label.
Note: The class is not polymorphic.
This is a base/mixin class for most of the MEF constructs.
Public Types Documentation
using AttributeMap
using scram::mef::Element::AttributeMap = ext::linear_set<Attribute, AttributeKey>;Unique attribute map keyed with the attribute names.
Note:
- Elements are expected to have very few attributes, complex containers may be overkill.
- Using a multi-index or other tables incurs a huge memory overhead in common usage (up to 400B / attribute).
Public Functions Documentation
function Element
explicit Element(
std::string name
)Constructs an element with an original name.
Parameters:
- name The local identifier name.
Exceptions:
- LogicError The name is required and empty.
- ValidityError The name is malformed.
The name is expected to conform to identifier requirements described in the MEF documentation and additions.
function name
inline const std::string & name() constReturn: The original name.
function name_view
inline std::string_view name_view() constReturn: The string view to the name for table keys.
function label
inline const std::string & label() constReturn:
- The empty or preset label.
- Empty string if the label has not been set.
function label
inline void label(
std::string label
)Sets the element label.
Parameters:
- label The extra description for the element.
function attributes
inline const AttributeMap & attributes() constReturn: The current set of element attributes (non-inherited!).
Note: The element attributes override its inherited attributes. However, the inherited attributes are not copied into the map. The precedence is followed upon lookup.
function AddAttribute
void AddAttribute(
Attribute attr
)Adds an attribute to the attribute map of this element.
Parameters:
- attr An attribute of this element.
Exceptions:
- ValidityError The attribute is duplicate.
Warning: Pointers or references to existing attributes may get invalidated.
function SetAttribute
void SetAttribute(
Attribute attr
)Sets an attribute to the attribute map.
Parameters:
- attr An attribute of this element.
Warning: Pointers or references to existing attributes may get invalidated.
If an attribute with the same name exits, it gets overwritten.
function GetAttribute
const Attribute * GetAttribute(
std::string_view name
) constParameters:
- name The name of the attribute.
Return: The attribute with the given name. nullptr if no attribute is found.
Note: Attributes can be inherited from parent containers.
Warning: Attribute addresses are not stable. Do not store the returned pointer.
function RemoveAttribute
std::optional< Attribute > RemoveAttribute(
std::string_view name
)Removes an attribute of this element.
Parameters:
- name The identifying name of the attribute.
Return: The removed attribute if any.
Postcondition: No inherited attributes are affected.
Protected Functions Documentation
function ~Element
~Element() =defaultfunction name
void name(
std::string name
)Resets the element name.
Parameters:
- name The local identifier name.
Exceptions:
- LogicError The name is required and empty.
- ValidityError The name is malformed.
Updated on 2025-11-11 at 16:51:08 +0000
