Molassembler  1.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 
113  BondStereopermutator& at(const BondIndex& index);
120  AtomStereopermutator& add(AtomStereopermutator stereopermutator);
121 
128  BondStereopermutator& add(BondStereopermutator stereopermutator);
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 
177  void remove(AtomIndex index);
178 
183  void remove(const BondIndex& edge);
184 
189  void try_remove(AtomIndex index);
190 
195  void try_remove(const BondIndex& edge);
197 
200 
207  const AtomStereopermutator& at(AtomIndex index) const;
208 
216  const BondStereopermutator& at(const BondIndex& index) const;
217 
222  bool compare(
223  const StereopermutatorList& other,
224  AtomEnvironmentComponents componentBitmask
225  ) const;
226 
231  bool empty() const;
232 
237  bool hasZeroAssignmentStereopermutators() const;
238 
243  bool hasUnassignedStereopermutators() const;
244 
249  boost::optional<const AtomStereopermutator&> option(AtomIndex index) const;
250 
255  boost::optional<const BondStereopermutator&> option(const BondIndex& edge) const;
256 
261  unsigned A() const;
262 
267  unsigned B() const;
268 
273  unsigned size() const;
275 
278 
282  IteratorRange<AtomStereopermutatorIterator> atomStereopermutators();
283 
288  IteratorRange<AtomStereopermutatorConstIterator> atomStereopermutators() const;
289 
294  IteratorRange<BondStereopermutatorIterator> bondStereopermutators();
295 
300  IteratorRange<BondStereopermutatorConstIterator> bondStereopermutators() const;
302 
305 
309  bool operator == (const StereopermutatorList& other) const;
311  bool operator != (const StereopermutatorList& other) const;
313 
314 private:
315  std::unique_ptr<Impl> impl_;
316 };
317 
318 } // namespace Molassembler
319 } // namespace Scine
320 #endif
Defines basic types widely shared across the project.
auto at(Container &&container)
Make functor calling at on arguments.
Definition: Functor.h:58
AtomEnvironmentComponents
For bitmasks grouping components of immediate atom environments.
Definition: Types.h:103
Handles the steric permutation of substituents of a non-terminal central atom.
Definition: AtomStereopermutator.h:79
void remove(Container &container, const T &value)
Applies erase-remove idiom in-place to container.
Definition: Functional.h:299
Homogeneous pair of iterators with begin and end member fns.
Definition: IteratorRange.h:26
Handles specific relative arrangements of two atom stereopermutators joined by a bond.
Definition: BondStereopermutator.h:46
Manages all stereopermutators that are part of a Molecule.
Definition: StereopermutatorList.h:30
Range type.
std::size_t AtomIndex
Unsigned integer atom index type. Used to refer to particular atoms.
Definition: Types.h:51
Permutation applyPermutation(const Permutation &occupation, const Permutation &permutation)
Rotates a passed list of indices with a specified rotation vector.
Type used to refer to particular bonds. Orders first &lt; second.
Definition: Types.h:54
unsigned size(const Shape shape)
Fetch the number of vertices of a shape.
Definition: StereopermutatorList.h:38
Definition: StereopermutatorListImpl.h:19