source: src/Element/periodentafel.cpp@ 4ae823

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 4ae823 was 4ae823, checked in by Frederik Heber <heber@…>, 13 years ago

periodentafel may or may not Load internal databases in its cstor.

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