ENSDF++ 1.1
An easy, fast and simple way to run querys towards the ENSDF database, written in C++.
Functions
Main.cpp File Reference

Source file for the main program flow controlling functions. More...

#include "Main.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 The main method of the program.
int proceed_interact (int verbosityLevel, unsigned int nbrOfThreads)
 Called by main if interactive queries are requested.
int proceed_nointeract (CommandLineInterpreter *myInterpreter)
 Run the program in non-interactive mode.

Detailed Description

Source file for the main program flow controlling functions.

Author:
Rikard Lundmark

Definition in file Main.cpp.


Function Documentation

int main ( int  argc,
char *  argv[] 
)

The main method of the program.

Main function in this short program.

Parameters:
argcargc, standard.
argvargv, standard.

Definition at line 4 of file Main.cpp.

{
  list<CommandLineArgument> myArguments;
  myArguments.push_back(CommandLineArgument("file",1));
  myArguments.push_back(CommandLineArgument("bLimits",2));
  myArguments.push_back(CommandLineArgument("bBranch",1));
  myArguments.push_back(CommandLineArgument("gBranch",1));
  myArguments.push_back(CommandLineArgument("v",1)); //verbose.
  myArguments.push_back(CommandLineArgument("i",0));
  myArguments.push_back(CommandLineArgument("gList",0));
  myArguments.push_back(CommandLineArgument("iList",0));
  myArguments.push_back(CommandLineArgument("cList",0));
  myArguments.push_back(CommandLineArgument("texList",0));
  myArguments.push_back(CommandLineArgument("t",1));
  myArguments.push_back(CommandLineArgument("tLimits",2));
  myArguments.push_back(CommandLineArgument("help",0));
  CommandLineInterpreter * myInterpreter = new CommandLineInterpreter(argc, argv, myArguments);
  if(!myInterpreter->readFlaggedCommand("help").empty())
    {
      printf("The following arguments are valid:\n");
      printf("  -file <filename> Specifies output file.\n");
      printf("  -bLimits <lower limit> <upper limit> Specifies limiting Beta decay times.\n");
      printf("  -bBranch <branch strength> Specifies minimum branch strength for a beta decay branch.\n");
      printf("  -gBranch <branch strength> Specifies minimum branch strength for a gamma decay.\n");
      printf("  -v <verbose level> Specifies how verbose the output should be.\n     The larger verbose level, the more information will be dumped to the terminal during execution.\n");
      printf("  -i Interactive session.\n");
      printf("  -gList Create a list of gamma energies instead of normal output.\n");
      printf("  -iList Create a list of isomers instead of normal output.\n");
      printf("  -cList Create a list of nuclides suitable for chart view.\n");
      printf("  -texList Create a list of nuclides suitable for the report.\n");

      printf("  -tLimits Time limits for the isomers in case of the iList parameter.\n");
      printf("  -t <number of threads> specifies number of threads to use for loading data, default is 5.");
      printf("  -help Displays this help message.\n");
      return 0;
    }
  
  if(argc<2 || !(myInterpreter->readFlaggedCommand("i").empty()))
    {
      int verbosityLevel = 0;
      if(myInterpreter->readFlaggedCommand("v").size()==1)
        verbosityLevel = atoi((myInterpreter->readFlaggedCommand("v").front()).c_str());
      unsigned int nbrOfThreads = 5;
      if(myInterpreter->readFlaggedCommand("t").size()==1)
        nbrOfThreads = atoi((myInterpreter->readFlaggedCommand("t").front()).c_str());
      int retval = proceed_interact(verbosityLevel, nbrOfThreads);
      delete myInterpreter;
      myInterpreter = NULL;
      return retval;
    }
  int retval = proceed_nointeract(myInterpreter);
  delete myInterpreter;
  myInterpreter = NULL;
  return retval;
}
int proceed_interact ( int  verbosityLevel,
unsigned int  nbrOfThreads = 5 
)

Called by main if interactive queries are requested.

Currently only supports a limited set of queries.

Parameters:
verbosityLevelThe verbosity level of the VerbosePrinter created.
nbrOfThreadsThe number of worker threads for the ENSDFProcessor object.

Definition at line 61 of file Main.cpp.

References ENSDF_DIR, MASSTABLE_DIR, NULL, VerbosePrinter::print(), and ENSDFProcessor::runBetaGammaQuery().

Referenced by main().

{
  VerbosePrinter * myVerbosePrinter = new VerbosePrinter(verbosityLevel);
  myVerbosePrinter->print(1,"Creating ENSDF object.\n");
  ENSDFProcessor * myProcessor = new ENSDFProcessor(ENSDF_DIR, MASSTABLE_DIR, myVerbosePrinter, nbrOfThreads);

  int thisVariableIsOnlyUsedToAvoidCompilerWarnings = 0;
  char proceed = 'Y';
  do
    {
      double min=1E-3, max=1, betabranch=0.1, gammabranch=0.1;
      printf("\nPlease enter query parameters.\n");
      printf("Minimum time for beta decay (s): ");
      thisVariableIsOnlyUsedToAvoidCompilerWarnings=scanf("%lg",&min);
      printf("Maximum time for beta decay (s): ");
      thisVariableIsOnlyUsedToAvoidCompilerWarnings=scanf("%lg",&max);
      printf("Minimum beta branch strength (%%): ");
      thisVariableIsOnlyUsedToAvoidCompilerWarnings=scanf("%lg", &betabranch);
      printf("Minimum gamma branch strength (%%): ");
      thisVariableIsOnlyUsedToAvoidCompilerWarnings=scanf("%lg",&gammabranch);
      char * myD = new char[200];
      printf("Enter output file name: "); fflush(stdin);
      thisVariableIsOnlyUsedToAvoidCompilerWarnings=scanf("%s",myD);
      
      string fileString(myD);
      
      myVerbosePrinter->print(1,"Running query\n");
      myProcessor->runBetaGammaQuery(min, max, betabranch, gammabranch, fileString);
      
      fflush(stdin);
      printf("Do you want to run another query? [Y/N] ");
      thisVariableIsOnlyUsedToAvoidCompilerWarnings=scanf(" %c", &proceed);
      fflush(stdin);
    }while(proceed=='Y' || proceed=='y');
  delete myProcessor;
  myProcessor = NULL;
  delete myVerbosePrinter;
  myVerbosePrinter = NULL;
  return 0;
}
int proceed_nointeract ( CommandLineInterpreter myInterpreter)

Run the program in non-interactive mode.

Parameters:
myInterpreterThe CommandLineInterpreter from which to read what to do.

Definition at line 103 of file Main.cpp.

References ENSDF_DIR, MASSTABLE_DIR, NULL, VerbosePrinter::print(), CommandLineInterpreter::readFlaggedCommand(), ENSDFProcessor::runBetaGammaQuery(), ENSDFProcessor::runBetaGammaQuery_GenerateChartList(), ENSDFProcessor::runBetaGammaQuery_GenerateGammaList(), ENSDFProcessor::runBetaGammaQuery_GenerateTexList(), and ENSDFProcessor::runIsomerQuery().

Referenced by main().

{
  int verbosityLevel = 0;
  if(myInterpreter->readFlaggedCommand("v").size()==1)
    verbosityLevel = atoi((myInterpreter->readFlaggedCommand("v").front()).c_str());

  
  VerbosePrinter * myVerbosePrinter = new VerbosePrinter(verbosityLevel);

  unsigned int nbrOfThreads = 5;
  if(myInterpreter->readFlaggedCommand("t").size()==1)
    {
      nbrOfThreads = atoi((myInterpreter->readFlaggedCommand("t").front()).c_str());
      myVerbosePrinter->print(8,"Number of threads: %d.\n",nbrOfThreads);
    }
  else
    {
      myVerbosePrinter->print(8,"Number of threads not specified, the default number %d was set.\n", nbrOfThreads);
    }

  
  
  if(myInterpreter->readFlaggedCommand("file").size()!=1)
    throw CommandLineException("File not properly specified.\n");
  string myFile = myInterpreter->readFlaggedCommand("file").front();
  if(myFile.size()<2)
    throw CommandLineException("Invalid file name specified.\n");
  
  myVerbosePrinter->print(1,"Creating ENSDF object.\n");
  ENSDFProcessor * myProcessor = new ENSDFProcessor(ENSDF_DIR, MASSTABLE_DIR, myVerbosePrinter, nbrOfThreads);

  myVerbosePrinter->print(1,"Running query\n");
  if(!myInterpreter->readFlaggedCommand("iList").empty())
    {
      if(myInterpreter->readFlaggedCommand("tLimits").size()!=2)
        throw CommandLineException("Decay time limits not properly specified.\n");
      double tLower = atof(((myInterpreter->readFlaggedCommand("tLimits"))[0]).c_str());
      double tUpper = atof(((myInterpreter->readFlaggedCommand("tLimits"))[1]).c_str());

      myProcessor->runIsomerQuery(tLower, tUpper, myFile);
    }
  else
    {
      if(myInterpreter->readFlaggedCommand("bLimits").size()!=2)
        throw CommandLineException("Beta limits not properly specified.\n");
      double bLowerLimit = atof(((myInterpreter->readFlaggedCommand("bLimits"))[0]).c_str());
      double bUpperLimit = atof(((myInterpreter->readFlaggedCommand("bLimits"))[1]).c_str());
      
      if(myInterpreter->readFlaggedCommand("gBranch").size()!=1)
        throw CommandLineException("Gamma branch not properly specified.\n");
      double gBranch = atof(myInterpreter->readFlaggedCommand("gBranch").front().c_str());
      
      if(!myInterpreter->readFlaggedCommand("gList").empty())
        {
          myProcessor->runBetaGammaQuery_GenerateGammaList(bLowerLimit, bUpperLimit, gBranch, myFile);
        }
      else if(!myInterpreter->readFlaggedCommand("cList").empty())
        {
          myProcessor->runBetaGammaQuery_GenerateChartList(bLowerLimit, bUpperLimit, gBranch, myFile);
        }
      else if(!myInterpreter->readFlaggedCommand("texList").empty())
        {
           myProcessor->runBetaGammaQuery_GenerateTexList(bLowerLimit, bUpperLimit, gBranch, myFile);
        }
      else
        {
          if(myInterpreter->readFlaggedCommand("bBranch").size()!=1)
            throw CommandLineException("Beta branch not properly specified.\n");
          double bBranch = atof(myInterpreter->readFlaggedCommand("bBranch").front().c_str());
          myProcessor->runBetaGammaQuery(bLowerLimit, bUpperLimit, bBranch, gBranch, myFile);
        }
    }
  delete myProcessor;
  myProcessor = NULL;
  delete myVerbosePrinter;
  myVerbosePrinter = NULL;
  return 0;
}
 All Classes Files Functions Variables Enumerations Enumerator Defines

Back to the main page of the Precalibrated Ion Beam Identification Detector project

Created by Rikard Lundmark