CEPS  24.01
Cardiac ElectroPhysiology Simulator
HoldsCells.hpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
31 #pragma once
32 
34 
36 namespace ceps
37 {
44  template <class CellType>
45  class HoldsCells
46  {
47  public:
49  explicit HoldsCells(const CepsVector<CellType*>& cells);
50 
52  HoldsCells(CellType** cells, const CepsUInt& n);
53 
55  HoldsCells() = default;
56 
58  HoldsCells(const HoldsCells&) = default;
59 
61  HoldsCells(HoldsCells&&) noexcept = default;
62 
64  virtual ~HoldsCells() = default;
65 
67  HoldsCells&
68  operator=(const HoldsCells&) = default;
69 
71  HoldsCells&
72  operator=(HoldsCells&&) noexcept = default;
73 
75  CepsUInt
77 
79  CepsUInt
81 
83  CepsVector<CellType*>
85 
87  CepsVector<CellType*>&
89 
91  const CepsVector<CellType*>&
92  getCells() const;
93 
95  CellType*&
96  getCellAt(const CepsUInt& i);
97 
99  const CellType*&
100  getCellAt(const CepsUInt& i) const;
101 
103  void
104  setCells(const CepsVector<CellType*>& cells);
105 
107  void
108  setCells(CellType** cells, const CepsUInt& n);
109 
111  template <class _It>
112  void
113  setCells (_It first, _It last);
114 
121  void
122  setCellAt(const CepsUInt& i, CellType* neigh);
123 
125  void
126  addCell(CellType*& name);
127 
129  void
130  addCells(const CepsVector<CellType*>& cells);
131 
133  void
134  addCells(CellType** cells, const CepsUInt& n);
135 
137  template <class _It>
138  void
139  addCells(_It first, _It last);
140 
142  void
143  removeCell(CellType*& name);
144 
146  void
147  removeCells(const CepsVector<CellType*>& cells);
148 
150  void
151  removeCells(CellType **cells, const CepsUInt &n);
152 
154  template <class _It>
155  void
156  removeCells(_It first, _It last);
157 
159  void
161 
163  CepsBool
164  hasCell(CellType*& neigh);
165 
167  CepsBool
168  hasAllCells(const CepsVector<CellType*>& cells);
169 
171  CepsBool
172  hasAllCells(CellType** cells, const CepsUInt& n);
173 
175  template <class _It>
176  CepsBool
177  hasAllCells(_It first, _It last);
178 
180  CepsBool
181  hasOneOfCells(const CepsVector<CellType*>& cells);
182 
184  CepsBool
185  hasOneOfCells(CellType** cells, const CepsUInt& n);
186 
188  template <class _It>
189  CepsBool
190  hasOneOfCells(_It first, _It last);
191 
193  CepsIndex
195 
199 
201  void
202  reset();
203 
204 
205  protected:
206 
208  void
209  errorOnCellIndex(CepsUInt i, const CepsString& funcName) const;
210 
211 
212  protected:
213 
215  CepsVector<CellType*> m_cells;
216 
217  };
218 
219 } // namespace ceps
220 
221 // Template member definitions
222 #include "common/abstract/HoldsCells.tpp"
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
std::vector< _Type, _Alloc > CepsVector
C++ vector.
Definition: CepsTypes.hpp:155
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
Definition: CepsTypes.hpp:109
CepsInt CepsIndex
Index rowid etc.
Definition: CepsTypes.hpp:111
An abstract class for objects that regroup pointers to cells (eg a mesh, a finite elements discretiza...
Definition: HoldsCells.hpp:46
HoldsCells(const HoldsCells &)=default
Copy constructor.
void removeCell(CellType *&name)
Removes a given cell pointer from the list.
HoldsCells(HoldsCells &&) noexcept=default
Copy constructor.
HoldsCells(const CepsVector< CellType * > &cells)
Constructor with a vector of cells.
void reset()
Equivalent to HoldsCells::clearCells.
CepsUInt getNumberOfCells() const
Returns the number of cells in the object.
void addCells(const CepsVector< CellType * > &cells)
Adds several cells to the list.
void errorOnCellIndex(CepsUInt i, const CepsString &funcName) const
Aborts if object holds less than i cells.
HoldsCells(CellType **cells, const CepsUInt &n)
Constructor with a vector of cells.
CepsBool hasAllCells(const CepsVector< CellType * > &cells)
Tells if object has all cells given in argument.
CepsIndex getCellIndex(CepsUInt i) const
Get the index of i-th cell.
CepsBool hasOneOfCells(const CepsVector< CellType * > &cells)
Tells if object has one of the cells given in argument.
void addCell(CellType *&name)
Adds a cell to the list.
CepsVector< CellType * > & getCells()
Reference to the cells.
CepsBool hasCell(CellType *&neigh)
Tells if object has the cell given in argument.
void setCellAt(const CepsUInt &i, CellType *neigh)
Set a cell pointer in the vector of currently held cells, at given index.
void setCells(const CepsVector< CellType * > &cells)
Replaces currently held cell pointers.
HoldsCells()=default
Default constructor.
void removeCells(const CepsVector< CellType * > &cells)
Removes several cell pointers from the list.
CepsVector< CellType * > getValidCells()
Reference to the valid cells.
CepsVector< CellType * > m_cells
The cell pointers.
Definition: HoldsCells.hpp:215
void clearCells()
Wipes the current list of cell pointers.
CepsVector< CepsIndex > getCellsIndices() const
Get indices of all cells.
CellType *& getCellAt(const CepsUInt &i)
Pointer to the i-th cell.
CepsUInt countValidCells()
Get the number of cells that are not nullptr.
A namespace for all utility methods.