![]() |
ENSDF++ 1.1
An easy, fast and simple way to run querys towards the ENSDF database, written in C++.
|
Contains the MassTable from the mass.mas03 file. More...
#include <MassTable.h>
Public Member Functions | |
MassTable (string filename, VerbosePrinter *toRegister=NULL) | |
C. | |
list< MassObject > | getMassObjects () const |
Get the mass objects in the table. | |
const MassObject | getMassObject (Nukleid toGet) const |
Returns a MassObject corresponding to toGet. | |
const MassObject | getMassObject (unsigned short int Z, unsigned short int A) const |
Returns a MassObject corresponding to a specific atomic- and massnumber. | |
Private Attributes | |
list< MassObject > | myMasses |
A list of MassObject loaded in the constructor. |
Contains the MassTable from the mass.mas03 file.
Definition at line 47 of file MassTable.h.
MassTable::MassTable | ( | string | filename, |
VerbosePrinter * | toRegister = NULL |
||
) |
C.
filename | The filename to load the masstable from. |
toRegister | Used to display information to the user. |
Definition at line 4 of file MassTable.cpp.
References myMasses, NULL, VerbosePrinterEventEnabled::registerListener(), and VerbosePrinterEventEnabled::vPrint().
{ registerListener(toRegister); vPrint(4,"Creating mass table from file %s.\n", filename.c_str()); FILE * myFile; myFile = fopen(filename.c_str(),"r"); if(myFile==NULL) perror("The opened file is null"); char line[200]; vector<string> fileContent; while (fgets(line,200, myFile)!=NULL) { string myString(line); fileContent.push_back(myString); } vector<string>::iterator it = fileContent.begin(); for(int i = 0; i<40 && it!=fileContent.end(); i++) ++it; while(it!=fileContent.end()) { myMasses.push_back(MassObject(*(it++))); } if(myFile!=NULL) fclose(myFile); vPrint(4,"Done creating mass table.\n"); return; }
const MassObject MassTable::getMassObject | ( | Nukleid | toGet | ) | const |
Returns a MassObject corresponding to toGet.
DataFileException | if there is no such MassObject. |
toGet | The Nukleid object to get a MassObject for. |
Definition at line 37 of file MassTable.cpp.
References myMasses, Nukleid::toString(), and VerbosePrinterEventEnabled::vPrint().
Referenced by DataQueryBetaGamma::DetectInterestingStuffWithThisIsotope(), and main().
{ vPrint(13, "Now searching through %d masstable entries.\n",myMasses.size()); for(list<MassObject>::const_iterator it = myMasses.begin(); it!=myMasses.end(); it++) { if(it->getNukleid()==toGet) return (*it); } throw DataFileException("The requested nucleid was not found in the masstable: " + toGet.toString() + " Probable cause: incorrect or missing masstable."); }
const MassObject MassTable::getMassObject | ( | unsigned short int | Z, |
unsigned short int | A | ||
) | const |
Returns a MassObject corresponding to a specific atomic- and massnumber.
DataFileException | if no such MassObject exists. |
Z | The atomic number. |
A | The mass number |
Definition at line 48 of file MassTable.cpp.
References myMasses.
{ for(list<MassObject>::const_iterator it = myMasses.begin(); it!=myMasses.end(); it++) { if(it->getNukleid().getA()==A && it->getNukleid().getZ()==Z) return (*it); } throw DataFileException("The requested nucleid was not found. "); }
list< MassObject > MassTable::getMassObjects | ( | ) | const |
Get the mass objects in the table.
Definition at line 32 of file MassTable.cpp.
References myMasses.
Referenced by main().
{ return myMasses; }