Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
Database.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright © 2014-2024 Allan Leal
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // Reaktoro includes
21 #include <Reaktoro/Common/Types.hpp>
22 #include <Reaktoro/Core/ElementList.hpp>
23 #include <Reaktoro/Core/Reaction.hpp>
24 #include <Reaktoro/Core/SpeciesList.hpp>
25 
26 namespace Reaktoro {
27 
31 class Database
32 {
33 public:
37  static auto fromFile(String const& path) -> Database;
38 
42  static auto fromEmbeddedFile(String const& path) -> Database;
43 
46  static auto fromContents(String const& contents) -> Database;
47 
50  static auto fromStream(std::istream& stream) -> Database;
51 
53  static auto local(String const& path) -> Database;
54 
56  static auto embedded(String const& path) -> Database;
57 
60 
62  Database(Database const& other);
63 
66 
68  explicit Database(Vec<Species> const& species);
69 
72 
74  auto operator=(Database other) -> Database&;
75 
77  auto clear() -> void;
78 
82  auto addElement(Element const& element) -> void;
83 
87  auto addSpecies(Species const& species) -> void;
88 
90  auto addSpecies(Vec<Species> const& species) -> void;
91 
93  auto attachData(Any const& data) -> void;
94 
96  auto extend(Database const& other) -> void;
97 
99  auto elements() const -> ElementList const&;
100 
102  auto species() const -> SpeciesList const&;
103 
106 
109  auto element(String const& symbol) const -> Element const&;
110 
113  auto species(String const& name) const -> Species const&;
114 
117  auto reaction(String const& equation) const -> Reaction;
118 
120  auto attachedData() const -> Any const&;
121 
122 private:
123  struct Impl;
124 
125  Ptr<Impl> pimpl;
126 };
127 
128 } // namespace Reaktoro
The class used to store and retrieve data of chemical species.
Definition: Database.hpp:32
auto element(String const &symbol) const -> Element const &
Return an element with given symbol in the database.
auto reaction(String const &equation) const -> Reaction
Construct a reaction with given equation.
static auto embedded(String const &path) -> Database
Return a Database object constructed with a given embedded file.
~Database()
Destroy this Database object.
Database(Vec< Element > const &elements, Vec< Species > const &species)
Construct a Database object with given elements and species.
auto addSpecies(Vec< Species > const &species) -> void
Add a list of species in the database.
auto clear() -> void
Remove all species and elements from the database.
auto addSpecies(Species const &species) -> void
Add a species in the database.
auto addElement(Element const &element) -> void
Add an element in the database.
Database()
Construct a default Database object.
static auto fromEmbeddedFile(String const &path) -> Database
Return a Database object constructed with a given embedded file.
auto speciesWithAggregateState(AggregateState option) const -> SpeciesList
Return all species in the database with given aggregate state.
auto species() const -> SpeciesList const &
Return all species in the database.
static auto fromStream(std::istream &stream) -> Database
Return a Database object constructed with given input stream containing the database text contents.
auto extend(Database const &other) -> void
Extend this database with elements, species and other contents from another database.
Database(Vec< Species > const &species)
Construct a Database object with given species (elements extracted from them).
static auto local(String const &path) -> Database
Return a Database object constructed with a given local file.
auto operator=(Database other) -> Database &
Assign another Database object to this.
auto attachedData() const -> Any const &
Return the attached data to this database whose type is known at runtime only.
Database(Database const &other)
Construct a copy of a Database object.
auto elements() const -> ElementList const &
Return all elements in the database.
static auto fromFile(String const &path) -> Database
Return a Database object constructed with a given local file.
static auto fromContents(String const &contents) -> Database
Return a Database object constructed with given database text contents.
auto attachData(Any const &data) -> void
Attach data to this database whose type is known at runtime only.
A type used as a collection of elements.
Definition: ElementList.hpp:28
A type used to define a element and its attributes.
Definition: Element.hpp:28
A class to represent a reaction and its attributes.
Definition: Reaction.hpp:42
A type used as a collection of species.
Definition: SpeciesList.hpp:29
A type used to represent a chemical species and its attributes.
Definition: Species.hpp:35
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
AggregateState
The aggregate states of substances according to IUPAC.
Definition: AggregateState.hpp:32
std::vector< T > Vec
Convenient alias for std::vector<T>.
Definition: Types.hpp:66
std::string String
Convenient alias for std::string.
Definition: Types.hpp:52
std::unique_ptr< T > Ptr
Convenient alias for std::unique_ptr<T>.
Definition: Types.hpp:102
std::any Any
Convenient alias for std::any.
Definition: Types.hpp:125