| 1 | /* | 
|---|
| 2 | * FragmentForces.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Oct 23, 2014 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef FRAGMENTFORCES_HPP_ | 
|---|
| 9 | #define FRAGMENTFORCES_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 | // include config.h | 
|---|
| 12 | #ifdef HAVE_CONFIG_H | 
|---|
| 13 | #include <config.h> | 
|---|
| 14 | #endif | 
|---|
| 15 |  | 
|---|
| 16 | #include <vector> | 
|---|
| 17 |  | 
|---|
| 18 | #include "boost/serialization/export.hpp" | 
|---|
| 19 | #include "boost/serialization/vector.hpp" | 
|---|
| 20 |  | 
|---|
| 21 | class FragmentForces : public std::vector< std::vector<double> > | 
|---|
| 22 | { | 
|---|
| 23 | //!> let ostream access private parts | 
|---|
| 24 | friend std::ostream & operator<<(std::ostream &ost, const FragmentForces &forces); | 
|---|
| 25 |  | 
|---|
| 26 | public: | 
|---|
| 27 | //!> typedef for a  vector with three components | 
|---|
| 28 | typedef std::vector<double> force_t; | 
|---|
| 29 | //!> typedef for a vector containing the force per fragment atom | 
|---|
| 30 | typedef std::vector<force_t> forces_t; | 
|---|
| 31 |  | 
|---|
| 32 | /** Default constructor for FragmentForces. | 
|---|
| 33 | * | 
|---|
| 34 | */ | 
|---|
| 35 | FragmentForces() {} | 
|---|
| 36 |  | 
|---|
| 37 | /** Equality operator. | 
|---|
| 38 | * | 
|---|
| 39 | * @param other other instance to check against | 
|---|
| 40 | * @return true - both are equal, false - some FragmentForces differ | 
|---|
| 41 | */ | 
|---|
| 42 | bool operator==(const FragmentForces& other) const; | 
|---|
| 43 |  | 
|---|
| 44 | bool operator!=(const FragmentForces& other) const | 
|---|
| 45 | { | 
|---|
| 46 | return (!(*this == other)); | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 | void operator+=(const FragmentForces& other); | 
|---|
| 50 |  | 
|---|
| 51 | private: | 
|---|
| 52 | friend class boost::serialization::access; | 
|---|
| 53 | // serialization | 
|---|
| 54 | template <typename Archive> | 
|---|
| 55 | void serialize(Archive& ar, const unsigned int version) | 
|---|
| 56 | { | 
|---|
| 57 | ar & boost::serialization::base_object<forces_t>(*this); | 
|---|
| 58 | } | 
|---|
| 59 | }; | 
|---|
| 60 |  | 
|---|
| 61 | /** Function to print eigenvalues to ostream. | 
|---|
| 62 | * | 
|---|
| 63 | * @param ost output stream | 
|---|
| 64 | * @param eigenvalues set of eigenvalues to print | 
|---|
| 65 | * @return ref to given ostream for concatenation | 
|---|
| 66 | */ | 
|---|
| 67 | std::ostream & operator<<(std::ostream &ost, const FragmentForces &forces); | 
|---|
| 68 |  | 
|---|
| 69 | // we need to give this class a unique key for serialization | 
|---|
| 70 | // its is only serialized through its base class FragmentJob | 
|---|
| 71 | BOOST_CLASS_EXPORT_KEY(FragmentForces) | 
|---|
| 72 |  | 
|---|
| 73 | #endif /* FRAGMENTFORCES_HPP_ */ | 
|---|