Victor
 All Data Structures Functions Variables Friends Pages
Bond.h
1 /* This file is part of Victor.
2 
3  Victor is free software: you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation, either version 3 of the License, or
6  (at your option) any later version.
7 
8  Victor is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with Victor. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 
18 #ifndef _BOND_H_
19 #define _BOND_H_
20 
21 // Includes:
22 #include <algorithm>
23 #include <vector>
24 #include <SimpleBond.h>
25 #include <Atom.h>
26 
27 namespace Victor { namespace Biopool {
28  class Atom;
29 
35  // Global constants, typedefs, etc. (to avoid):
36 
37  class Bond : public SimpleBond {
38  public:
39 
40  // CONSTRUCTORS/DESTRUCTOR:
41  Bond(unsigned int mI = 1, unsigned int mO = 1);
42  Bond(const Bond& orig);
43  virtual ~Bond();
44 
45  // PREDICATES:
46  virtual const Atom& getInBondRef(unsigned int n) const;
47  virtual Atom& getInBondRef(unsigned int n);
48  virtual const Atom& getOutBondRef(unsigned int n) const;
49  virtual Atom& getOutBondRef(unsigned int n);
50 
51  virtual const Atom& getOpenInBondRef(unsigned int n = 0) const;
52  virtual Atom& getOpenInBondRef(unsigned int n = 0);
53  virtual const Atom& getOpenOutBondRef(unsigned int n = 0) const;
54  virtual Atom& getOpenOutBondRef(unsigned int n = 0);
55 
56  unsigned int sizeOpenInBonds() const;
57  unsigned int sizeOpenOutBonds() const;
58 
59  // MODIFIERS:
60  void copy(const Bond& orig);
61 
62  virtual void bindIn(Atom& _this, Bond& c, Atom& _other);
63  virtual void bindOut(Atom& _this, Bond& c, Atom& _other);
64 
65  virtual void unbindIn(Bond& c);
66  virtual void unbindOut(Bond& c);
67 
68  // OPERATORS:
69 
70  protected:
71 
72  private:
73 
74  // HELPERS:
75  virtual void pUnbindIn(Bond& c, bool unbind = false);
76  virtual void pUnbindOut(Bond& c, bool unbind = false);
77 
78  // ATTRIBUTES:
79  vector<Atom*> inRef, outRef;
80  // reference to the atom containg the in- and out-bonds
81 
82  };
83 
84 
85  // ---------------------------------------------------------------------------
86  // Bond
87  // -----------------x-------------------x-------------------x-----------------
88 
89  // PREDICATES:
90 
96  inline Atom&
97  Bond::getInBondRef(unsigned int n) {
98  PRECOND(n < inRef.size(), exception);
99  return *inRef[n];
100  }
101 
102  inline const Atom&
103  Bond::getInBondRef(unsigned int n) const {
104  PRECOND(n < inRef.size(), exception);
105  return *inRef[n];
106  }
107 
113  inline Atom&
114  Bond::getOutBondRef(unsigned int n) {
115  PRECOND(n < outRef.size(), exception);
116  return *outRef[n];
117  }
118 
119  inline const Atom&
120  Bond::getOutBondRef(unsigned int n) const {
121  PRECOND(n < outRef.size(), exception);
122  return *outRef[n];
123  }
124 
130  inline unsigned int
132  return (getMaxInBonds() - sizeInBonds());
133  }
134 
140  inline unsigned int Bond::sizeOpenOutBonds() const {
141  return (getMaxOutBonds() - sizeOutBonds());
142  }
143 
144 
145  // MODIFIERS:
146 
147  // OPERATORS:
148 
149 }} //namespace
150 #endif //_BOND_H_
151 
152 
unsigned int getMaxInBonds() const
Definition: SimpleBond.h:193
Defines chemical and abstract bonds between objects which are compositions of atoms.
Definition: Bond.h:37
virtual void bindIn(Atom &_this, Bond &c, Atom &_other)
Definition: Bond.cc:92
Defines chemical and abstract bonds between objects. eg.: covalent bonds. Attention: copy() strips or...
Definition: SimpleBond.h:39
virtual void unbindOut(Bond &c)
Definition: Bond.cc:150
unsigned int sizeInBonds() const
Definition: SimpleBond.h:146
virtual void bindOut(Atom &_this, Bond &c, Atom &_other)
Definition: Bond.cc:116
unsigned int sizeOutBonds() const
Definition: SimpleBond.h:153
void copy(const Bond &orig)
Definition: Bond.cc:232
unsigned int sizeOpenInBonds() const
Definition: Bond.h:131
unsigned int sizeOpenOutBonds() const
Definition: Bond.h:140
Implements a simple atom type.
Definition: Atom.h:39
virtual void unbindIn(Bond &c)
Definition: Bond.cc:139
unsigned int getMaxOutBonds() const
Definition: SimpleBond.h:200