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 <iosfwd>
|
---|
18 | #include <vector>
|
---|
19 |
|
---|
20 | class Fragment {
|
---|
21 | //!> grant ostream operator access
|
---|
22 | friend std::ostream & operator<<(std::ostream &ost, const Fragment &f);
|
---|
23 | public:
|
---|
24 | typedef std::vector< std::vector<double> > positions_t;
|
---|
25 | typedef std::vector< double > charges_t;
|
---|
26 | typedef std::pair< std::vector<double>, double> nucleus_t;
|
---|
27 | typedef std::vector< nucleus_t > nuclei_t;
|
---|
28 |
|
---|
29 | /** Default constructor of class Fragment.
|
---|
30 | *
|
---|
31 | */
|
---|
32 | Fragment();
|
---|
33 |
|
---|
34 | /** Default constructor of class Fragment.
|
---|
35 | *
|
---|
36 | */
|
---|
37 | Fragment(const nuclei_t &_nuclei) :
|
---|
38 | nuclei(_nuclei)
|
---|
39 | {}
|
---|
40 |
|
---|
41 | /** Constructor of class Fragment.
|
---|
42 | *
|
---|
43 | * @param _positions given positions
|
---|
44 | * @param _charges given charges
|
---|
45 | */
|
---|
46 | Fragment(const std::vector< std::vector<double> > &_positions, const std::vector< double > &_charges);
|
---|
47 |
|
---|
48 | /** Adding another fragment onto this one.
|
---|
49 | *
|
---|
50 | * \note The operation is area-conserving, i.e. the new area is the sum of
|
---|
51 | * both areas.
|
---|
52 | *
|
---|
53 | * @param other other fragment
|
---|
54 | * @return ref to this instance
|
---|
55 | */
|
---|
56 | Fragment& operator+=(const Fragment &other);
|
---|
57 |
|
---|
58 | /** Assignment operator.
|
---|
59 | *
|
---|
60 | * @param other other fragment to make ourselves equal to
|
---|
61 | * @return ref to this instance
|
---|
62 | */
|
---|
63 | Fragment& operator=(const Fragment &other);
|
---|
64 |
|
---|
65 | /** Subtracting another fragment from this one.
|
---|
66 | *
|
---|
67 | * @param other other fragment
|
---|
68 | * @return ref to this instance
|
---|
69 | */
|
---|
70 | Fragment& operator-=(const Fragment &other);
|
---|
71 |
|
---|
72 | /** Getter for all stored positions.
|
---|
73 | *
|
---|
74 | * @return vector of positions
|
---|
75 | */
|
---|
76 | positions_t getPositions() const;
|
---|
77 |
|
---|
78 | /** Getter for all stored charges.
|
---|
79 | *
|
---|
80 | * @return vector of charges
|
---|
81 | */
|
---|
82 | charges_t getCharges() const;
|
---|
83 |
|
---|
84 | private:
|
---|
85 | /** Helper function that checks whether this nuclei is present.
|
---|
86 | *
|
---|
87 | * This operation is \f${\cal O}(n)\f$
|
---|
88 | *
|
---|
89 | * @param n nuclei to check
|
---|
90 | * @return true - is contained, false - is not contained
|
---|
91 | */
|
---|
92 | bool containsNuclei(const nucleus_t &n) const;
|
---|
93 |
|
---|
94 | /** Seeks through all nuclei and removes matching one if found.
|
---|
95 | *
|
---|
96 | * @param n nuclei to remove
|
---|
97 | */
|
---|
98 | void removeNuclei(const nucleus_t &n);
|
---|
99 |
|
---|
100 | private:
|
---|
101 | nuclei_t nuclei;
|
---|
102 | };
|
---|
103 |
|
---|
104 | std::ostream & operator<<(std::ostream &ost, const Fragment &f);
|
---|
105 |
|
---|
106 | template<typename T> T ZeroInstance();
|
---|
107 | template<> Fragment ZeroInstance<Fragment>();
|
---|
108 |
|
---|
109 | #endif /* FRAGMENT_HPP_ */
|
---|