Changeset 8fc9b6
- Timestamp:
- Feb 2, 2010, 4:22:22 PM (16 years ago)
- Children:
- 4272f0
- Parents:
- f1ef9cc
- Location:
- molecuilder/src
- Files:
-
- 2 edited
-
Patterns/Observer.hpp (modified) (2 diffs)
-
molecule.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/Patterns/Observer.hpp
rf1ef9cc r8fc9b6 20 20 * Observation blocks from there, these functions wont trigger notifications. Only the end 21 21 * of the final observation block triggers the update of Observers. 22 * 23 * Returning from observed code should be done using the RETURN_OBSERVER() macro. This way the Observer mechanism 24 * is notified that the method is left. 22 25 * 23 26 * Each observerable can have sub-observables. When one of these sub-observables changes and … … 78 81 #define START_OBSERVER Observable::start_observer_internal(this);do{do{}while(0) 79 82 #define FINISH_OBSERVER }while(0);Observable::finish_observer_internal(this) 83 #define RETURN_OBSERVER( retval ) do{Observable::finish_observer_internal(this); return (retval);}while(0) 80 84 #endif /* OBSERVER_HPP_ */ -
molecuilder/src/molecule.cpp
rf1ef9cc r8fc9b6 103 103 bool molecule::AddAtom(atom *pointer) 104 104 { 105 bool retval = false; 106 START_OBSERVER; 105 107 if (pointer != NULL) { 106 108 pointer->sort = &pointer->nr; … … 119 121 } 120 122 } 121 return add(pointer, end); 122 } else 123 return false; 123 retval = add(pointer, end); 124 } 125 FINISH_OBSERVER; 126 return retval; 124 127 }; 125 128 … … 131 134 atom * molecule::AddCopyAtom(atom *pointer) 132 135 { 136 atom *retval = NULL; 137 START_OBSERVER; 133 138 if (pointer != NULL) { 134 139 atom *walker = new atom(pointer); … … 140 145 NoNonHydrogen++; 141 146 AtomCount++; 142 return walker; 143 } else 144 return NULL; 147 retval=walker; 148 } 149 FINISH_OBSERVER; 150 return retval; 145 151 }; 146 152 … … 181 187 bool molecule::AddHydrogenReplacementAtom(bond *TopBond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem) 182 188 { 189 bool AllWentWell = true; // flag gathering the boolean return value of molecule::AddAtom and other functions, as return value on exit 190 START_OBSERVER; 183 191 double bondlength; // bond length of the bond to be replaced/cut 184 192 double bondangle; // bond angle of the bond to be replaced/cut 185 193 double BondRescale; // rescale value for the hydrogen bond length 186 bool AllWentWell = true; // flag gathering the boolean return value of molecule::AddAtom and other functions, as return value on exit187 194 bond *FirstBond = NULL, *SecondBond = NULL; // Other bonds in double bond case to determine "other" plane 188 195 atom *FirstOtherAtom = NULL, *SecondOtherAtom = NULL, *ThirdOtherAtom = NULL; // pointer to hydrogen atoms to be added … … 228 235 if (BondRescale == -1) { 229 236 eLog() << Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl; 230 return false;237 RETURN_OBSERVER(false); 231 238 BondRescale = bondlength; 232 239 } else { … … 308 315 if (bondangle == -1) { 309 316 eLog() << Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl; 310 return false;317 RETURN_OBSERVER(false); 311 318 bondangle = 0; 312 319 } … … 435 442 Free(&matrix); 436 443 444 FINISH_OBSERVER; 437 445 // Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl; 438 446 return AllWentWell; … … 446 454 bool molecule::AddXYZFile(string filename) 447 455 { 456 448 457 istringstream *input = NULL; 449 458 int NumberOfAtoms = 0; // atom number in xyz read … … 459 468 return false; 460 469 470 START_OBSERVER; 461 471 getline(xyzfile,line,'\n'); // Read numer of atoms in file 462 472 input = new istringstream(line); … … 499 509 xyzfile.close(); 500 510 delete(input); 511 FINISH_OBSERVER; 501 512 return true; 502 513 };
Note:
See TracChangeset
for help on using the changeset viewer.
