Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
Elements.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/Index.hpp>
22 #include <Reaktoro/Common/StringList.hpp>
23 #include <Reaktoro/Common/Types.hpp>
24 #include <Reaktoro/Core/Element.hpp>
25 
26 namespace Reaktoro {
27 
30 class Elements
31 {
32 public:
34  Elements(const Elements&) = delete;
35 
37  auto operator=(const Elements&) -> Elements& = delete;
38 
40  static auto instance() -> Elements&;
41 
43  static auto data() -> Vec<Element> const&;
44 
46  [[deprecated("Use Elements::data() instead.")]]
47  static auto elements() -> Vec<Element> const&;
48 
50  static auto append(Element element) -> void;
51 
53  static auto size() -> std::size_t;
54 
56  static auto withSymbol(String symbol) -> Optional<Element>;
57 
59  static auto withName(String name) -> Optional<Element>;
60 
62  static auto withTag(String tag) -> Vec<Element>;
63 
65  static auto withTags(StringList const& tags) -> Vec<Element>;
66 
68  auto begin() const { return data().begin(); }
69 
71  auto begin() { return data().begin(); }
72 
74  auto end() const { return data().end(); }
75 
77  auto end() { return data().end(); }
78 
79 private:
81  Vec<Element> m_elements;
82 
83 private:
85  Elements();
86 
88  ~Elements();
89 };
90 
91 } // namespace Reaktoro
A type used to define a element and its attributes.
Definition: Element.hpp:28
A type used store a collection of elements.
Definition: Elements.hpp:31
static auto withSymbol(String symbol) -> Optional< Element >
Return the element with given symbol.
static auto elements() -> Vec< Element > const &
Return the elements in the periodic table.
auto operator=(const Elements &) -> Elements &=delete
Assign a Elements object to this [deleted].
static auto withName(String name) -> Optional< Element >
Return the element with given name.
static auto withTag(String tag) -> Vec< Element >
Return the elements with a given tag.
auto end()
Return end iterator of this Elements instance.
Definition: Elements.hpp:77
static auto size() -> std::size_t
Return the number of elements in the periodic table.
static auto instance() -> Elements &
Return the single Elements object.
static auto append(Element element) -> void
Append a custom element to the periodic table.
Elements(const Elements &)=delete
Construct a copy of a Elements object [deleted].
auto begin() const
Return begin const iterator of this Elements instance.
Definition: Elements.hpp:68
auto begin()
Return begin iterator of this Elements instance.
Definition: Elements.hpp:71
static auto data() -> Vec< Element > const &
Return the elements in the periodic table.
auto end() const
Return end const iterator of this Elements instance.
Definition: Elements.hpp:74
static auto withTags(StringList const &tags) -> Vec< Element >
Return the elements with given tags.
A class for representing a list of strings with special constructors.
Definition: StringList.hpp:28
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
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::optional< T > Optional
Convenient alias for std::optional<T>.
Definition: Types.hpp:114