source: src/periodentafel.cpp@ 39fa96

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 39fa96 was b60804, checked in by Frederik Heber <heber@…>, 13 years ago

Added serialization to class periodentafel.

  • added unit test on comparison and serialization.
  • FIX: removed inclusion of PeriodentafelUnitTest.hpp in periodentafel.hpp as forward declaration is sufficient.
  • ComparisonTest and fix of operator==() for class periodentafel.
  • Property mode set to 100755
File size: 19.0 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/** \file periodentafel.cpp
9 *
10 * Function implementations for the class periodentafel.
11 *
12 */
13
14// include config.h
15#ifdef HAVE_CONFIG_H
16#include <config.h>
17#endif
18
19#include "CodePatterns/MemDebug.hpp"
20
21#include <iomanip>
22#include <iostream>
23#include <fstream>
24#include <cstring>
25
26#include "CodePatterns/Assert.hpp"
27#include "element.hpp"
28#include "elements_db.hpp"
29#include "CodePatterns/Log.hpp"
30#include "periodentafel.hpp"
31#include "CodePatterns/Verbose.hpp"
32
33using namespace std;
34
35/************************************* Functions for class periodentafel ***************************/
36
37/** constructor for class periodentafel
38 * Initialises start and end of list and resets periodentafel::checkliste to false.
39 */
40periodentafel::periodentafel()
41{
42 {
43 stringstream input(elementsDB,ios_base::in);
44#ifndef NDEBUG
45 bool status =
46#endif
47 LoadElementsDatabase(input);
48 ASSERT(status, "General element initialization failed");
49 }
50 {
51 stringstream input(ElectronegativitiesDB,ios_base::in);
52#ifndef NDEBUG
53 bool status =
54#endif
55 LoadElectronegativityDatabase(input);
56 ASSERT(status, "Electronegativities entry of element initialization failed");
57 }
58 {
59 stringstream input(valenceDB,ios_base::in);
60#ifndef NDEBUG
61 bool status =
62#endif
63 LoadValenceDatabase(input);
64 ASSERT(status, "Valence entry of element initialization failed");
65 }
66 {
67 stringstream input(orbitalsDB,ios_base::in);
68#ifndef NDEBUG
69 bool status =
70#endif
71 LoadOrbitalsDatabase(input);
72 ASSERT(status, "Orbitals entry of element initialization failed");
73 }
74 {
75 stringstream input(HbondangleDB,ios_base::in);
76#ifndef NDEBUG
77 bool status =
78#endif
79 LoadHBondAngleDatabase(input);
80 ASSERT(status, "HBond angle entry of element initialization failed");
81 }
82 {
83 stringstream input(HbonddistanceDB,ios_base::in);
84#ifndef NDEBUG
85 bool status =
86#endif
87 LoadHBondLengthsDatabase(input);
88 ASSERT(status, "HBond distance entry of element initialization failed");
89 }
90 {
91 stringstream input(ColorDB,ios_base::in);
92#ifndef NDEBUG
93 bool status =
94#endif
95 LoadColorDatabase(input);
96 ASSERT(status, "color entry of element initialization failed");
97 }
98};
99
100/** destructor for class periodentafel
101 * Removes every element and afterwards deletes start and end of list.
102 * TODO: Handle when elements have changed and store databases then
103 */
104periodentafel::~periodentafel()
105{
106 CleanupPeriodtable();
107};
108
109/** Adds element to period table list
110 * \param *pointer element to be added
111 * \return iterator to added element
112 */
113periodentafel::iterator periodentafel::AddElement(element * pointer)
114{
115 atomicNumber_t Z = pointer->getNumber();
116 ASSERT(!elements.count(Z), "Element is already present.");
117 if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS)
118 DoeLog(0) && (eLog() << Verbose(0) << "Invalid Z number!\n");
119 pair<iterator,bool> res = elements.insert(pair<atomicNumber_t,element*>(Z,pointer));
120 return res.first;
121};
122
123/** Removes element from list.
124 * \param *pointer element to be removed
125 */
126size_t periodentafel::RemoveElement(const element * pointer)
127{
128 return RemoveElement(pointer->getNumber());
129};
130
131/** Removes element from list.
132 * \param Z element to be removed
133 */
134size_t periodentafel::RemoveElement(atomicNumber_t Z)
135{
136 return elements.erase(Z);
137};
138
139/** Removes every element from the period table.
140 */
141void periodentafel::CleanupPeriodtable()
142{
143 for(iterator iter=elements.begin();iter!=elements.end();++iter){
144 delete(*iter).second;
145 }
146 elements.clear();
147};
148
149/** Finds an element by its atomic number.
150 * If element is not yet in list, returns NULL.
151 * \param Z atomic number
152 * \return pointer to element or NULL if not found
153 */
154const element * periodentafel::FindElement(atomicNumber_t Z) const
155{
156 const_iterator res = elements.find(Z);
157 return res!=elements.end()?((*res).second):0;
158};
159
160/** Finds an element by its atomic number.
161 * If element is not yet in list, datas are asked and stored in database.
162 * \param shorthand chemical symbol of the element, e.g. H for hydrogene
163 * \return pointer to element
164 */
165const element * periodentafel::FindElement(const string &shorthand) const
166{
167 element *res = 0;
168 for(const_iterator iter=elements.begin();iter!=elements.end();++iter) {
169 if((*iter).second->getSymbol() == shorthand){
170 res = (*iter).second;
171 break;
172 }
173 }
174 return res;
175};
176
177/** Asks for element number and returns pointer to element
178 * \return desired element or NULL
179 */
180const element * periodentafel::AskElement() const
181{
182 const element * walker = NULL;
183 int Z;
184 do {
185 DoLog(0) && (Log() << Verbose(0) << "Atomic number Z: ");
186 cin >> Z;
187 walker = this->FindElement(Z); // give type
188 } while (walker == NULL);
189 return walker;
190};
191
192/** Asks for element and if not found, presents mask to enter info.
193 * \return pointer to either present or newly created element
194 */
195const element * periodentafel::EnterElement()
196{
197 atomicNumber_t Z = 0;
198 DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
199 cin >> Z;
200 const element *res = FindElement(Z);
201 if (!res) {
202 // TODO: make this using the constructor
203 DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl);
204 element *tmp = new element;
205 tmp->Z = Z;
206 DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl);
207 cin >> tmp->mass;
208 DoLog(0) && (Log() << Verbose(0) << "Name [max 64 chars]: " << endl);
209 cin >> tmp->name;
210 DoLog(0) && (Log() << Verbose(0) << "Short form [max 3 chars]: " << endl);
211 cin >> tmp->symbol;
212 AddElement(tmp);
213 return tmp;
214 }
215 return res;
216};
217
218
219/******************** Access to iterators ****************************/
220periodentafel::const_iterator periodentafel::begin() const{
221 return elements.begin();
222}
223
224periodentafel::const_iterator periodentafel::end() const{
225 return elements.end();
226}
227
228periodentafel::reverse_iterator periodentafel::rbegin() const{
229 return reverse_iterator(elements.end());
230}
231
232periodentafel::reverse_iterator periodentafel::rend() const{
233 return reverse_iterator(elements.begin());
234}
235
236/** Prints period table to given stream.
237 * \param output stream
238 */
239bool periodentafel::Output(ostream * const output) const
240{
241 bool result = true;
242 if (output != NULL) {
243 for(const_iterator iter=elements.begin(); iter !=elements.end();++iter){
244 result = result && (*iter).second->Output(output);
245 }
246 return result;
247 } else
248 return false;
249};
250
251/** Loads element list from file.
252 * \param *path to to standard file names
253 */
254bool periodentafel::LoadPeriodentafel(const char *path)
255{
256 ifstream input;
257 bool status = true;
258 bool otherstatus = true;
259 char filename[255];
260
261 // fill elements DB
262 strncpy(filename, path, MAXSTRINGSIZE);
263 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
264 strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
265 input.open(filename);
266 if (!input.fail())
267 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as elements database." << endl);
268 status = status && LoadElementsDatabase(input);
269 input.close();
270 input.clear();
271
272 // fill valence DB per element
273 strncpy(filename, path, MAXSTRINGSIZE);
274 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
275 strncat(filename, STANDARDELECTRONEGATIVITYDB, MAXSTRINGSIZE-strlen(filename));
276 input.open(filename);
277 if (!input.fail())
278 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as electronegativity database." << endl);
279 otherstatus = otherstatus && LoadElectronegativityDatabase(input);
280 input.close();
281 input.clear();
282
283 // fill valence DB per element
284 strncpy(filename, path, MAXSTRINGSIZE);
285 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
286 strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename));
287 input.open(filename);
288 if (!input.fail())
289 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as valence database." << endl);
290 otherstatus = otherstatus && LoadValenceDatabase(input);
291 input.close();
292 input.clear();
293
294 // fill orbitals DB per element
295 strncpy(filename, path, MAXSTRINGSIZE);
296 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
297 strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
298 input.open(filename);
299 if (!input.fail())
300 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as orbitals database." << endl);
301 otherstatus = otherstatus && LoadOrbitalsDatabase(input);
302 input.close();
303 input.clear();
304
305 // fill H-BondAngle DB per element
306 strncpy(filename, path, MAXSTRINGSIZE);
307 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
308 strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename));
309 input.open(filename);
310 if (!input.fail())
311 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond angle database." << endl);
312 otherstatus = otherstatus && LoadHBondAngleDatabase(input);
313 input.close();
314 input.clear();
315
316 // fill H-BondDistance DB per element
317 strncpy(filename, path, MAXSTRINGSIZE);
318 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
319 strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename));
320 input.open(filename);
321 if (!input.fail())
322 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond length database." << endl);
323 otherstatus = otherstatus && LoadHBondLengthsDatabase(input);
324 input.close();
325 input.clear();
326
327 if (!otherstatus){
328 DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
329 }
330
331 return status;
332};
333
334/** load the element info.
335 * \param *input stream to parse from
336 * \return true - parsing successful, false - something went wrong
337 */
338bool periodentafel::LoadElementsDatabase(istream &input)
339{
340 bool status = true;
341 string header1tmp,header2tmp;
342 // first parse into a map, so we can revert to old status in case something goes wront
343 map<atomicNumber_t,element*> parsedElements;
344 if (!input.fail()) {
345 getline(input,header1tmp);
346 getline(input,header2tmp); // skip first two header lines
347 //cout << "First header: " << header1tmp << endl;
348 //cout << "Second header: " << header2tmp << endl;
349// DoLog(0) && (Log() << Verbose(0) << "Parsed elements:");
350 while (!input.eof()) {
351 element *neues = new element;
352 input >> neues->name;
353 //input >> ws;
354 input >> neues->symbol;
355 //input >> ws;
356 input >> neues->period;
357 //input >> ws;
358 input >> neues->group;
359 //input >> ws;
360 input >> neues->block;
361 //input >> ws;
362 input >> neues->Z;
363 //input >> ws;
364 input >> neues->mass;
365 //input >> ws;
366 input >> neues->CovalentRadius;
367 //input >> ws;
368 input >> neues->VanDerWaalsRadius;
369 //input >> ws;
370 input >> ws;
371 //neues->Output((ofstream *)&cout);
372 if ((neues->getNumber() > 0) && (neues->getNumber() < MAX_ELEMENTS)) {
373 parsedElements[neues->Z] = neues;
374// DoLog(0) && (Log() << Verbose(0) << " " << *neues);
375 } else {
376 DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl);
377 DoLog(0) && (Log() << Verbose(0) << " <?>");
378 delete(neues);
379 }
380 // when the input is in failed state, we most likely just read garbage
381 if(input.fail()) {
382 DoeLog(2) && (eLog() << Verbose(2) << "Error parsing elements db." << endl);
383 status = false;
384 break;
385 }
386 }
387// DoLog(0) && (Log() << Verbose(0) << endl);
388 } else {
389 DoeLog(1) && (eLog() << Verbose(1) << "Could not open the database." << endl);
390 status = false;
391 }
392
393 if (!parsedElements.size())
394 status = false;
395
396 if(status){
397 for(map<atomicNumber_t,element*>::iterator iter=parsedElements.begin();
398 iter!=parsedElements.end();
399 ++iter){
400 if (elements.count(iter->first)) {
401 // if element already present, replace the old one
402 // pointer to old element might still be in use, so we have to replace into the old element
403 *(elements[iter->first])=*iter->second;
404 delete(iter->second);
405 }
406 else {
407 // no such element in periodentafel... we can just insert
408 elements[iter->first] = iter->second;
409 }
410 }
411 // all went well.. we now copy the header
412 strncpy(header1,header1tmp.c_str(),MAXSTRINGSIZE);
413 header1[MAXSTRINGSIZE-1]=0;
414 strncpy(header2,header2tmp.c_str(),MAXSTRINGSIZE);
415 header2[MAXSTRINGSIZE-1]=0;
416 }
417
418 return status;
419}
420
421/** load the electronegativity info.
422 * \param *input stream to parse from
423 * \return true - parsing successful, false - something went wrong
424 */
425bool periodentafel::LoadElectronegativityDatabase(std::istream &input)
426{
427 char dummy[MAXSTRINGSIZE];
428 if (!input.fail()) {
429 input.getline(dummy, MAXSTRINGSIZE);
430 while (!input.eof()) {
431 atomicNumber_t Z;
432 input >> Z;
433 ASSERT(elements.count(Z), "Element not present");
434 input >> ws;
435 input >> elements[Z]->Electronegativity;
436 input >> ws;
437 //DoLog(1) && (Log() << Verbose(1)
438 // << "Element " << Z << " has " << FindElement(Z)->Electronegativity << " valence electrons." << endl);
439 }
440 return true;
441 } else
442 return false;
443}
444
445/** load the valence info.
446 * \param *input stream to parse from
447 * \return true - parsing successful, false - something went wrong
448 */
449bool periodentafel::LoadValenceDatabase(istream &input)
450{
451 char dummy[MAXSTRINGSIZE];
452 if (!input.fail()) {
453 input.getline(dummy, MAXSTRINGSIZE);
454 while (!input.eof()) {
455 atomicNumber_t Z;
456 input >> Z;
457 ASSERT(elements.count(Z), "Element not present");
458 input >> ws;
459 input >> elements[Z]->Valence;
460 input >> ws;
461 //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->Valence << " valence electrons." << endl;
462 }
463 return true;
464 } else
465 return false;
466}
467
468/** load the orbitals info.
469 * \param *input stream to parse from
470 * \return true - parsing successful, false - something went wrong
471 */
472bool periodentafel::LoadOrbitalsDatabase(istream &input)
473{
474 char dummy[MAXSTRINGSIZE];
475 if (!input.fail()) {
476 input.getline(dummy, MAXSTRINGSIZE);
477 while (!input.eof()) {
478 atomicNumber_t Z;
479 input >> Z;
480 ASSERT(elements.count(Z), "Element not present");
481 input >> ws;
482 input >> elements[Z]->NoValenceOrbitals;
483 input >> ws;
484 //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
485 }
486 return true;
487 } else
488 return false;
489}
490
491/** load the hbond angles info.
492 * \param *input stream to parse from
493 * \return true - parsing successful, false - something went wrong
494 */
495bool periodentafel::LoadHBondAngleDatabase(istream &input)
496{
497 char dummy[MAXSTRINGSIZE];
498 if (!input.fail()) {
499 input.getline(dummy, MAXSTRINGSIZE);
500 while (!input.eof()) {
501 atomicNumber_t Z;
502 input >> Z;
503 ASSERT(elements.count(Z), "Element not present");
504 input >> ws;
505 input >> elements[Z]->HBondAngle[0];
506 input >> elements[Z]->HBondAngle[1];
507 input >> elements[Z]->HBondAngle[2];
508 input >> ws;
509 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondAngle[0] << ", " << FindElement((int)tmp)->HBondAngle[1] << ", " << FindElement((int)tmp)->HBondAngle[2] << " degrees bond angle for one, two, three connected hydrogens." << endl;
510 }
511 return true;
512 } else
513 return false;
514}
515
516/** load the hbond lengths info.
517 * \param *input stream to parse from
518 * \return true - parsing successful, false - something went wrong
519 */
520bool periodentafel::LoadHBondLengthsDatabase(istream &input)
521{
522 char dummy[MAXSTRINGSIZE];
523 if (!input.fail()) {
524 input.getline(dummy, MAXSTRINGSIZE);
525 while (!input.eof()) {
526 atomicNumber_t Z;
527 input >> Z;
528 ASSERT(elements.count(Z), "Element not present");
529 input >> ws;
530 input >> elements[Z]->HBondDistance[0];
531 input >> elements[Z]->HBondDistance[1];
532 input >> elements[Z]->HBondDistance[2];
533 input >> ws;
534 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
535 }
536 return true;
537 } else
538 return false;
539}
540
541/** load the color info.
542 * \param *input stream to parse from
543 * \return true - parsing successful, false - something went wrong
544 */
545bool periodentafel::LoadColorDatabase(istream &input)
546{
547 char dummy[MAXSTRINGSIZE];
548 if (!input.fail()) {
549 input.getline(dummy, MAXSTRINGSIZE);
550 while (!input.eof()) {
551 atomicNumber_t Z;
552 input >> Z;
553 ASSERT(elements.count(Z), "Element not present");
554 input >> ws;
555 input >> dummy;
556 {
557 int tmpcolor; // char here will only parse a single char (i.e. only "2" out of "255")
558 for (int i=0;i<3;++i) {
559 input >> ws;
560 input >> tmpcolor;
561 elements[Z]->color[i] = (unsigned char)tmpcolor;
562 }
563 }
564 input >> ws;
565// {
566// const element * tmp = FindElement(Z);
567// LOG(0, "Element " << tmp->getName() << " has ("
568// << (int)tmp->color[0] << "," << (int)tmp->color[1] << "," << (int)tmp->color[2]
569// << ") colors.");
570// }
571 }
572 return true;
573 } else
574 return false;
575}
576
577/** Stores element list to file.
578 */
579bool periodentafel::StorePeriodentafel(const char *path) const
580{
581 bool result = true;
582 ofstream f;
583 char filename[MAXSTRINGSIZE];
584
585 strncpy(filename, path, MAXSTRINGSIZE);
586 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
587 strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
588 f.open(filename);
589 if (f != NULL) {
590 f << header1 << endl;
591 f << header2 << endl;
592 for(const_iterator iter=elements.begin();iter!=elements.end();++iter){
593 result = result && (*iter).second->Output(&f);
594 }
595 f.close();
596 return true;
597 } else
598 return result;
599};
600
601/** Comparison operator for periodentafel.
602 *
603 * @param other other instance to compare to
604 * @return true when both contain same elements
605 */
606bool periodentafel::operator==(const periodentafel &other) const
607{
608 // there are only pointers in the elementSet, hence we have to compare ourselves
609 if (elements.size() != other.elements.size()) return false;
610 const_iterator iter = elements.begin();
611 const_iterator otheriter = other.elements.begin();
612 for (;(iter != elements.end()) && (otheriter != other.elements.end());
613 ++iter, ++otheriter) {
614 bool status = true;
615 status = status && (iter->first == otheriter->first);
616 status = status && (*(iter->second) == *(otheriter->second));
617 if (!status) {
618 std::cout << *(iter->second) << " not equal to " << *(otheriter->second) << "." << std::endl;
619 return false;
620 }
621// else
622// std::cout << (iter->second)->getName() << " are equal to " << (otheriter->second)->getName() << "." << std::endl;
623 }
624 if (strncmp(header1, other.header1, MAXSTRINGSIZE) != 0) return false;
625 if (strncmp(header2, other.header2, MAXSTRINGSIZE) != 0) return false;
626 return true;
627}
Note: See TracBrowser for help on using the repository browser.