Changeset 17264 for trunk/Mars/mcore


Ignore:
Timestamp:
10/18/13 17:52:38 (11 years ago)
Author:
tbretz
Message:
Hopefully finished removing the std namespace from the headers.
Location:
trunk/Mars/mcore
Files:
5 edited

Legend:

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

    r17141 r17264  
    77
    88#include <stdint.h>
    9 
    10 namespace std
    11 {
    129
    1310class Checksum
     
    4340        return *this;
    4441    }
     42
    4543    Checksum operator+(Checksum sum) const
    4644    {
     
    6058        if (len%4>0)
    6159        {
    62             ostringstream sout;
    63             sout << "Length " << len << " not dividable by 4." << endl;
     60            std::ostringstream sout;
     61            sout << "Length " << len << " not dividable by 4";
    6462
    6563#ifdef __EXCEPTIONS
    66             throw runtime_error(sout.str());
     64            throw std::runtime_error(sout.str());
    6765#else
    6866            gLog << ___err___ << "ERROR - " << sout.str() << endl;
     
    143141    }
    144142
    145     bool add(const vector<char> &v, bool big_endian = true)
     143    bool add(const std::vector<char> &v, bool big_endian = true)
    146144    {
    147145        return add(v.data(), v.size(), big_endian);
    148146    }
    149147
    150     string str(bool complm=true) const
    151     {
    152         string rc(16,0);
     148    std::string str(bool complm=true) const
     149    {
     150        std::string rc(16,0);
    153151
    154152        const uint8_t exclude[13] =
     
    241239   }
    242240};
    243 }
    244241
    245242#endif
  • trunk/Mars/mcore/factfits.h

    r17038 r17264  
    1111#include "zfits.h"
    1212
    13 #ifndef __MARS__
    14 namespace std
    15 {
    16 #endif
    17 
    1813class factfits : public zfits
    1914{
    2015public:
    2116    // Default constructor
    22     factfits(const string& fname, const string& tableName="", bool force=false) :
     17    factfits(const std::string& fname, const std::string& tableName="", bool force=false) :
    2318        zfits(fname, tableName, force),
    2419        fOffsetCalibration(0),
     
    3227
    3328    // Alternative constructor
    34     factfits(const string& fname, const string& fout, const string& tableName, bool force=false) :
     29    factfits(const std::string& fname, const std::string& fout, const std::string& tableName, bool force=false) :
    3530        zfits(fname, fout, tableName, force),
    3631        fOffsetCalibration(0),
     
    4843    {
    4944        zfits::StageRow(row, dest);
     45
    5046        // This file does not contain fact data or no calibration to be applied
    51          if (fOffsetCalibration.empty())
    52              return;
    53 
    54          //re-get the pointer to the data to access the offsets
    55          const uint8_t offset = (row*fTable.bytes_per_row)%4;
    56 
    57          int16_t *startCell = reinterpret_cast<int16_t*>(fBufferRow.data() + offset + fOffsetStartCellData);
    58          int16_t *data      = reinterpret_cast<int16_t*>(fBufferRow.data() + offset + fOffsetData);
     47        if (fOffsetCalibration.empty())
     48            return;
     49
     50        //re-get the pointer to the data to access the offsets
     51        const uint8_t offset = (row*fTable.bytes_per_row)%4;
     52
     53        int16_t *startCell = reinterpret_cast<int16_t*>(fBufferRow.data() + offset + fOffsetStartCellData);
     54        int16_t *data      = reinterpret_cast<int16_t*>(fBufferRow.data() + offset + fOffsetData);
    5955
    6056         /*
     
    7167         */
    7268
    73          // This version is faster because the compilers optimization
    74          // is not biased by the evaluation of %1024
    75          for (int ch=0; ch<1440; ch++)
    76          {
    77              if (startCell[ch]<0)
    78              {
    79                  data += fNumRoi;
    80                  continue;
    81              }
    82 
    83              const int16_t modStart = startCell[ch] % 1024;
    84              const int16_t *off = fOffsetCalibration.data() + ch*1024;
    85 
    86              const int16_t *cal = off+modStart;
    87              const int16_t *end_stride = data+fNumRoi;
    88 
    89              if (modStart+fNumRoi>1024)
    90              {
    91                  while (cal<off+1024)
    92                      *data++ += *cal++;
    93 
    94                  cal = off;
    95              }
    96              while (data<end_stride)
    97                  *data++ += *cal++;
    98          }
    99 
    100 }
     69        // This version is faster because the compilers optimization
     70        // is not biased by the evaluation of %1024
     71        for (int ch=0; ch<1440; ch++)
     72        {
     73            if (startCell[ch]<0)
     74            {
     75                data += fNumRoi;
     76                continue;
     77            }
     78
     79            const int16_t modStart = startCell[ch] % 1024;
     80            const int16_t *off = fOffsetCalibration.data() + ch*1024;
     81
     82            const int16_t *cal = off+modStart;
     83            const int16_t *end_stride = data+fNumRoi;
     84
     85            if (modStart+fNumRoi>1024)
     86            {
     87                while (cal<off+1024)
     88                    *data++ += *cal++;
     89
     90                cal = off;
     91            }
     92            while (data<end_stride)
     93                *data++ += *cal++;
     94        }
     95
     96    }
    10197
    10298    bool init()
     
    129125
    130126    //  Read the Drs calibration data
    131     void readDrsCalib(const string& fileName)
     127    void readDrsCalib(const std::string& fileName)
    132128    {
    133129        //should not be mandatory, but improves the perfs a lot when reading not compressed, gzipped files
     
    205201}; //class factfits
    206202
    207 #ifndef __MARS__
    208 }; //namespace std
    209 #endif
    210 
    211 #endif
     203#endif
  • trunk/Mars/mcore/factofits.h

    r17263 r17264  
    1212#include "DrsCalib.h"
    1313
    14 #ifndef __MARS__
    15 namespace std
    16 {
    17 #endif
    18 
    1914class factofits : public zofits
    2015{
    21 
    2216    public:
    2317
     
    5044
    5145        ///assign a given drs offset calibration
    52         void SetDrsCalibration(const vector<float> &calib)
     46        void SetDrsCalibration(const std::vector<float> &calib)
    5347        {
    5448            VerifyCalibrationSize(calib.size());
     
    6256
    6357        ///assign a given drs offset calibration
    64         void SetDrsCalibration(const vector<int16_t>& vec)
     58        void SetDrsCalibration(const std::vector<int16_t>& vec)
    6559        {
    6660            VerifyCalibrationSize(vec.size());
     
    110104                    {
    111105#ifdef __EXCEPTIONS
    112                         throw runtime_error("Number of data samples not a multiple of 1440.");
     106                        throw std::runtime_error("Number of data samples not a multiple of 1440.");
    113107#else
    114                         gLog << ___warn___ << "WARNING - Number of data samples not a multiple of 1440. Doing it uncalibrated." << endl;
     108                        gLog << ___warn___ << "WARNING - Number of data samples not a multiple of 1440. Doing it uncalibrated." << std::endl;
    115109#endif
    116110                        fOffsetCalibration.resize(0);
     
    123117            {
    124118#ifdef __EXCEPTIONS
    125                 throw runtime_error("FACT Calibration requested, but \"StartCellData\" column not found.");
     119                throw std::runtime_error("FACT Calibration requested, but \"StartCellData\" column not found.");
    126120#else
    127                 gLog << ___warn___ << "WARNING - FACT Calibration requested, but \"StartCellData\" column not found. Doing it uncalibrated." << endl;
     121                gLog << ___warn___ << "WARNING - FACT Calibration requested, but \"StartCellData\" column not found. Doing it uncalibrated." << std::endl;
    128122#endif
    129123                //throw away the calibration data
     
    134128            {
    135129#ifdef __EXCEPTIONS
    136                 throw runtime_error("FACT Calibration requested, but \"Data\" column not found.");
     130                throw std::runtime_error("FACT Calibration requested, but \"Data\" column not found.");
    137131#else
    138                 gLog << ___warn___ << "WARNING - FACT Calibration requested, but \"Data\" column not found. Doing it uncalibrated." << endl;
     132                gLog << ___warn___ << "WARNING - FACT Calibration requested, but \"Data\" column not found. Doing it uncalibrated." << std::endl;
    139133#endif
    140134                    //throw away the calibration data
     
    174168            datasum.add(swappedOffsets.data(), sizeof(int16_t)*1024*1440);
    175169
    176             ostringstream dataSumStr;
     170            std::ostringstream dataSumStr;
    177171            dataSumStr << datasum.val();
    178172            c.SetStr("DATASUM", dataSumStr.str());
     
    241235            Checksum rawsum;
    242236            rawsum.add((char*)(fOffsetCalibration.data()), 1024*1440*sizeof(int16_t));
    243             c.SetStr("RAWSUM", to_string(rawsum.val()));
     237            c.SetStr("RAWSUM", std::to_string(rawsum.val()));
    244238
    245239            //compress data and calculate final, compressed size
     
    281275            c.SetFloat("ZRATIO", (float)(1024*1440*2)/(float)(compressed_size));
    282276            c.SetInt("PCOUNT", compressed_size + catalog_size);
    283             c.SetStr("DATASUM", to_string(datasum.val()));
     277            c.SetStr("DATASUM", std::to_string(datasum.val()));
    284278
    285279            datasum += c.WriteHeader(*this);
     
    339333                return true;
    340334
    341             ostringstream str;
     335            std::ostringstream str;
    342336            str << "Cannot load calibration with anything else than 1440 pixels and 1024 samples per pixel. Got a total size of " << size;
    343337#ifdef __EXCEPTIONS
    344             throw runtime_error(str.str());
     338            throw std::runtime_error(str.str());
    345339#else
    346             gLog << ___err___ << "ERROR - " << str.str() << endl;
     340            gLog << ___err___ << "ERROR - " << str.str() << std::endl;
    347341            return false;
    348342#endif
     
    350344
    351345        //Offsets calibration stuff.
    352         vector<int16_t> fOffsetCalibration;  ///< The calibration itself
     346        std::vector<int16_t> fOffsetCalibration;  ///< The calibration itself
    353347        int32_t         fStartCellsOffset;   ///< Offset in bytes for the startcell data
    354348        int32_t         fDataOffset;         ///< Offset in bytes for the data
     
    357351}; //class factofits
    358352
    359 #ifndef __MARS
    360 }; //namespace std
    361 #endif
    362 
    363353#endif /* FACTOFITS_H_ */
  • trunk/Mars/mcore/ofits.h

    r17263 r17264  
    3333#include "checksum.h"
    3434
    35 #ifndef __MARS__
    36 namespace std
    37 {
    38 #endif
    39 
    4035// Sloppy:  allow / <--- left
    4136//          allow all characters (see specs for what is possible)
     
    4338// units: m kg s rad sr K A mol cd Hz J W V N Pa C Ohm S F Wb T Hlm lx
    4439
    45 class ofits : public ofstream
     40class ofits : public std::ofstream
    4641{
    4742public:
     
    8176                throw std::runtime_error("Key name empty.");
    8277#else
    83                 gLog << ___err___ << "ERROR - Key name empty." << endl;
     78                gLog << ___err___ << "ERROR - Key name empty." << std::endl;
    8479                return false;
    8580#endif
     
    9287                throw std::runtime_error(sout.str());
    9388#else
    94                 gLog << ___err___ << "ERROR - " << sout.str() << endl;
     89                gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    9590                return false;
    9691#endif
     
    107102                    throw std::runtime_error(sout.str());
    108103#else
    109                     gLog << ___err___ << "ERROR - " << sout.str() << endl;
     104                    gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    110105                    return false;
    111106#endif
     
    127122                    throw std::runtime_error(sout.str());
    128123#else
    129                     gLog << ___err___ << "ERROR - " << sout.str() << endl;
     124                    gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    130125                    return false;
    131126#endif
     
    154149                throw std::runtime_error(sout.str());
    155150#else
    156                 gLog << ___err___ << "ERROR - " << sout.str() << endl;
     151                gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    157152#endif
    158153                return false;
     
    169164                std::ostringstream sout;
    170165                sout << "Size " << sz << " of entry for key '" << key << "' exceeds 80 characters... removed comment.";
    171                 gLog << ___warn___ << "WARNING - " << sout.str() << endl;
     166                gLog << ___warn___ << "WARNING - " << sout.str() << std::endl;
    172167#endif
    173168                return true;
     
    179174            throw std::runtime_error(sout.str());
    180175#else
    181             gLog << ___err___ << "ERROR - " << sout.str() << endl;
     176            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    182177            return false;
    183178#endif
     
    199194
    200195            std::ostringstream sout;
    201             sout << std::left << setw(8) << key;
     196            sout << std::left << std::setw(8) << key;
    202197
    203198            if (!delim)
     
    209204            sout << "= ";
    210205            sout << (!value.empty() && value[0]=='\''?std::left:std::right);
    211             sout << setw(20) << value << std::left;
     206            sout << std::setw(20) << value << std::left;
    212207
    213208            if (!comment.empty())
     
    219214        Checksum checksum;
    220215
    221         void Out(ofstream &fout)
     216        void Out(std::ofstream &fout)
    222217        {
    223218            if (!changed)
     
    286281                throw std::runtime_error(sout.str());
    287282#else
    288                 gLog << ___err___ << "ERROR - " << sout.str() << endl;
     283                gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    289284                return false;
    290285#endif
     
    357352    {
    358353    }
    359     ofits(const char *fname) : ofstream(),
     354    ofits(const char *fname) : std::ofstream(),
    360355                               fCommentTrimming(false),
    361356                               fManualExtName(false)
     
    388383        SetStr("DATASUM",  "         0", "Checksum for the data block");
    389384
    390         ofstream::open(filename);
     385        std::ofstream::open(filename);
    391386    }
    392387
     
    414409            throw std::runtime_error(sout.str());
    415410#else
    416             gLog << ___err___ << "ERROR - " << sout.str() << endl;
     411            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    417412            return false;
    418413#endif
     
    462457
    463458        if (p<0)
    464             sout << setprecision(-p) << fixed;
     459            sout << std::setprecision(-p) << fixed;
    465460        if (p>0)
    466             sout << setprecision(p);
     461            sout << std::setprecision(p);
    467462        if (p==0)
    468             sout << setprecision(f>1e-100 && f<1e100 ? 15 : 14);
     463            sout << std::setprecision(f>1e-100 && f<1e100 ? 15 : 14);
    469464
    470465        sout << f;
     
    558553            throw std::runtime_error(sout.str());
    559554#else
    560             gLog << ___err___ << "ERROR - " << sout.str() << endl;
     555            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    561556            return false;
    562557#endif
     
    570565            throw std::runtime_error(sout.str());
    571566#else
    572             gLog << ___err___ << "ERROR - " << sout.str() << endl;
     567            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    573568            return false;
    574569#endif
     
    582577            throw std::runtime_error(sout.str());
    583578#else
    584             gLog << ___err___ << "ERROR - " << sout.str() << endl;
     579            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    585580            return false;
    586581#endif
     
    597592            throw std::runtime_error(sout.str());
    598593#else
    599             gLog << ___err___ << "ERROR - " << sout.str() << endl;
     594            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    600595            return false;
    601596#endif
     
    727722
    728723
    729     Checksum WriteHeader(ofstream &fout)
     724    Checksum WriteHeader(std::ofstream &fout)
    730725    {
    731726        Checksum sum;
     
    796791            throw std::runtime_error("File not empty anymore.");
    797792#else
    798             gLog << ___err___ << "ERROR - File not empty anymore." << endl;
     793            gLog << ___err___ << "ERROR - File not empty anymore." << std::endl;
    799794            return false;
    800795#endif
     
    824819        const char *pend = src + num*N;
    825820        for (const char *ptr = src; ptr<pend; ptr+=N, dest+=N)
    826             reverse_copy(ptr, ptr+N, dest);
     821            std::reverse_copy(ptr, ptr+N, dest);
    827822    }
    828823
     
    835830        if (cnt!=fTable.bytes_per_row)
    836831        {
    837             ostringstream sout;
     832            std::ostringstream sout;
    838833            sout << "WriteRow - Size " << cnt << " does not match expected size " << fTable.bytes_per_row;
    839834#ifdef __EXCEPTIONS
    840835            throw std::runtime_error(sout.str());
    841836#else
    842             gLog << ___err___ << "ERROR - " << sout.str() << endl;
     837            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    843838            return false;
    844839#endif
     
    918913    {
    919914
    920         ostringstream dataSumStr;
     915        std::ostringstream dataSumStr;
    921916        dataSumStr << fDataSum.val();
    922917        SetStr("DATASUM", dataSumStr.str());
     
    943938        const Checksum chk = UpdateHeaderChecksum();
    944939
    945         ofstream::close();
     940        std::ofstream::close();
    946941
    947942        if ((chk+fDataSum).valid())
    948943            return true;
    949944
    950         ostringstream sout;
     945        std::ostringstream sout;
    951946        sout << "Checksum (" << std::hex << chk.val() << ") invalid.";
    952947#ifdef __EXCEPTIONS
    953948        throw std::runtime_error(sout.str());
    954949#else
    955         gLog << ___err___ << "ERROR - " << sout.str() << endl;
     950        gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    956951        return false;
    957952#endif
    958953    }
    959954
    960     pair<string, int> GetChecksumData()
     955    std::pair<std::string, int> GetChecksumData()
    961956    {
    962957        std::string datasum;
     
    972967        if (datasum[0] == '\'')
    973968            datasum = datasum.substr(1, datasum.size()-2);
    974         return make_pair(checksum, atoi(datasum.c_str()));
     969        return std::make_pair(checksum, atoi(datasum.c_str()));
    975970    }
    976971
     
    997992    }
    998993};
    999 
    1000 #ifndef __MARS__
    1001 };
    1002 #endif
    1003994
    1004995#if 0
  • trunk/Mars/mcore/zofits.h

    r17263 r17264  
    1010
    1111#include "ofits.h"
    12 #include "zfits.h"
     12#include "huffman.h"
    1313#include "Queue.h"
    1414#include "MemoryManager.h"
     
    1616#ifdef USE_BOOST_THREADS
    1717#include <boost/thread.hpp>
    18 #endif
    19 
    20 #ifndef __MARS__
    21 namespace std
    22 {
    2318#endif
    2419
     
    3934        struct CatalogEntry
    4035        {
    41             CatalogEntry(int64_t f=0, int64_t s=0) : first(f), second(s) {};
     36            CatalogEntry(int64_t f=0, int64_t s=0) : first(f), second(s) { }
    4237            int64_t first;   ///< Size of this column in the tile
    4338            int64_t second;  ///< offset of this column in the tile, from the start of the heap area
    4439        } __attribute__((__packed__));
    4540
    46         typedef vector<CatalogEntry> CatalogRow;
    47         typedef list<CatalogRow>     CatalogType;
     41        typedef std::vector<CatalogEntry> CatalogRow;
     42        typedef std::list<CatalogRow>     CatalogType;
    4843
    4944
     
    5954            WriteTarget(const WriteTarget &t, uint32_t sz) : tile_num(t.tile_num), size(sz), data(t.data) { }
    6055
    61             uint32_t         tile_num; ///< Tile index of the data (to make sure that they are written in the correct order)
    62             uint32_t         size;     ///< Size to write
    63             shared_ptr<char> data;     ///< Memory block to write
     56            uint32_t              tile_num; ///< Tile index of the data (to make sure that they are written in the correct order)
     57            uint32_t              size;     ///< Size to write
     58            std::shared_ptr<char> data;     ///< Memory block to write
    6459        };
    6560
     
    7166            {}
    7267
    73             CatalogRow&      catalog_entry;   ///< Reference to the catalog entry to deal with
    74             shared_ptr<char> src;             ///< Original data
    75             shared_ptr<char> transposed_src;  ///< Transposed data
    76             WriteTarget      target;          ///< Compressed data
    77             uint32_t         num_rows;        ///< Number of rows to compress
     68            CatalogRow&           catalog_entry;   ///< Reference to the catalog entry to deal with
     69            std::shared_ptr<char> src;             ///< Original data
     70            std::shared_ptr<char> transposed_src;  ///< Transposed data
     71            WriteTarget           target;          ///< Compressed data
     72            uint32_t              num_rows;        ///< Number of rows to compress
    7873         };
    7974
     
    9287               uint32_t rowPerTile  = DefaultNumRowsPerTile(),
    9388               uint32_t maxUsableMem= DefaultMaxMemory()) : ofits(),
    94                                                         fMemPool(0, maxUsableMem*1000),
    95                                                         fWriteToDiskQueue(bind(&zofits::WriteBufferToDisk, this, placeholders::_1), false)
     89            fMemPool(0, maxUsableMem*1000),
     90            fWriteToDiskQueue(std::bind(&zofits::WriteBufferToDisk, this, std::placeholders::_1), false)
    9691        {
    9792            InitMemberVariables(numTiles, rowPerTile, maxUsableMem*1000);
     
    107102               uint32_t rowPerTile  = DefaultNumRowsPerTile(),
    108103               uint32_t maxUsableMem= DefaultMaxMemory()) : ofits(fname),
    109                                                         fMemPool(0, maxUsableMem*1000),
    110                                                         fWriteToDiskQueue(bind(&zofits::WriteBufferToDisk, this, placeholders::_1), false)
     104                   fMemPool(0, maxUsableMem*1000),
     105                   fWriteToDiskQueue(std::bind(&zofits::WriteBufferToDisk, this, std::placeholders::_1), false)
    111106        {
    112107            InitMemberVariables(numTiles, rowPerTile, maxUsableMem*1000);
     
    132127            fMaxUsableMem = maxUsableMem;
    133128#ifdef __EXCEPTIONS
    134             fThreadsException = exception_ptr();
     129            fThreadsException = std::exception_ptr();
    135130#endif
    136131            fErrno = 0;
     
    208203
    209204            // swap the catalog bytes before writing
    210             vector<char> swapped_catalog(total_catalog_size);
     205            std::vector<char> swapped_catalog(total_catalog_size);
    211206
    212207            uint32_t shift = 0;
     
    272267            {
    273268#ifdef __EXCEPTIONS
    274                 throw runtime_error("Wrong size of row given to WriteRow");
     269                throw std::runtime_error("Wrong size of row given to WriteRow");
    275270#else
    276                 gLog << ___err___ << "ERROR - Wrong size of row given to WriteRow" << endl;
     271                gLog << ___err___ << "ERROR - Wrong size of row given to WriteRow" << std::endl;
    277272                return false;
    278273#endif
     
    282277            //check if something hapenned while the compression threads were working
    283278            //if so, re-throw the exception that was generated
    284             if (fThreadsException != exception_ptr())
    285                 rethrow_exception(fThreadsException);
     279            if (fThreadsException != std::exception_ptr())
     280                std::rethrow_exception(fThreadsException);
    286281#endif
    287282            //copy current row to pool or rows waiting for compression
     
    331326                const WriteTarget write_target(compress_target.target, size_to_write);
    332327                if (!WriteBufferToDisk(write_target))
    333                     throw runtime_error("Unexpected tile number mismatch in WriteBufferToDisk in the main thread.");
     328                    throw std::runtime_error("Unexpected tile number mismatch in WriteBufferToDisk in the main thread.");
    334329
    335330                // The correct 'errno' is set, because it is the main thread.
     
    339334            //if all queues are empty, use queue 0
    340335            uint32_t min_index     = 0;
    341             uint32_t min_size      = numeric_limits<uint32_t>::max();
     336            uint32_t min_size      = std::numeric_limits<uint32_t>::max();
    342337            uint32_t current_index = 0;
    343338
     
    353348
    354349            if (!fCompressionQueues[min_index].emplace(compress_target))
    355                 throw runtime_error("The compression queues are not started. Did you close the file before writing this row?");
     350                throw std::runtime_error("The compression queues are not started. Did you close the file before writing this row?");
    356351
    357352            errno = fErrno;
     
    448443            //check if something hapenned while the compression threads were working
    449444            //if so, re-throw the exception that was generated
    450             if (fThreadsException != exception_ptr())
    451                 rethrow_exception(fThreadsException);
     445            if (fThreadsException != std::exception_ptr())
     446                std::rethrow_exception(fThreadsException);
    452447#endif
    453448
     
    467462                const WriteTarget write_target(compress_target.target, size_to_write);
    468463                if (!WriteBufferToDisk(write_target))
    469                     throw runtime_error("Tile number mismatch in WriteBufferToDisk writing the last tile.");
     464                    throw std::runtime_error("Tile number mismatch in WriteBufferToDisk writing the last tile.");
    470465            }
    471466
     
    502497            SetInt("NAXIS1", total_catalog_width);
    503498            SetInt("NAXIS2", total_num_tiles_written);
    504             SetStr("RAWSUM", to_string(fRawSum.val()));
     499            SetStr("RAWSUM", std::to_string(fRawSum.val()));
    505500
    506501            const float compression_ratio = (float)(fRealRowWidth*fTable.num_rows)/(float)heap_size;
     
    519514            const Checksum checksm = UpdateHeaderChecksum();
    520515
    521             ofstream::close();
     516            std::ofstream::close();
    522517
    523518            if ((checksm+fDataSum).valid())
    524519                return true;
    525520
    526             ostringstream sout;
     521            std::ostringstream sout;
    527522            sout << "Checksum (" << std::hex << checksm.val() << ") invalid.";
    528523#ifdef __EXCEPTIONS
    529             throw runtime_error(sout.str());
     524            throw std::runtime_error(sout.str());
    530525#else
    531             gLog << ___err___ << "ERROR - " << sout.str() << endl;
     526            gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
    532527            return false;
    533528#endif
     
    535530
    536531        /// Overload of the ofits method. Just calls the zofits specific one with default, uncompressed options for this column
    537         bool AddColumn(uint32_t cnt, char typechar, const string& name, const string& unit, const string& comment="", bool addHeaderKeys=true)
     532        bool AddColumn(uint32_t cnt, char typechar, const std::string& name, const std::string& unit,
     533                       const std::string& comment="", bool addHeaderKeys=true)
    538534        {
    539535            return AddColumn(FITS::kFactRaw, cnt, typechar, name, unit, comment, addHeaderKeys);
     
    541537
    542538        /// Overload of the simplified compressed version
    543         bool AddColumn(const FITS::Compression &comp, uint32_t cnt, char typechar, const string& name, const string& unit, const string& comment="", bool addHeaderKeys=true)
     539        bool AddColumn(const FITS::Compression &comp, uint32_t cnt, char typechar, const std::string& name,
     540                       const std::string& unit, const std::string& comment="", bool addHeaderKeys=true)
    544541        {
    545542            if (!ofits::AddColumn(1, 'Q', name, unit, comment, addHeaderKeys))
     
    559556            fRealColumns.emplace_back(col, comp);
    560557
    561             SetStr("ZFORM"+to_string(fRealColumns.size()), to_string(cnt)+typechar, "format of "+name+" "+CommentFromType(typechar));
    562             SetStr("ZCTYP"+to_string(fRealColumns.size()), "FACT", "Compression type: FACT");
     558            SetStr("ZFORM"+std::to_string(fRealColumns.size()), std::to_string(cnt)+typechar, "format of "+name+" "+CommentFromType(typechar));
     559            SetStr("ZCTYP"+std::to_string(fRealColumns.size()), "FACT", "Compression type: FACT");
    563560
    564561            return true;
     
    572569            {
    573570#ifdef __EXCEPTIONS
    574                 throw runtime_error("File must be closed before changing the number of compression threads");
     571                throw std::runtime_error("File must be closed before changing the number of compression threads");
    575572#else
    576                 gLog << ___err___ << "ERROR - File must be closed before changing the number of compression threads" << endl;
     573                gLog << ___err___ << "ERROR - File must be closed before changing the number of compression threads" << std::endl;
    577574#endif
    578575                return false;
     
    583580            unsigned int num_available_cores = boost::thread::hardware_concurrency();
    584581#else
    585             unsigned int num_available_cores = thread::hardware_concurrency();
     582            unsigned int num_available_cores = std::thread::hardware_concurrency();
    586583#endif
    587584            // could not detect number of available cores from system properties...
     
    595592            if (fCompressionQueues.size() != uint32_t(num))
    596593            {
    597                 fCompressionQueues.resize(num, Queue<CompressionTarget>(bind(&zofits::CompressBuffer, this, placeholders::_1), false));
     594                fCompressionQueues.resize(num, Queue<CompressionTarget>(std::bind(&zofits::CompressBuffer, this, std::placeholders::_1), false));
    598595                fNumQueues = num;
    599596            }
     
    664661//            for (uint32_t i=0;i<thisRoundNumRows;i++)
    665662//            {
    666 //                char* target_location = target.src.get()->get() + fRealRowWidth*i;
     663//                char* target_location = target.src.get() + fRealRowWidth*i;
    667664//                cout << "Target Location there...." << hex << static_cast<void*>(target_location) << endl;
    668665//                DrsOffsetCalibrate(target_location);
     
    682679            catch (...)
    683680            {
    684                 fThreadsException = current_exception();
     681                fThreadsException = std::current_exception();
    685682                if (fNumQueues == 0)
    686                     rethrow_exception(fThreadsException);
     683                    std::rethrow_exception(fThreadsException);
    687684            }
    688685#endif
     
    720717            catch (...)
    721718            {
    722                 fThreadsException = current_exception();
     719                fThreadsException = std::current_exception();
    723720                if (fNumQueues == 0)
    724                     rethrow_exception(fThreadsException);
     721                    std::rethrow_exception(fThreadsException);
    725722            }
    726723#endif
     
    871868        uint32_t compressHUFFMAN16(char* dest, const char* src, uint32_t numRows, uint32_t sizeOfElems, uint32_t numRowElems)
    872869        {
    873             string huffmanOutput;
     870            std::string huffmanOutput;
    874871            uint32_t previousHuffmanSize = 0;
    875872
     
    881878            {
    882879#ifdef __EXCEPTIONS
    883                 throw runtime_error("HUFMANN16 can only encode columns with 16-bit or longer types");
     880                throw std::runtime_error("HUFMANN16 can only encode columns with 16-bit or longer types");
    884881#else
    885                 gLog << ___err___ << "ERROR - HUFMANN16 can only encode columns with 16-bit or longer types" << endl;
     882                gLog << ___err___ << "ERROR - HUFMANN16 can only encode columns with 16-bit or longer types" << std::endl;
    886883                return 0;
    887884#endif
     
    942939        int32_t         fLatestWrittenTile; ///< Index of the last tile written to disk (for correct ordering while using several threads)
    943940
    944         vector<Queue<CompressionTarget>>          fCompressionQueues;  ///< Processing queues (=threads)
     941        std::vector<Queue<CompressionTarget>>          fCompressionQueues;  ///< Processing queues (=threads)
    945942        Queue<WriteTarget, QueueMin<WriteTarget>> fWriteToDiskQueue;   ///< Writing queue (=thread)
    946943
     
    967964            FITS::Compression block_head;  ///< the compression data associated with that column
    968965        };
    969         vector<CompressedColumn> fRealColumns;     ///< Vector hosting the columns of the file
    970         uint32_t                 fRealRowWidth;    ///< Width in bytes of one uncompressed row
    971         shared_ptr<char>         fSmartBuffer;     ///< Smart pointer to the buffer where the incoming rows are written
    972         vector<char>             fRawSumBuffer;    ///< buffer used for checksuming the incoming data, before compression
    973 
    974 #ifdef __EXCEPTIONS
    975         exception_ptr     fThreadsException; ///< exception pointer to store exceptions coming from the threads
    976 #endif
    977         int               fErrno;            ///< propagate errno to main thread
    978 
    979 
     966        std::vector<CompressedColumn> fRealColumns;     ///< Vector hosting the columns of the file
     967        uint32_t                      fRealRowWidth;    ///< Width in bytes of one uncompressed row
     968        std::shared_ptr<char>         fSmartBuffer;     ///< Smart pointer to the buffer where the incoming rows are written
     969        std::vector<char>             fRawSumBuffer;    ///< buffer used for checksuming the incoming data, before compression
     970
     971#ifdef __EXCEPTIONS
     972        std::exception_ptr fThreadsException; ///< exception pointer to store exceptions coming from the threads
     973#endif
     974        int                fErrno;            ///< propagate errno to main thread
    980975};
    981976
    982 #ifndef __MARS__
    983 }; //namespace std
    984 #endif
    985 
    986 #endif
     977#endif
Note: See TracChangeset for help on using the changeset viewer.