Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/periodentafel.cpp

    • Property mode changed from 100755 to 100644
    rcc2ee5 r82cd9f  
    11/** \file periodentafel.cpp
    2  *
     2 * 
    33 * Function implementations for the class periodentafel.
    4  *
     4 * 
    55 */
    66
     
    1414 * Initialises start and end of list and resets periodentafel::checkliste to false.
    1515 */
    16 periodentafel::periodentafel()
    17 {
    18   start = new element;
    19   end = new element;
    20   start->previous = NULL;
    21   start->next = end;
    22   end->previous = start;
     16periodentafel::periodentafel() 
     17{ 
     18  start = new element; 
     19  end = new element; 
     20  start->previous = NULL; 
     21  start->next = end; 
     22  end->previous = start; 
    2323  end->next = NULL;
    2424};
     
    2727 * Removes every element and afterwards deletes start and end of list.
    2828 */
    29 periodentafel::~periodentafel()
    30 {
    31   CleanupPeriodtable();
    32   delete(end);
    33   delete(start);
    34 };
     29periodentafel::~periodentafel() 
     30{ 
     31  CleanupPeriodtable(); 
     32  delete(end); 
     33  delete(start); 
     34}; 
    3535
    3636/** Adds element to period table list
     
    3838 * \return true - succeeded, false - does not occur
    3939 */
    40 bool periodentafel::AddElement(element *pointer)
    41 {
     40bool periodentafel::AddElement(element *pointer) 
     41{ 
    4242  pointer->sort = &pointer->Z;
    4343  if (pointer->Z < 1 && pointer->Z >= MAX_ELEMENTS)
    4444    cout << Verbose(0) << "Invalid Z number!\n";
    45   return add(pointer, end);
     45  return add(pointer, end); 
    4646};
    4747
     
    5050 * \return true - succeeded, false - element not found
    5151 */
    52 bool periodentafel::RemoveElement(element *pointer)
    53 {
    54   return remove(pointer, start, end);
     52bool periodentafel::RemoveElement(element *pointer) 
     53{ 
     54  return remove(pointer, start, end); 
    5555};
    5656
     
    5858 * \return true - succeeded, false - does not occur
    5959 */
    60 bool periodentafel::CleanupPeriodtable()
    61 {
    62   return cleanup(start,end);
     60bool periodentafel::CleanupPeriodtable() 
     61{ 
     62  return cleanup(start,end); 
    6363};
    6464
     
    7676    cout << Verbose(0) << "Mass: " << endl;
    7777    cin >> walker->mass;
    78     walker->Z = Z;
    79     cout << Verbose(0) << "Atomic number: " << walker->Z << endl;
     78    walker->Z = Z; 
     79    cout << Verbose(0) << "Atomic number: " << walker->Z << endl; 
    8080    cout << Verbose(0) << "Name [max 64 chars]: " << endl;
    8181    cin >> walker->name;
     
    105105/** Asks for element number and returns pointer to element
    106106 */
    107 element * periodentafel::AskElement()
     107element * periodentafel::AskElement() 
    108108{
    109109  element *walker = NULL;
     
    117117};
    118118
     119
    119120/** Prints period table to given stream.
    120121 * \param output stream
    121  */
     122 */ 
    122123bool periodentafel::Output(ofstream *output) const
    123124{
     
    130131    }
    131132    return result;
    132   } else
     133  } else 
    133134    return false;
    134135};
     
    137138 * \param *output output stream
    138139 * \param *checkliste elements table for this molecule
    139  */
     140 */ 
    140141bool periodentafel::Checkout(ofstream *output, const int *checkliste) const
    141142{
     
    151152      if ((walker != NULL) && (walker->Z > 0) && (walker->Z < MAX_ELEMENTS) && (checkliste[walker->Z])) {
    152153        walker->No = No;
    153         result = result && walker->Checkout(output, No++, checkliste[walker->Z]);
     154        result = result && walker->Checkout(output, No++, checkliste[walker->Z]);     
    154155      }
    155156    }
    156157    return result;
    157   } else
     158  } else 
    158159    return false;
    159160};
     161
    160162
    161163/** Loads element list from file.
     
    169171  bool status = true;
    170172  bool otherstatus = true;
    171   char filename[255];
    172 
     173  char *filename = new char[MAXSTRINGSIZE];
     174 
    173175  // fill elements DB
    174176  strncpy(filename, path, MAXSTRINGSIZE);
     
    223225  if (infile != NULL) {
    224226    while (!infile.eof()) {
     227        infile >> tmp;
     228        infile >> ws;
     229        infile >> FindElement((int)tmp)->Valence;
     230        infile >> ws;
     231        //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl;
     232    }
     233    infile.close();
     234    infile.clear();
     235  } else
     236    otherstatus = false;
     237
     238  // fill valence DB per element
     239  strncpy(filename, path, MAXSTRINGSIZE);
     240  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     241  strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
     242  infile.open(filename);
     243  if (infile != NULL) {
     244    while (!infile.eof()) {
    225245      infile >> tmp;
    226246      infile >> ws;
    227       infile >> FindElement((int)tmp)->Valence;
    228       infile >> ws;
    229       //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl;
     247      infile >> FindElement((int)tmp)->NoValenceOrbitals;
     248      infile >> ws;
     249      //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
    230250    }
    231251    infile.close();
     
    233253  } else
    234254    otherstatus = false;
    235 
    236   // fill valence DB per element
    237   strncpy(filename, path, MAXSTRINGSIZE);
    238   strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
    239   strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
    240   infile.open(filename);
    241   if (infile != NULL) {
    242     while (!infile.eof()) {
    243       infile >> tmp;
    244       infile >> ws;
    245       infile >> FindElement((int)tmp)->NoValenceOrbitals;
    246       infile >> ws;
    247       //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
    248     }
    249     infile.close();
    250     infile.clear();
    251   } else
    252     otherstatus = false;
    253 
     255 
    254256  // fill H-BondDistance DB per element
    255257  strncpy(filename, path, MAXSTRINGSIZE);
     
    259261  if (infile != NULL) {
    260262    while (!infile.eof()) {
    261       infile >> tmp;
     263        infile >> tmp;
    262264      ptr = FindElement((int)tmp);
    263       infile >> ws;
     265        infile >> ws;
    264266      infile >> ptr->HBondDistance[0];
    265267      infile >> ptr->HBondDistance[1];
    266268      infile >> ptr->HBondDistance[2];
    267       infile >> ws;
     269        infile >> ws;
    268270      //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
    269271    }
     
    272274  } else
    273275    otherstatus = false;
    274 
     276 
    275277  // fill H-BondAngle DB per element
    276278  strncpy(filename, path, MAXSTRINGSIZE);
     
    292294  } else
    293295    otherstatus = false;
    294 
     296 
    295297  if (!otherstatus)
    296     cerr << "WARNING: Something went wrong while parsing the other databases!" << endl;
    297 
     298    cerr << "ERROR: Something went wrong while parsing the databases!" << endl;
     299 
    298300  return status;
    299301};
     
    306308  ofstream f;
    307309  char filename[MAXSTRINGSIZE];
    308 
     310 
    309311  strncpy(filename, path, MAXSTRINGSIZE);
    310312  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
Note: See TracChangeset for help on using the changeset viewer.