CEPS  24.01
Cardiac ElectroPhysiology Simulator
HoldsAttributes.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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
30 #pragma once
31 
33 
35 namespace ceps
36 {
37 
42  {
43 
44  public:
45 
47  explicit HoldsAttributes(const CepsSet<CepsAttribute>& attributes);
48 
50  explicit HoldsAttributes(const CepsVector<CepsAttribute>& attributes);
51 
53  HoldsAttributes(CepsAttribute* attributes, const CepsUInt& n);
54 
56  HoldsAttributes() = default;
57 
59  HoldsAttributes(const HoldsAttributes&) = default;
60 
62  HoldsAttributes(HoldsAttributes&&) noexcept = default;
63 
65  virtual ~HoldsAttributes() = default;
66 
69  operator=(const HoldsAttributes&) = default;
70 
73  operator=(HoldsAttributes&&) noexcept = default;
74 
76  CepsUInt
77  getNumberOfAttributes() const;
78 
81  getAttributes();
82 
84  const CepsSet<CepsAttribute>&
85  getAttributes() const;
86 
88  void
89  setAttributes(const CepsVector<CepsAttribute>& attributes);
90 
92  void
93  setAttributes(const CepsSet<CepsAttribute>& attributes);
94 
96  void
97  setAttributes(const CepsAttribute* attributes, const CepsUInt& n);
98 
100  template <class _It>
101  void
102  setAttributes(_It first, _It last)
103  {
104  m_attributes = CepsSet<CepsAttribute>(first, last);
105  return;
106  }
107 
109  void
110  addAttribute (const CepsAttribute& name);
111 
113  void
114  addAttributes(const CepsVector<CepsAttribute>& attributes);
115 
117  void
118  addAttributes(const CepsSet<CepsAttribute>& attributes);
119 
121  void
122  addAttributes(const CepsAttribute* attributes, const CepsUInt& n);
123 
125  template <class _It>
126  void
127  addAttributes(_It first, _It last)
128  {
129  for (_It it=first; it!=last; ++it)
130  {
131  auto attr = *it;
132  addAttribute(attr);
133  }
134  return;
135  }
136 
138  void
139  removeAttribute(const CepsAttribute& name);
140 
142  void
143  removeAttributes(const CepsSet<CepsAttribute>& attributes);
144 
146  void
147  removeAttributes(const CepsVector<CepsAttribute>& attributes);
148 
150  void
151  removeAttributes(const CepsAttribute* attributes, const CepsUInt &n);
152 
154  template <class _It>
155  void
156  removeAttributes(_It first, _It last)
157  {
158  for (_It it=first; it!=last; ++it)
159  {
160  auto attr = *it;
161  removeAttribute(attr);
162  }
163  return;
164  }
165 
167  void
168  clearAttributes();
169 
171  CepsBool
172  hasAttribute(const CepsAttribute& name) const;
173 
175  CepsBool
176  hasAllAttributes(const CepsVector<CepsAttribute>& attributes) const;
177 
179  CepsBool
180  hasAllAttributes(const CepsAttribute* attributes, const CepsUInt& n) const;
181 
183  template <class _It>
184  CepsBool
185  hasAllAttributes(_It first, _It last) const
186  {
187  for (_It it=first; it!=last; ++it)
188  {
189  auto attr = *it;
190  if (not hasAttribute(attr))
191  return false;
192  }
193  return true;
194  }
195 
197  CepsBool
198  hasOneOfAttributes(const CepsSet<CepsAttribute>& attributes) const;
199 
201  CepsBool
202  hasOneOfAttributes (const CepsVector<CepsAttribute>& attributes) const;
203 
205  CepsBool
206  hasOneOfAttributes(const CepsAttribute* attributes, const CepsUInt& n) const;
207 
209  template <class _It>
210  CepsBool
211  hasOneOfAttributes(_It first, _It last) const
212  {
213  for (_It it=first; it!=last; ++it)
214  {
215  auto attr = *it;
216  if (hasAttribute(attr))
217  return true;
218  }
219  return false;
220  }
221 
223  CepsBool
224  hasUniversalAttribute() const;
225 
227  void
228  reset();
229 
230 
231  protected:
232 
235 
236  };
237 
238 } // namespace ceps
std::set< _Type, _Compare, _Alloc > CepsSet
C++ set.
Definition: CepsTypes.hpp:209
std::vector< _Type, _Alloc > CepsVector
C++ vector.
Definition: CepsTypes.hpp:155
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
CepsInt CepsAttribute
Used to define regions.
Definition: CepsTypes.hpp:215
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
Definition: CepsTypes.hpp:109
An abstract class from which all objects that contain region attributes should derive.
CepsBool hasOneOfAttributes(_It first, _It last) const
Tells if the entity has one of the attributes in argument.
CepsSet< CepsAttribute > m_attributes
The attributes held by the entity.
CepsBool hasAllAttributes(const CepsVector< CepsAttribute > &attributes) const
Tells if the entity has all the attributes in argument.
void addAttribute(const CepsAttribute &name)
Adds an attribute to the entity.
HoldsAttributes(HoldsAttributes &&) noexcept=default
Copy constructor.
HoldsAttributes(const HoldsAttributes &)=default
Assignement operator.
CepsBool hasOneOfAttributes(const CepsSet< CepsAttribute > &attributes) const
Tells if the entity has one of the attributes in argument.
void removeAttributes(_It first, _It last)
Removes several attributes from the entity.
CepsBool hasAllAttributes(_It first, _It last) const
Tells if the entity has all the attributes in argument.
void addAttributes(_It first, _It last)
Adds several attributes to the entity.
void clearAttributes()
Removes all attributes from the entity.
void setAttributes(const CepsVector< CepsAttribute > &attributes)
Sets the attributes of the entity.
void addAttributes(const CepsVector< CepsAttribute > &attributes)
Adds several attributes to the entity.
void reset()
Equivalent to HoldsAttributes::clear()
CepsBool hasAttribute(const CepsAttribute &name) const
Tells if the entity has the attribute in argument.
CepsBool hasUniversalAttribute() const
Detect if the current entity has the attribute universal.
CepsSet< CepsAttribute > & getAttributes()
Returns the attributes of the entity.
void removeAttributes(const CepsSet< CepsAttribute > &attributes)
Removes several attributes from the entity.
HoldsAttributes()=default
Default constructor.
void removeAttribute(const CepsAttribute &name)
Removes an attribute from the entity.
CepsUInt getNumberOfAttributes() const
Returns number of attributes of the entity.
A namespace for all utility methods.