Ignore:
Timestamp:
Oct 7, 2009, 2:29:57 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
17b3a5c
Parents:
972706
git-author:
Frederik Heber <heber@…> (10/07/09 14:26:53)
git-committer:
Frederik Heber <heber@…> (10/07/09 14:29:57)
Message:

used forward declaration to untangle atom and bond declarations, molecule::CreateListOfBondsPerAtom() uses ActOnAllAtoms

  • a major problem is two classes depending on one another and we've often made constraints in order to accommodate for this. But there is an easier solution: Have forward declarations of the other class in each header file, only include the true other header file in each implementation (i.e. cpp file).
  • This was done with atom and bond class to allow for a new function atom::OutputBondOfAtom()
  • molecule::CreateListOfBondsPerAtom() uses ActOnAllAtoms with this new function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/atom.cpp

    r972706 r70b7aa  
    66
    77#include "atom.hpp"
     8#include "bond.hpp"
    89#include "memoryallocator.hpp"
    910
     
    120121 * \param *out stream to output to
    121122 * \param *comment commentary after '#' sign
     123  * \return true - \a *out present, false - \a *out is NULL
    122124 */
    123125bool atom::Output(ofstream *out, int ElementNo, int AtomNo, const char *comment) const
     
    157159/** Output of a single atom as one lin in xyz file.
    158160 * \param *out stream to output to
     161  * \return true - \a *out present, false - \a *out is NULL
    159162 */
    160163bool atom::OutputXYZLine(ofstream *out) const
     
    169172/** Output of a single atom as one lin in xyz file.
    170173 * \param *out stream to output to
     174 * \param *ElementNo array with ion type number in the config file this atom's element shall have
     175 * \param *AtomNo array with atom number in the config file this atom shall have, is increase by one automatically
     176 * \param step Trajectory time step to output
     177  * \return true - \a *out present, false - \a *out is NULL
    171178 */
    172179bool atom::OutputTrajectory(ofstream *out, int *ElementNo, int *AtomNo, int step) const
     
    189196/** Output of a single atom as one lin in xyz file.
    190197 * \param *out stream to output to
     198 * \param step Trajectory time step to output
     199 * \return true - \a *out present, false - \a *out is NULL
    191200 */
    192201bool atom::OutputTrajectoryXYZ(ofstream *out, int step) const
     
    202211};
    203212
     213/** Prints all bonds of this atom from given global lists.
     214 * \param *out stream to output to
     215 * \param *NumberOfBondsPerAtom array with number of bonds per atomic index
     216 * \param ***ListOfBondsPerAtom array per atomic index of array with pointer to bond
     217 * \return true - \a *out present, false - \a *out is NULL
     218 */
     219bool atom::OutputBondOfAtom(ofstream *out, int *NumberOfBondsPerAtom, bond ***ListOfBondsPerAtom) const
     220{
     221  if (out != NULL) {
     222    *out << Verbose(4) << "Atom " << Name << "/" << nr << " with " << NumberOfBondsPerAtom[nr] << " bonds: ";
     223    int TotalDegree = 0;
     224    for (int j=0;j<NumberOfBondsPerAtom[nr];j++) {
     225      *out << *ListOfBondsPerAtom[nr][j] << "\t";
     226      TotalDegree += ListOfBondsPerAtom[nr][j]->BondDegree;
     227    }
     228    *out << " -- TotalDegree: " << TotalDegree << endl;
     229    return true;
     230  } else
     231    return false;
     232};
     233
    204234ostream & operator << (ostream &ost, const atom &a)
    205235{
Note: See TracChangeset for help on using the changeset viewer.