Debian Codegraph @

avogadro/core/atomtyper.h

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #ifndef AVOGADRO_CORE_ATOMTYPER_H
7 #define AVOGADRO_CORE_ATOMTYPER_H
8
9 #include <avogadro/core/array.h>
10
11 namespace Avogadro::Core {
12 class Atom;
13 class Molecule;
14
15 /**
16 * @class AtomTyper atomtyper.h <avogadro/core/atomtyper.h>
17 * @brief The AtomTyper class provides a base interface for generating a list of
18 * type identifiers describing the atoms in a molecule.
19 */
20 template <typename OutputType>
21 class AtomTyper
22 {
23 public:
24 using ValueType = OutputType;
25
26 explicit AtomTyper(const Molecule* mol = nullptr);
27 virtual ~AtomTyper();
28
29 /**
30 * @param mol The molecule with atoms to type.
31 */
32 void setMolecule(const Molecule* mol);
33
34 /**
35 * Iterate through the molecule and generate type descriptions for each atom.
36 * The results can be obtained by calling types().
37 */
38 virtual void run();
39
40 /**
41 * Perform a type lookup on the specified atom. If run() has been called
42 * previously, a cached result is returned.
43 * @return The type of @a atom.
44 */
45 virtual OutputType atomType(const Atom& atom);
46
47 /**
48 * @return An Array of OutputType objects. There will be one object for each
49 * atom of the input Molecule, and they are ordered by the corresponding
50 * atom's index.
51 */
52 Array<OutputType> types() const;
53
54 /**
55 * Reset the typer's internal state. This is called when the molecule is
56 * changed. The base implementation clears the m_types Array.
57 */
58 virtual void reset();
59
60 protected:
61 /**
62 * Perform any setup needed that needs to be done prior to calling type(). The
63 * base implementation of this function reserves enough room in the m_types
64 * Array for the current Molecule.
65 */
66 virtual void initialize();
67
68 /**
69 * Determines the type of the atom.
70 * @param atom The atom to type.
71 * @return The type of @a atom.
72 */
73 virtual OutputType type(const Atom& atom) = 0;
74
75 /** The molecule on which to operate. */
76 const Molecule* m_molecule;
77
78 /** The array of types to be populated. */
79 Array<OutputType> m_types;
80 };
81
82 } // namespace Avogadro::Core
83
84 #include <avogadro/core/atomtyper-inline.h>
85
86 #endif // AVOGADRO_CORE_ATOMTYPER_H