Changeset 11015 for trunk/FACT++/src


Ignore:
Timestamp:
06/13/11 18:05:57 (13 years ago)
Author:
tbretz
Message:
Added some const-qualifiers.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Fits.cc

    r10955 r11015  
    3535//! @param numDataBytes the number of bytes taken by the variable
    3636//
    37 void Fits::AddStandardColumn(Description& desc, string dataFormat, void* dataPointer, long unsigned int numDataBytes)
     37void Fits::AddStandardColumn(const Description& desc, const string &dataFormat, void* dataPointer, long unsigned int numDataBytes)
    3838{
    3939        //check if entry already exist
    40         for (vector<Description>::iterator it=fStandardColDesc.begin(); it != fStandardColDesc.end(); it++)
     40        for (vector<Description>::const_iterator it=fStandardColDesc.begin(); it != fStandardColDesc.end(); it++)
    4141                if (it->name == desc.name)
    4242                        return;
     
    5454//! @param numDataBytes the number of bytes taken by the DIM data.
    5555//     
    56 void Fits::InitDataColumns(vector<Description> desc, vector<string>& dataFormat, void* dataPointer, int numDataBytes)
     56void Fits::InitDataColumns(const vector<Description> &desc, vector<string>& dataFormat, void* dataPointer, int numDataBytes)
    5757{//we will copy this information here. It duplicates the data, which is not great, but it is the easiest way of doing it right now
    5858        if (desc.size() == dataFormat.size())
     
    101101                {                       
    102102                        ostringstream str;
    103                         str << "Could not open FITS file " << fileName << " reason: " << e.message();
     103                        str << "Opening FITS file " << fileName << ": " << e.message();
    104104                        fMess->Error(str);
    105105                        fFile = NULL;
     
    129129        }
    130130        //for (int i=static_cast<int>(fDataColDesc.size())-1;i>=0;i--)
    131         for (int i=0; i< static_cast<int>(fDataColDesc.size()); i++)
     131        for (unsigned int i=0; i<fDataColDesc.size(); i++)
    132132        {
    133133                if (fDataColDesc[i].name != "")
     
    147147        try
    148148        {
    149                 string factTableName = tableName;
    150149                //first, let's check if the table already exist in the file
    151150                vector<string> tryToLoadName;
    152                 tryToLoadName.push_back(factTableName);
    153                 fFile->read(tryToLoadName);
     151                tryToLoadName.push_back(tableName);
     152                fFile->read(tryToLoadName);
     153
    154154            const multimap< string, CCfits::ExtHDU * >& extMap = fFile->extension();
    155             if (extMap.find(factTableName) == extMap.end())
     155            if (extMap.find(tableName) == extMap.end())
    156156            {
    157157                for (multimap<string, CCfits::ExtHDU*>::const_iterator it=extMap.begin(); it!= extMap.end(); it++)
    158158                    fMess->Debug(it->first);
    159                 fTable = fFile->addTable(factTableName, 0, allNames, allDataTypes, allUnits);
     159                fTable = fFile->addTable(tableName, 0, allNames, allDataTypes, allUnits);
    160160            }
    161161            else
    162162            {
    163                 fTable = dynamic_cast<CCfits::Table*>(extMap.find(factTableName)->second);
     163                fTable = dynamic_cast<CCfits::Table*>(extMap.find(tableName)->second);
    164164            }
    165165            if (!fTable)
    166166            {
    167                 fMess->Error("The table " + factTableName + " could not be created nor loaded. skipping it");
     167                fMess->Error("Table " + tableName + " could not be created nor loaded from "+fileName);
    168168                Close();
    169169                return false;
     
    177177                        if (!bTable)
    178178                        {
    179                                 fMess->Error("The table " + factTableName + " could not be converted to a binary table. skipping");
     179                                fMess->Error("Table " + tableName + " in "+fileName+" could not be converted to a binary table.");
    180180                                Close();
    181181                                return false;
     
    186186
    187187                        //double check that the data was indeed read from the disk. Go through the fTable instead as colName is empty (yes, it is !)
    188                         map<string, Column*> cMap = fTable->column();
    189                         map<string, Column*>::iterator cMapIt;
    190 
    191                         for (cMapIt = cMap.begin(); cMapIt != cMap.end(); cMapIt++)
     188                        const map<string, Column*> cMap = fTable->column();
     189
     190                        for (map<string, Column*>::const_iterator cMapIt = cMap.begin(); cMapIt != cMap.end(); cMapIt++)
    192191                        {
    193192                                if (!cMapIt->second->isRead())
    194193                                {
    195                                         fMess->Error("Column " + cMapIt->first + "Could not be read back from the disk");
     194                                        fMess->Error("Reading column " + cMapIt->first + " back from "+fileName+" failed.");
    196195                                        Close();
    197196                                        return false;
     
    205204        {
    206205                ostringstream str;
    207                 str << "Could not open or create FITS table " << tableName << " in  file " << fileName << " reason: " << e.message();
     206                str << "Opening or creating table " << tableName << " in " << fileName << ": " << e.message();
    208207                fMess->Error(str);
    209208                fTable = NULL;
     
    226225//!@param a comment explaining the meaning of the key
    227226template <typename T>
    228 bool Fits::WriteSingleHeaderKey(string name, T value, string comment)
     227bool Fits::WriteSingleHeaderKey(const string &name, const T &value, const string &comment)
    229228{
    230229        try
     
    249248        if (!fTable)
    250249                return false;
    251         string name;
    252         string comment;
    253 
    254         string stringValue;
     250
     251        string stringValue = Time().GetAsStr();
     252        stringValue[10]= 'T';
    255253
    256254        if (!WriteSingleHeaderKey("EXTREL", 1.0f, "Release Number")) return false;
     
    258256        if (!WriteSingleHeaderKey("ORIGIN", "ISDC", "Institution that wrote the file")) return false;
    259257        if (!WriteSingleHeaderKey("CREATOR", "FACT++ DataLogger", "Program that wrote this file")) return false;
    260         stringValue = Time().GetAsStr();
    261         stringValue[10]= 'T';
    262258        if (!WriteSingleHeaderKey("DATE", stringValue, "File creation data")) return false;
    263259        if (!WriteSingleHeaderKey("TIMESYS", "TT", "Time frame system")) return false;
     
    373369        if (stat(fFileName.c_str(), &st))
    374370                return 0;
    375         else
    376                 return st.st_size;
    377 }
     371
     372        return st.st_size;
     373}
  • trunk/FACT++/src/Fits.h

    r10955 r11015  
    8888               
    8989                ///Adds a column that exists in all FITS files
    90                 void AddStandardColumn(Description& desc, string dataFormat, void* dataPointer, long unsigned int numDataBytes);
     90                void AddStandardColumn(const Description& desc, const string &dataFormat, void* dataPointer, long unsigned int numDataBytes);
    9191               
    9292                ///Adds columns specific to the service being logged.
    93                 void InitDataColumns(vector<Description> desc, vector<string>& dataFormat, void* dataPointer, int numDataBytes);
     93                void InitDataColumns(const vector<Description> &desc, vector<string>& dataFormat, void* dataPointer, int numDataBytes);
    9494
    9595                ///Opens a FITS file
     
    106106private:
    107107                template <typename T>
    108                 bool WriteSingleHeaderKey(string name, T value, string comment);
     108                bool WriteSingleHeaderKey(const string &name, const T &value, const string &comment);
    109109
    110110};//Fits
Note: See TracChangeset for help on using the changeset viewer.