Molassembler  3.0.1
Molecule graph and conformer library
StereopermutatorList.h
Go to the documentation of this file.
1 
11 #ifndef INCLUDE_MOLASSEMBLER_STEREOPERMUTATOR_LIST_H
12 #define INCLUDE_MOLASSEMBLER_STEREOPERMUTATOR_LIST_H
13 
14 #include "Molassembler/Types.h"
16 
17 #include "boost/optional/optional_fwd.hpp"
18 #include <memory>
19 #include <vector>
20 
21 namespace Scine {
22 namespace Molassembler {
23 
24 class AtomStereopermutator;
25 class BondStereopermutator;
26 
30 class MASM_EXPORT StereopermutatorList {
31 private:
32  struct Impl;
33 
34 public:
37  template<typename Permutator>
38  class iterator {
39  public:
40  static_assert(
41  std::is_same<std::decay_t<Permutator>, AtomStereopermutator>::value
42  || std::is_same<std::decay_t<Permutator>, BondStereopermutator>::value,
43  "This type may not be instantiated for any type other than atom and bond stereopermutators"
44  );
45 
46  using iterator_category = std::forward_iterator_tag;
47  using difference_type = std::ptrdiff_t;
48  using value_type = Permutator;
49  using pointer = Permutator*;
50  using reference = Permutator&;
51 
52  iterator(iterator&& other) noexcept;
53  iterator& operator = (iterator&& other) noexcept;
54  iterator(const iterator& other);
55  iterator& operator = (const iterator& other);
56  ~iterator();
57 
58  iterator();
59 
60  using ImplType = std::conditional_t<
61  std::is_const<Permutator>::value,
64  >;
65  iterator(ImplType impl, bool begin);
66 
67  iterator& operator ++ ();
68  iterator operator ++ (int);
69  reference operator * () const;
70 
71  bool operator == (const iterator& other) const;
72  bool operator != (const iterator& other) const;
73 
74  private:
75  struct Impl;
76  std::unique_ptr<Impl> impl_;
77  };
78 
84 
89  StereopermutatorList& operator = (StereopermutatorList&& other) noexcept;
91  StereopermutatorList& operator = (const StereopermutatorList& other);
94 
97 
105 
121 
129 
137  void applyPermutation(const std::vector<AtomIndex>& permutation);
138 
143  void clear();
144 
149  void clearBonds();
150 
155  boost::optional<AtomStereopermutator&> option(AtomIndex index);
156 
161  boost::optional<BondStereopermutator&> option(const BondIndex& edge);
162 
171  void propagateVertexRemoval(AtomIndex removedIndex);
172 
178  bool remove(AtomIndex index);
179 
185  bool remove(const BondIndex& edge);
186 
191  [[deprecated("Prefer remove")]]
192  void try_remove(AtomIndex index);
193 
198  [[deprecated("Prefer remove")]]
199  void try_remove(const BondIndex& edge);
201 
204 
211  const AtomStereopermutator& at(AtomIndex index) const;
212 
220  const BondStereopermutator& at(const BondIndex& index) const;
221 
226  bool compare(
227  const StereopermutatorList& other,
228  AtomEnvironmentComponents componentBitmask
229  ) const;
230 
235  bool empty() const;
236 
242 
248 
253  boost::optional<const AtomStereopermutator&> option(AtomIndex index) const;
254 
259  boost::optional<const BondStereopermutator&> option(const BondIndex& edge) const;
260 
265  unsigned A() const;
266 
271  unsigned B() const;
272 
277  unsigned size() const;
279 
282 
287 
293 
299 
306 
309 
313  bool operator == (const StereopermutatorList& other) const;
315  bool operator != (const StereopermutatorList& other) const;
317 
318 private:
319  std::unique_ptr<Impl> impl_;
320 };
321 
322 } // namespace Molassembler
323 } // namespace Scine
324 #endif
Range type.
Defines basic types widely shared across the project.
Handles the steric permutation of substituents of a non-terminal central atom.
Definition: AtomStereopermutator.h:79
Handles specific relative arrangements of two atom stereopermutators joined by a bond.
Definition: BondStereopermutator.h:46
Definition: StereopermutatorList.h:38
Manages all stereopermutators that are part of a Molecule.
Definition: StereopermutatorList.h:30
IteratorRange< BondStereopermutatorConstIterator > bondStereopermutators() const
Returns an iterable object with unmodifiable bond stereopermutator references.
IteratorRange< AtomStereopermutatorConstIterator > atomStereopermutators() const
Returns an iterable object with unmodifiable atom stereopermutator references.
void clearBonds()
Remove all stereopermutators on bonds.
void applyPermutation(const std::vector< AtomIndex > &permutation)
Apply an index mapping to the list of stereopermutators.
bool remove(AtomIndex index)
Removes the AtomStereopermutator on a specified index, if present.
unsigned B() const
Returns the number of BondStereopermutators.
bool remove(const BondIndex &edge)
Removes the BondStereopermutator on a specified edge, if present.
bool hasUnassignedStereopermutators() const
Returns true if there are unassigned stereopermutators.
bool empty() const
Returns true if there are no stereopermutators.
bool compare(const StereopermutatorList &other, AtomEnvironmentComponents componentBitmask) const
Modular comparison with another StereopermutatorList using a bitmask.
BondStereopermutator & at(const BondIndex &index)
Access bond stereopermutator at a bond.
void try_remove(const BondIndex &edge)
Removes the BondStereopermutator on a specified edge, if present.
boost::optional< const BondStereopermutator & > option(const BondIndex &edge) const
Fetch a const ref-option to a BondStereopermutator, if present.
AtomStereopermutator & add(AtomStereopermutator stereopermutator)
Add a new AtomStereopermutator to the list.
boost::optional< AtomStereopermutator & > option(AtomIndex index)
Fetch a reference-option to an AtomStereopermutator.
unsigned A() const
Returns the number of AtomStereopermutators.
const BondStereopermutator & at(const BondIndex &index) const
Access bond stereopermutator at a bond.
void try_remove(AtomIndex index)
Removes the AtomStereopermutator on a specified index, if present.
void propagateVertexRemoval(AtomIndex removedIndex)
Communicates the removal of a vertex index to all stereopermutators in the list.
bool hasZeroAssignmentStereopermutators() const
Returns true if there are any stereopermutators with zero possible assignments.
IteratorRange< AtomStereopermutatorIterator > atomStereopermutators()
Returns an iterable object with modifiable atom stereopermutator references.
const AtomStereopermutator & at(AtomIndex index) const
Access atom stereopermutator at an atom.
IteratorRange< BondStereopermutatorIterator > bondStereopermutators()
Returns an iterable object with modifiable bond stereopermutator references.
unsigned size() const
Combined size of atom and bond-stereopermutator lists.
AtomStereopermutator & at(AtomIndex index)
Access atom stereopermutator at an atom.
boost::optional< const AtomStereopermutator & > option(AtomIndex index) const
Fetch a const ref-option to an AtomStereopermutator, if present.
boost::optional< BondStereopermutator & > option(const BondIndex &edge)
Fetch a reference-option to a BondStereopermutator.
BondStereopermutator & add(BondStereopermutator stereopermutator)
Add a new BondStereopermutator to the list.
void clear()
Remove all stereopermutators.
AtomEnvironmentComponents
For bitmasks grouping components of immediate atom environments.
Definition: Types.h:103
std::size_t AtomIndex
Unsigned integer atom index type. Used to refer to particular atoms.
Definition: Types.h:51
Type used to refer to particular bonds. Orders first < second.
Definition: Types.h:54
Homogeneous pair of iterators with begin and end member fns.
Definition: IteratorRange.h:26
Definition: StereopermutatorListImpl.h:19