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;
00306
00308 const Atom* getSecondAtom() const;
00309
00317 Atom* getPartner(const Atom& atom) const;
00318
00320 void setName(const String& name);
00321
00323 const String& getName() const;
00324
00326 void setOrder(Order bond_order);
00327
00329 Order getOrder() const;
00330
00336 bool isAromatic() const;
00337
00339 void setType(Type bond_type);
00340
00342 Type getType() const;
00343
00348 float getLength() const throw(NotBound);
00349
00355 const Atom* getBoundAtom(const Atom& atom) const;
00356
00362 Atom* getBoundAtom(const Atom& atom);
00364
00368
00376 bool isBondOf(const Atom& atom) const;
00377
00383 bool isBound() const;
00384
00392 bool isInterBond() const;
00393
00402 bool isInterBondOf(const AtomContainer& atom_container) const;
00403
00412 bool isIntraBond() const;
00413
00422 bool isIntraBondOf(const AtomContainer& atom_container) const;
00423
00425
00429
00434 virtual bool isValid() const;
00435
00442 virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
00444
00445 protected:
00446
00450
00451
00452 Atom* first_;
00453
00454
00455 Atom* second_;
00456
00457
00458 String name_;
00459
00460
00461 Order bond_order_;
00462
00463
00464 Type bond_type_;
00466
00467 private:
00468
00469 void arrangeBonds_();
00470 void clear_();
00471 };
00472
00473 # ifndef BALL_NO_INLINE_FUNCTIONS
00474 # include <BALL/KERNEL/bond.iC>
00475 # endif
00476 }
00477
00478 #endif // BALL_KERNEL_BOND_H
00479