FACT++  1.0
int FitsLoader::LoadPlease ( )
private

Transition from ready to fileLoaded.

Loads the fits file based on the current parameters.

Definition at line 421 of file fitsloader.cc.

References MessageImp::Error(), fColMap, fDumpList, fFile, fFileName, fTable, fTableName, kSM_FileLoaded, StateMachineImp::kSM_Ready, MessageImp::Message(), numRows, and str.

Referenced by FitsLoader().

422 {
423  ostringstream str;
424  try
425  {
426  fFile = new CCfits::FITS(fFileName);
427  }
428  catch (CCfits::FitsException e)
429  {
430  str << "Could not open FITS file " << fFileName << " reason: " << e.message();
431  Error(str);
432  return kSM_Ready;
433  }
434  str.str("");
435  const multimap< string, CCfits::ExtHDU * > extMap = fFile->extension();
436  if (extMap.find(fTableName) == extMap.end())
437  {
438  str.str("");
439  str << "Could not open table " << fTableName << ". Tables in file are: ";
440  for (std::multimap<string, CCfits::ExtHDU*>::const_iterator it=extMap.begin(); it != extMap.end(); it++)
441  str << it->first << " ";
442  Error(str);
443  return kSM_Ready;
444  }
445  else
446  fTable = dynamic_cast<CCfits::Table*>(extMap.find(fTableName)->second);
447  int numRows = fTable->rows();
448  str.str("");
449  str << "Loaded table has " << numRows << " rows";
450  Message(str);
451 
452  fColMap = fTable->column();
453  if (fDumpList.size() != 0)
454  {
455  bool should_clear = false;
456  for (vector<string>::iterator it=fDumpList.begin(); it!= fDumpList.end(); it++)
457  {
458  if (fColMap.find(*it) == fColMap.end())
459  {
460  should_clear = true;
461  Error("Config-given dump list contains invalid entry " + *it + " clearing the list");
462  }
463  }
464  if (should_clear)
465  fDumpList.clear();
466  }
467  return kSM_FileLoaded;
468 }
map< string, CCfits::Column * > fColMap
map between the column names and their CCfits objects
Definition: fitsloader.cc:82
Mainloop running, state machine in operation.
char str[80]
Definition: test_client.c:7
CCfits::FITS * fFile
FITS pointer.
Definition: fitsloader.cc:74
int Error(const std::string &str)
Definition: MessageImp.h:49
vector< string > fDumpList
List of the column names to be dumped.
Definition: fitsloader.cc:84
string fFileName
Name of the fits file to load.
Definition: fitsloader.cc:70
CCfits::Table * fTable
Table pointer.
Definition: fitsloader.cc:76
string fTableName
Name of the table to load from the file.
Definition: fitsloader.cc:72
int Message(const std::string &str)
Definition: MessageImp.h:46
uint32_t numRows
Definition: FITS.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function: