|
AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
An object representing the top-level object of a Sina file. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/sina/core/Document.hpp>
Public Types | |
| using | RecordList = std::vector< std::unique_ptr< Record > > |
| using | RelationshipList = std::vector< Relationship > |
Public Member Functions | |
| Document ()=default | |
| Document (Document const &)=delete | |
| Document & | operator= (Document const &)=delete |
| Document (Document &&)=default | |
| Document & | operator= (Document &&)=default |
| Document (conduit::Node const &asNode, RecordLoader const &recordLoader) | |
| Create a Document from its Conduit Node representation. More... | |
| Document (std::string const &asJson, RecordLoader const &recordLoader) | |
| Create a Document from a JSON string representation. More... | |
| void | add (std::unique_ptr< Record > record) |
| Add the given record to this document. More... | |
| RecordList const & | getRecords () const noexcept |
| Get the list of records currently in this document. More... | |
| void | add (Relationship relationship) |
| Add a relationship to this document. More... | |
| RelationshipList const & | getRelationships () const noexcept |
| Get the list of relationships in this document. More... | |
| conduit::Node | toNode () const |
| Convert this document to a conduit Node. More... | |
| std::string | toJson (conduit::index_t indent=0, conduit::index_t depth=0, const std::string &pad="", const std::string &eoe="") const |
| Convert this document to a JSON string. More... | |
| std::string | get_supported_file_types () |
| Get the list of file types currently supported by the implementation. More... | |
An object representing the top-level object of a Sina file.
A Document represents the top-level object of a file conforming to the Sina schema. When serialized, these documents can be ingested into a Sina database and used with the Sina tool. Sina files are defaulted to JSON but optionally support HDF5.
Documents contain at most two objects: a list of Records and a list of Relationships. A simple, empty document:
The "records" list can contain Record objects and their inheriting types, such as Run (for a full list, please see the inheritance diagram in the Record documentation). The "relationships" list can contain Relationship objects.
Documents can be assembled programatically and/or generated from existing JSON. An example of an assembled Document is provided on the main page. To load a Document from an existing JSON file:
To generate a Document from a JSON string and vice versa:
You can add further entries to the Document using add():
You can also export your Document to file:
Loading and Saving documents will default to the JSON file type, but if an optional file type is loaded the Protocol parameter will control your file type. For example with HDF5:
Check the Sina file format version with:
| using axom::sina::Document::RecordList = std::vector<std::unique_ptr<Record> > |
A vector of pointers to Record objects.
| using axom::sina::Document::RelationshipList = std::vector<Relationship> |
A vector of Relationship objects.
|
default |
Construct an empty Document.
|
delete |
Disable copying Document objects. We must do this since we hold pointers to polymorphic objects.
|
default |
Move constructor which should be handled by the compiler.
| axom::sina::Document::Document | ( | conduit::Node const & | asNode, |
| RecordLoader const & | recordLoader | ||
| ) |
Create a Document from its Conduit Node representation.
| asNode | the Document as a Node |
| recordLoader | an RecordLoader to use to load the different types of records which may be in the document |
| axom::sina::Document::Document | ( | std::string const & | asJson, |
| RecordLoader const & | recordLoader | ||
| ) |
Create a Document from a JSON string representation.
| asJson | the Document as a JSON string |
| recordLoader | an RecordLoader to use to load the different types of records which may be in the document |
Move assignment which should be handled by the compiler.
| void axom::sina::Document::add | ( | std::unique_ptr< Record > | record | ) |
Add the given record to this document.
| record | the record to add |
|
inlinenoexcept |
Get the list of records currently in this document.
| void axom::sina::Document::add | ( | Relationship | relationship | ) |
Add a relationship to this document.
| relationship | the relationship to add |
|
inlinenoexcept |
Get the list of relationships in this document.
| conduit::Node axom::sina::Document::toNode | ( | ) | const |
Convert this document to a conduit Node.
| std::string axom::sina::Document::toJson | ( | conduit::index_t | indent = 0, |
| conduit::index_t | depth = 0, |
||
| const std::string & | pad = "", |
||
| const std::string & | eoe = "" |
||
| ) | const |
Convert this document to a JSON string.
| std::string axom::sina::Document::get_supported_file_types | ( | ) |
Get the list of file types currently supported by the implementation.