source: src/Atom/CopyAtoms/CopyAtomsInterface.hpp

Candidate_v1.6.1
Last change on this file was aa91de0, checked in by Frederik Heber <frederik.heber@…>, 8 years ago

FIX: size_t definition missing and other fixes.

  • cstddef defines both size_t and NULL.
  • also string include missing.
  • this is in preparation for removing MemDebug include.
  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 * CopyAtomsInterface.hpp
3 *
4 * Created on: Mar 17, 2012
5 * Author: heber
6 */
7
8#ifndef COPYATOMSINTERFACE_HPP_
9#define COPYATOMSINTERFACE_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <cstddef>
17#include <vector>
18
19class atom;
20class CopyAtomsInterfaceTest;
21
22/** This class defines a general interface for functors that copy a Vector of Atoms.
23 *
24 * I.e. we can implement here multiple ways of copying a vector of atoms, with or
25 * without bonds, with or without saturation, ...
26 *
27 */
28class CopyAtomsInterface
29{
30 /// grant unit test access
31 friend class CopyAtomsInterfaceTest;
32public:
33 typedef std::vector<atom*> AtomVector;
34 typedef std::vector<const atom*> ConstAtomVector;
35
36 /** Constructor.
37 *
38 */
39 CopyAtomsInterface()
40 {}
41
42 /** Destructor.
43 *
44 */
45 virtual ~CopyAtomsInterface()
46 {}
47
48 /** Function that just stores given atoms in CopyAtomsInterface::OriginalAtoms.
49 *
50 * We reset ourselves.
51 * We initialize CopyAtomsInterface::CopiedAtoms with the size of \a _atoms
52 * but NULL entities.
53 *
54 * \note If you override this function, always first call the implementation
55 * in the original class, then continue with implementation in derived class.
56 *
57 * @param _atoms atoms to copy
58 */
59 virtual void operator()(const AtomVector &_atoms)
60 {
61 // clear ourselves
62 reset();
63 CopiedAtoms.resize(_atoms.size(), NULL);
64 }
65
66 /** Getter for CopiedAtoms to allow outside transformations.
67 *
68 * @return CopiedAtoms
69 */
70 AtomVector& getCopiedAtoms() {
71 return CopiedAtoms;
72 }
73
74private:
75 /// forbid copy cstor as it may change class behavior
76 CopyAtomsInterface(const CopyAtomsInterface &);
77
78 /** Internal helper to reset all member variables.
79 *
80 */
81 void reset()
82 {
83 CopiedAtoms.clear();
84 }
85
86protected:
87 //!> set of copied atoms, this is to allow later transformations in derived classes
88 AtomVector CopiedAtoms;
89};
90
91#endif /* COPYATOMSINTERFACE_HPP_ */
Note: See TracBrowser for help on using the repository browser.