Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
SurfaceList.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/Common/StringList.hpp>
23 #include <Reaktoro/Core/Surface.hpp>
24 
25 namespace Reaktoro {
26 
29 {
30 public:
33 
35  SurfaceList(std::initializer_list<Surface> surfaces);
36 
38  SurfaceList(Vec<Surface> const& surfaces);
39 
41  auto append(Surface const& surface) -> void;
42 
44  auto data() const -> Vec<Surface> const&;
45 
47  auto empty() const -> bool;
48 
50  auto size() const -> Index;
51 
53  auto operator[](Index i) const -> Surface const&;
54 
56  auto operator[](Index i) -> Surface&;
57 
59  auto find(String const& name) const -> Index;
60 
62  auto findWithName(String const& name) const -> Index;
63 
65  auto index(String const& name) const -> Index;
66 
68  auto indexWithName(String const& name) const -> Index;
69 
71  auto get(String const& name) const -> Surface const&;
72 
74  auto getWithName(String const& name) const -> Surface const&;
75 
77  auto withNames(StringList const& names) const -> SurfaceList;
78 
80  operator Vec<Surface>&();
81 
83  operator Vec<Surface>const&() const;
84 
85 private:
87  Vec<Surface> m_surfaces;
88 
89 public:
91  template<typename InputIterator>
92  SurfaceList(InputIterator begin, InputIterator end) : m_surfaces(begin, end) {}
93 
95  auto begin() const { return m_surfaces.begin(); }
96 
98  auto begin() { return m_surfaces.begin(); }
99 
101  auto end() const { return m_surfaces.end(); }
102 
104  auto end() { return m_surfaces.end(); }
105 
107  auto push_back(Surface const& surfaces) -> void { append(surfaces); }
108 
110  template<typename Iterator, typename InputIterator>
111  auto insert(Iterator pos, InputIterator begin, InputIterator end) -> void { m_surfaces.insert(pos, begin, end); }
112 
115 };
116 
118 auto operator+(SurfaceList const& a, SurfaceList const& b) -> SurfaceList;
119 
120 } // namespace Reaktoro
A class for representing a list of strings with special constructors.
Definition: StringList.hpp:28
A type used as a collection of surfaces.
Definition: SurfaceList.hpp:29
auto get(String const &name) const -> Surface const &
Return the surface with given name.
auto findWithName(String const &name) const -> Index
Return the index of the first surface with given unique name or the number of surfaces if not found.
auto empty() const -> bool
Return true if there are no surfaces in the collection.
SurfaceList(std::initializer_list< Surface > surfaces)
Construct an SurfaceList object with given surfaces.
auto end()
Return end iterator of this SurfaceList instance (for STL compatibility reasons).
Definition: SurfaceList.hpp:104
auto indexWithName(String const &name) const -> Index
Return the index of the first surface with given unique name or throw a runtime error if not found.
auto append(Surface const &surface) -> void
Append a new surface to the list of surfaces.
auto withNames(StringList const &names) const -> SurfaceList
Return all surfaces with given names.
auto data() const -> Vec< Surface > const &
Return the internal collection of Surface objects.
SurfaceList()
Construct a default SurfaceList object.
auto getWithName(String const &name) const -> Surface const &
Return the surface with given name or throw a runtime error if not found.
SurfaceList(Vec< Surface > const &surfaces)
Construct an SurfaceList object with given surfaces.
auto insert(Iterator pos, InputIterator begin, InputIterator end) -> void
Insert a container of Surface objects into this SurfaceList instance (for STL compatibility reasons).
Definition: SurfaceList.hpp:111
auto begin() const
Return begin const iterator of this SurfaceList instance (for STL compatibility reasons).
Definition: SurfaceList.hpp:95
auto begin()
Return begin iterator of this SurfaceList instance (for STL compatibility reasons).
Definition: SurfaceList.hpp:98
auto end() const
Return end const iterator of this SurfaceList instance (for STL compatibility reasons).
Definition: SurfaceList.hpp:101
auto push_back(Surface const &surfaces) -> void
Append a new Surface at the back of the container (for STL compatibility reasons).
Definition: SurfaceList.hpp:107
auto find(String const &name) const -> Index
Return the index of the first surface with given name or the number of surfaces if not found.
auto size() const -> Index
Return the number of surfaces in the collection.
auto index(String const &name) const -> Index
Return the index of the first surface with given name or throw a runtime error if not found.
Used to represent a surface across which chemical reactions take place.
Definition: Surface.hpp:31
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::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
auto operator+(const typename Derived::Scalar &scalar, const Eigen::MatrixBase< Derived > &mat) -> decltype((scalar+mat.array()).matrix())
Return the component-wise division of two matrices.
Definition: Matrix.hpp:774