Molassembler  1.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Types.h
Go to the documentation of this file.
1 
8 #ifndef INCLUDE_MOLASSEMBLER_SHARED_TYPES_H
9 #define INCLUDE_MOLASSEMBLER_SHARED_TYPES_H
10 
11 #include "Molassembler/Export.h"
12 #include <cstddef>
13 #include <type_traits>
14 
15 namespace Scine {
16 
18 namespace Molassembler {
19 
26 enum class MASM_EXPORT BondType : unsigned {
27  Single,
28  Double,
29  Triple,
30  Quadruple,
31  Quintuple,
32  Sextuple,
38  Eta
39 };
40 
42 constexpr unsigned nBondTypes = 7;
43 
45 enum class MASM_EXPORT LengthUnit {
46  Bohr,
47  Angstrom
48 };
49 
51 using AtomIndex = std::size_t;
52 
54 struct MASM_EXPORT BondIndex {
62  using const_iterator = const AtomIndex*;
63 
68 
70  BondIndex();
72  BondIndex(AtomIndex a, AtomIndex b) noexcept;
73 
75  bool contains(AtomIndex a) const;
76 
78  bool operator < (const BondIndex& other) const;
80  bool operator == (const BondIndex& other) const;
81 
83  const_iterator begin() const;
84 
86  const_iterator end() const;
87 };
88 
93 MASM_EXPORT std::size_t hash_value(const BondIndex& bond);
94 
103 enum class MASM_EXPORT AtomEnvironmentComponents : unsigned {
104  Connectivity = 0,
105  ElementTypes = (1 << 0),
106  BondOrders = (1 << 1),
107  Shapes = (1 << 2),
108  Stereopermutations = (1 << 3),
109  All = ElementTypes | BondOrders | Shapes | Stereopermutations
110 };
111 
112 } // namespace Molassembler
113 } // namespace Scine
114 
115 /* Operators for bitmask-like manipulation of AtomEnvironmentComponents must be
116  * at global scope, otherwise they can interfere with name lookup.
117  */
122 constexpr inline bool operator & (
125 ) {
127  return (
128  static_cast<std::underlying_type_t<T>>(a)
129  & static_cast<std::underlying_type_t<T>>(b)
130  ) != 0;
131 }
132 
139 ) {
141 
142  return static_cast<T>(
143  static_cast<std::underlying_type_t<T>>(a)
144  | static_cast<std::underlying_type_t<T>>(b)
145  );
146 }
147 
148 #endif
LengthUnit
Length units.
Definition: Types.h:45
AtomIndex second
Larger atom index.
Definition: Types.h:67
const AtomIndex * const_iterator
Definition: Types.h:62
AtomEnvironmentComponents
For bitmasks grouping components of immediate atom environments.
Definition: Types.h:103
AtomIndex first
Smaller atom index.
Definition: Types.h:65
constexpr unsigned nBondTypes
Number of distinct bond types present in the library.
Definition: Types.h:42
constexpr Scine::Molassembler::AtomEnvironmentComponents operator|(const Scine::Molassembler::AtomEnvironmentComponents a, const Scine::Molassembler::AtomEnvironmentComponents b)
Compose an atom environment components bitmask from parts.
Definition: Types.h:136
std::size_t AtomIndex
Unsigned integer atom index type. Used to refer to particular atoms.
Definition: Types.h:51
BondType
Discrete bond type numeration.
Definition: Types.h:26
constexpr bool operator&(const Scine::Molassembler::AtomEnvironmentComponents a, const Scine::Molassembler::AtomEnvironmentComponents b)
Test whether two atom environment bitmasks share components.
Definition: Types.h:122
Type used to refer to particular bonds. Orders first &lt; second.
Definition: Types.h:54
std::size_t hash_value(const BondIndex &bond)
Hash for BondIndex so it can be used as a key type in unordered containers.
Internal bond order to mark haptic binding sites.