1 | /*
|
---|
2 | * Fragment.hpp
|
---|
3 | *
|
---|
4 | * Created on: Aug 8, 2012
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef FRAGMENT_HPP_
|
---|
9 | #define FRAGMENT_HPP_
|
---|
10 |
|
---|
11 |
|
---|
12 | // include config.h
|
---|
13 | #ifdef HAVE_CONFIG_H
|
---|
14 | #include <config.h>
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #include <vector>
|
---|
18 |
|
---|
19 | class Fragment {
|
---|
20 | public:
|
---|
21 | typedef std::vector< std::vector<double> > positions_t;
|
---|
22 | typedef std::vector< double > charges_t;
|
---|
23 | typedef std::pair< std::vector<double>, double> nucleus_t;
|
---|
24 | typedef std::vector< nucleus_t > nuclei_t;
|
---|
25 |
|
---|
26 | /** Default constructor of class Fragment.
|
---|
27 | *
|
---|
28 | */
|
---|
29 | Fragment();
|
---|
30 |
|
---|
31 | /** Default constructor of class Fragment.
|
---|
32 | *
|
---|
33 | */
|
---|
34 | Fragment(const nuclei_t &_nuclei) :
|
---|
35 | nuclei(_nuclei)
|
---|
36 | {}
|
---|
37 |
|
---|
38 | /** Constructor of class Fragment.
|
---|
39 | *
|
---|
40 | * @param _positions given positions
|
---|
41 | * @param _charges given charges
|
---|
42 | */
|
---|
43 | Fragment(std::vector< std::vector<double> > &_positions, std::vector< double > &_charges);
|
---|
44 |
|
---|
45 | /** Adding another fragment onto this one.
|
---|
46 | *
|
---|
47 | * \note The operation is area-conserving, i.e. the new area is the sum of
|
---|
48 | * both areas.
|
---|
49 | *
|
---|
50 | * @param other other fragment
|
---|
51 | * @return ref to this instance
|
---|
52 | */
|
---|
53 | Fragment& operator+=(const Fragment &other);
|
---|
54 |
|
---|
55 | /** Assignment operator.
|
---|
56 | *
|
---|
57 | * @param other other fragment to make ourselves equal to
|
---|
58 | * @return ref to this instance
|
---|
59 | */
|
---|
60 | Fragment& operator=(const Fragment &other);
|
---|
61 |
|
---|
62 | /** Subtracting another fragment from this one.
|
---|
63 | *
|
---|
64 | * @param other other fragment
|
---|
65 | * @return ref to this instance
|
---|
66 | */
|
---|
67 | Fragment& operator-=(const Fragment &other);
|
---|
68 |
|
---|
69 | private:
|
---|
70 | /** Helper function that checks whether this nuclei is present.
|
---|
71 | *
|
---|
72 | * This operation is \f${\cal O}(n)\f$
|
---|
73 | *
|
---|
74 | * @param n nuclei to check
|
---|
75 | * @return true - is contained, false - is not contained
|
---|
76 | */
|
---|
77 | bool containsNuclei(const nucleus_t &n) const;
|
---|
78 |
|
---|
79 | /** Seeks through all nuclei and removes matching one if found.
|
---|
80 | *
|
---|
81 | * @param n nuclei to remove
|
---|
82 | */
|
---|
83 | void removeNuclei(const nucleus_t &n);
|
---|
84 |
|
---|
85 | private:
|
---|
86 | nuclei_t nuclei;
|
---|
87 | };
|
---|
88 |
|
---|
89 | template<typename T> T ZeroInstance();
|
---|
90 | template<> Fragment ZeroInstance<Fragment>();
|
---|
91 |
|
---|
92 | #endif /* FRAGMENT_HPP_ */
|
---|