00001
00002
00003
00004
00005
00006
00007 #ifndef BALL_KERNEL_BOND_H
00008 #define BALL_KERNEL_BOND_H
00009
00010 #ifndef BALL_CONCEPT_PROPERTY_H
00011 # include <BALL/CONCEPT/property.h>
00012 #endif
00013
00014 #ifndef BALL_CONCEPT_COMPOSITE_H
00015 # include <BALL/CONCEPT/composite.h>
00016 #endif
00017
00018 #ifndef BALL_CONCEPT_ATOMCONTAINER_H
00019 # include <BALL/KERNEL/atomContainer.h>
00020 #endif
00021
00022 #define BALL_BOND_DEFAULT_FIRST_ATOM 0
00023 #define BALL_BOND_DEFAULT_SECOND_ATOM 0
00024 #define BALL_BOND_DEFAULT_NAME ""
00025 #define BALL_BOND_DEFAULT_ORDER ORDER__UNKNOWN
00026 #define BALL_BOND_DEFAULT_TYPE TYPE__UNKNOWN
00027
00028
00029 namespace BALL
00030 {
00031 class Atom;
00032 class Fragment;
00033 class System;
00034
00056 class BALL_EXPORT Bond
00057 : public Composite,
00058 public PropertyManager
00059 {
00060 public:
00061
00063 friend class Atom;
00064
00065 BALL_CREATE_DEEP(Bond)
00066
00067
00070
00074 class BALL_EXPORT NotBound
00075 : public Exception::GeneralException
00076 {
00077 public:
00078 NotBound(const char* file, int line);
00079 };
00081
00085
00088 typedef short Order;
00089 typedef short Type;
00090
00092
00095
00098 enum BondOrder
00099 {
00101 ORDER__UNKNOWN = 0,
00103 ORDER__SINGLE = 1,
00105 ORDER__DOUBLE = 2,
00107 ORDER__TRIPLE = 3,
00109 ORDER__QUADRUPLE = 4,
00111 ORDER__AROMATIC = 5,
00113 ORDER__ANY = 6,
00115 NUMBER_OF_BOND_ORDERS
00116 };
00117
00122 enum BondType
00123 {
00125 TYPE__UNKNOWN = 0,
00127 TYPE__COVALENT = 1,
00129 TYPE__HYDROGEN = 2,
00131 TYPE__DISULPHIDE_BRIDGE = 3,
00133 TYPE__SALT_BRIDGE = 4,
00135 TYPE__PEPTIDE = 5,
00137 NUMBER_OF_BOND_TYPES
00138 };
00139
00143 enum Property
00144 {
00146 IS_AROMATIC = 0,
00148 NUMBER_OF_PROPERTIES
00149 };
00151
00155
00166 Bond();
00167
00179 Bond(const Bond& bond, bool deep = true);
00180
00190 Bond(const String& name, Atom& first, Atom& second, Order order = BALL_BOND_DEFAULT_ORDER,
00191 Type type = BALL_BOND_DEFAULT_TYPE)
00192 throw(Exception::TooManyBonds);
00193
00203 static Bond* createBond(Bond& bond, Atom& first, Atom& second)
00204 throw(Exception::TooManyBonds);
00205
00209 virtual ~Bond();
00210
00221 virtual void clear();
00222
00230 virtual void destroy();
00232
00236
00240 void persistentWrite(PersistenceManager& pm, const char* name = 0) const
00241 throw(Exception::GeneralException);
00242
00246 void persistentRead(PersistenceManager& pm)
00247 throw(Exception::GeneralException);
00248
00253 void finalize()
00254 throw(Exception::GeneralException);
00256
00260
00261 bool operator == (const Bond& bond) const;
00262
00264 bool operator != (const Bond& bond) const;
00266
00270
00280 Bond& operator = (const Bond& bond);
00281
00286 void swap(Bond& bond);
00288
00292
00297 void setFirstAtom(Atom* atom);
00302 void setSecondAtom(Atom* atom);
00303
00305 const Atom* getFirstAtom() const;
00307 Atom* getFirstAtom();
00308
00310 const Atom* getSecondAtom() const;
00312 Atom* getSecondAtom();
00313
00321 Atom* getPartner(const Atom& atom) const;
00322
00324 void setName(const String& name);
00325
00327 const String& getName() const;
00328
00330 void setOrder(Order bond_order);
00331
00333 Order getOrder() const;
00334
00340 bool isAromatic() const;
00341
00343 void setType(Type bond_type);
00344
00346 Type getType() const;
00347
00352 float getLength() const throw(NotBound);
00353
00359 const Atom* getBoundAtom(const Atom& atom) const;
00360
00366 Atom* getBoundAtom(const Atom& atom);
00368
00372
00380 bool isBondOf(const Atom& atom) const;
00381
00387 bool isBound() const;
00388
00396 bool isInterBond() const;
00397
00406 bool isInterBondOf(const AtomContainer& atom_container) const;
00407
00416 bool isIntraBond() const;
00417
00426 bool isIntraBondOf(const AtomContainer& atom_container) const;
00427
00429
00433
00438 virtual bool isValid() const;
00439
00446 virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
00448
00449 protected:
00450
00454
00455
00456 Atom* first_;
00457
00458
00459 Atom* second_;
00460
00461
00462 String name_;
00463
00464
00465 Order bond_order_;
00466
00467
00468 Type bond_type_;
00470
00471 private:
00472
00473 void arrangeBonds_();
00474 void clear_();
00475 };
00476
00477 # ifndef BALL_NO_INLINE_FUNCTIONS
00478 # include <BALL/KERNEL/bond.iC>
00479 # endif
00480 }
00481
00482 #endif // BALL_KERNEL_BOND_H
00483