Changeset 17392 for trunk


Ignore:
Timestamp:
11/26/13 19:14:53 (11 years ago)
Author:
tbretz
Message:
Simplified: keep a list of all skipped tables. There is no need to lop over the whole file for every table which is a log(n) process.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mcore/fits.h

    r17382 r17392  
    485485protected:
    486486    std::ofstream fCopy;
     487    std::vector<std::string> fListOfTables; // List of skipped tables. Last table is open table
    487488
    488489    Table fTable;
     
    558559    }
    559560
    560     void Constructor(const std::string &fname, std::string fout, const std::string& tableName, bool force, int tableNumber=-1)
     561    void Constructor(const std::string &fname, std::string fout="", const std::string& tableName="", bool force=false)
    561562    {
    562563        char simple[10];
     
    564565        if (!good())
    565566            return;
    566 
    567         int current_table = 0;
    568567
    569568        if (memcmp(simple, "SIMPLE  = ", 10))
     
    642641                }
    643642
     643                const std::string &tname = fTable.Get<std::string>("EXTNAME");
     644
     645                fListOfTables.emplace_back(tname);
     646
    644647                // Check for table name. Skip until eof or requested table are found.
    645648                // skip the current table?
    646                 if ((!tableName.empty() &&         tableName!=fTable.Get<std::string>("EXTNAME")) ||
    647                     ( tableName.empty() && "ZDrsCellOffsets"==fTable.Get<std::string>("EXTNAME")) ||
    648                     (tableNumber != -1))
     649                if ((!tableName.empty() && tableName!=tname) || (tableName.empty() && "ZDrsCellOffsets"==tname))
    649650                {
    650                     if (current_table == tableNumber)
    651                     {
    652                         fBufferRow.resize(fTable.bytes_per_row + 8-fTable.bytes_per_row%4);
    653                         fBufferDat.resize(fTable.bytes_per_row);
    654 
    655                         break;
    656                     }
    657651                    const streamoff skip = fTable.GetTotalBytes();
    658652                    seekg(skip, std::ios_base::cur);
    659653
    660654                    fChkHeader.reset();
    661                     current_table++;
    662655
    663656                    continue;
     
    688681#else
    689682            gLog << ___err___ << "ERROR - Failed to open output file." << std::endl;
     683            return;
    690684#endif
    691685        }
     
    10431037        return fTable.Get<size_t>("NAXIS1");
    10441038    }
     1039
     1040    const std::vector<std::string> &GetTables() const
     1041    {
     1042        return fListOfTables;
     1043    }
    10451044};
    10461045
Note: See TracChangeset for help on using the changeset viewer.