Simpatico  v1.10
Link.h
1 #ifdef MCMD_LINK
2 #ifndef MCMD_LINK_H
3 #define MCMD_LINK_H
4 
5 /*
6 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
7 *
8 * Copyright 2010 - 2017, Veronica Chappa and The Regents of the University of Minnesota
9 * Distributed under the terms of the GNU General Public License.
10 */
11 
12 #include <mcMd/chemistry/Atom.h>
13 
14 namespace McMd
15 {
16 
17  using namespace Util;
18 
19  //class Atom;
20 
30  class Link
31  {
32 
33  public:
34 
38  Link();
39 
43  const Atom& atom0() const;
44 
48  Atom& atom0();
49 
53  const Atom& atom1() const;
54 
58  Atom& atom1();
59 
63  int typeId() const;
64 
68  int tag() const;
69 
73  bool isActive() const;
74 
80  void setIsActive(bool isActive);
81 
82  private:
83 
85  Atom* atom0Ptr_;
86  Atom* atom1Ptr_;
87 
89  int typeId_;
90 
92  int tag_;
93 
95  bool isActive_;
96 
103  void setAtoms(Atom &atom0, Atom &atom1);
104 
110  void setTypeId(int typeId);
111 
120  void setTag(int tag);
121 
125  void clear();
126 
127  //friends:
128 
129  friend class LinkMaster;
130 
131  };
132 
133  // Inline method definitions
134 
135  /*
136  * Constructor.
137  */
138  inline Link::Link()
139  : atom0Ptr_(0),
140  atom1Ptr_(0),
141  typeId_(-1),
142  isActive_(false)
143  {}
144 
145  /*
146  * Add the two atoms to the Link.
147  */
148  inline void Link::setAtoms(Atom &atom0, Atom &atom1)
149  {
150  if (&atom0 != &atom1) {
151  atom0Ptr_ = &atom0;
152  atom1Ptr_ = &atom1;
153  }
154  }
155 
156  /*
157  * Get a const reference to atom0.
158  */
159  inline const Atom& Link::atom0() const
160  { return *atom0Ptr_; }
161 
162  /*
163  * Get atom0.
164  */
165  inline Atom& Link::atom0()
166  { return *atom0Ptr_; }
167 
168  /*
169  * Get a const referencen to atom1.
170  */
171  inline const Atom& Link::atom1() const
172  { return *atom1Ptr_; }
173 
174  /*
175  * Get atom1.
176  */
177  inline Atom& Link::atom1()
178  { return *atom1Ptr_; }
179 
180  /*
181  * Set the type id for this Link.
182  */
183  inline void Link::setTypeId(int typeId)
184  { typeId_ = typeId; }
185 
186  /*
187  * Get the typeId for this Link.
188  */
189  inline int Link::typeId() const
190  { return typeId_; }
191 
192  /*
193  * Is this Link active?
194  */
195  inline bool Link::isActive() const
196  { return isActive_; }
197 
198  /*
199  * Activate or deactivate the Link.
200  */
201  inline void Link::setIsActive(bool isActive)
202  { isActive_ = isActive; }
203 
204  /*
205  * Set a permanent identifier for this Link.
206  */
207  inline void Link::setTag(int tag)
208  { tag_ = tag; }
209 
210  /*
211  * Get a permanent integer identifier for this object.
212  */
213  inline int Link::tag() const
214  { return tag_; }
215 
216  /*
217  * Nullify pointers, set typeId to -1 and isActive to false.
218  */
219  inline void Link::clear()
220  {
221  atom0Ptr_ = 0;
222  atom1Ptr_ = 0;
223  typeId_ =-1;
224  isActive_ = false;
225  }
226 
227 }
228 #endif
229 #endif
A point particle within a Molecule.
Utility classes for scientific computation.
Definition: accumulators.mod:1
Manages all Link objects in a System.
Definition: LinkMaster.h:39
Single-processor Monte Carlo (MC) and molecular dynamics (MD).