AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::sina::Relationship Class Reference

An object used to correlate 2 Records. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/sina/core/Relationship.hpp>

Public Member Functions

 Relationship (ID subject, std::string predicate, ID object)
 Create a new relationship. More...
 
 Relationship (conduit::Node const &asNode)
 Create a Relationship object from its representation as a conduit Node. More...
 
ID const & getSubject () const noexcept
 Get the subject. More...
 
ID const & getObject () const noexcept
 Get the object. More...
 
std::string const & getPredicate () const noexcept
 Get the predicate. More...
 
conduit::Node toNode () const
 Convert this Relationship to its Node representation. More...
 

Detailed Description

An object used to correlate 2 Records.

A Relationship consists of three parts: a subject, an object, and a predicate. It describes a relationship between two Records (and/or Record inheritors, e.g. Run). The subject and object must be IDs referring to valid records, while the predicate may be any string.

In describing the connection between objects, a Relationship is read as "<subject> <predicate> <object>". For example, in the relationship "Alice knows Bob", "Alice" is the subject, "knows" is the predicate, and "Bob" is the object. For further examples:

  • Task_22 contains Run_1024
  • msub_1_1 describes out_j_1_1
  • Carlos sends an email to Dani
  • local_task_12 runs before local_run_14

Note that Relationships are described in the active voice. Avoiding the passive voice in predicates is recommended, as this keeps the "direction" of the relationship constant. An example of a passively-voiced Relationship is "Dani is emailed by Carlos". Instead, this should be phrased as "Carlos emails Dani".

If assembling Relationships programatically, it may be useful to reference the ID documentation.

axom::sina::Relationship myRelationship{task22, "contains", run1024};
std::cout << myRelationship.toNode().to_json() << std::endl;
The ID of a Record.
Definition: ID.hpp:50
An object used to correlate 2 Records.
Definition: Relationship.hpp:85
conduit::Node toNode() const
Convert this Relationship to its Node representation.

This would output:

{"object":"Run_1024","predicate":"contains","subject":"Task_22"}

As with any other Sina ID, the subject or object may be either local (uniquely refer to one object in a Sina file) or global (uniquely refer to one object in a database). Local IDs are replaced with global ones upon ingestion; all Relationships referring to that Local ID (as well as the Record possessing that ID) will be updated to use the same global ID.

axom::sina::ID myLocalID{"my_local_run", axom::sina::IDType::Local};
std::unique_ptr<axom::sina::Record> myRun{new axom::sina::Run{myLocalID, "My Sim Code", "1.2.3", "jdoe"}};
axom::sina::Relationship myRelationship{task22, "contains", myLocalID};
A sub-type of Record representing a single run of an applicaiton.
Definition: Run.hpp:48

In the above code, "my_local_run" would be replaced by a global ID on ingestion. If this new global ID was, for example, "5Aed-BCds-23G1", then "my_local_run" would automatically be replaced by "5Aed-BCds-23G1" in both the Record and Relationship entries.

Constructor & Destructor Documentation

◆ Relationship() [1/2]

axom::sina::Relationship::Relationship ( ID  subject,
std::string  predicate,
ID  object 
)

Create a new relationship.

Parameters
subjectthe subject of the relationship
predicatethe predicate describing the relationship from the subject to the object
objectthe object of the relationship

◆ Relationship() [2/2]

axom::sina::Relationship::Relationship ( conduit::Node const &  asNode)
explicit

Create a Relationship object from its representation as a conduit Node.

Parameters
asNodethe relationship as a Node

Member Function Documentation

◆ getSubject()

ID const& axom::sina::Relationship::getSubject ( ) const
inlinenoexcept

Get the subject.

Returns
the subject

References axom::sina::internal::IDField::getID().

◆ getObject()

ID const& axom::sina::Relationship::getObject ( ) const
inlinenoexcept

Get the object.

Returns
the object

◆ getPredicate()

std::string const& axom::sina::Relationship::getPredicate ( ) const
inlinenoexcept

Get the predicate.

Returns
the predicate

◆ toNode()

conduit::Node axom::sina::Relationship::toNode ( ) const

Convert this Relationship to its Node representation.

Returns
this relationship as a conduit Node

The documentation for this class was generated from the following file: