Changeset 17264 for trunk/Mars/mcore
- Timestamp:
- 10/18/13 17:52:38 (11 years ago)
- Location:
- trunk/Mars/mcore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/checksum.h
r17141 r17264 7 7 8 8 #include <stdint.h> 9 10 namespace std11 {12 9 13 10 class Checksum … … 43 40 return *this; 44 41 } 42 45 43 Checksum operator+(Checksum sum) const 46 44 { … … 60 58 if (len%4>0) 61 59 { 62 ostringstream sout;63 sout << "Length " << len << " not dividable by 4 ." << endl;60 std::ostringstream sout; 61 sout << "Length " << len << " not dividable by 4"; 64 62 65 63 #ifdef __EXCEPTIONS 66 throw runtime_error(sout.str());64 throw std::runtime_error(sout.str()); 67 65 #else 68 66 gLog << ___err___ << "ERROR - " << sout.str() << endl; … … 143 141 } 144 142 145 bool add(const vector<char> &v, bool big_endian = true)143 bool add(const std::vector<char> &v, bool big_endian = true) 146 144 { 147 145 return add(v.data(), v.size(), big_endian); 148 146 } 149 147 150 st ring str(bool complm=true) const151 { 152 st ring rc(16,0);148 std::string str(bool complm=true) const 149 { 150 std::string rc(16,0); 153 151 154 152 const uint8_t exclude[13] = … … 241 239 } 242 240 }; 243 }244 241 245 242 #endif -
trunk/Mars/mcore/factfits.h
r17038 r17264 11 11 #include "zfits.h" 12 12 13 #ifndef __MARS__14 namespace std15 {16 #endif17 18 13 class factfits : public zfits 19 14 { 20 15 public: 21 16 // Default constructor 22 factfits(const st ring& fname, conststring& tableName="", bool force=false) :17 factfits(const std::string& fname, const std::string& tableName="", bool force=false) : 23 18 zfits(fname, tableName, force), 24 19 fOffsetCalibration(0), … … 32 27 33 28 // Alternative constructor 34 factfits(const st ring& fname, const string& fout, conststring& tableName, bool force=false) :29 factfits(const std::string& fname, const std::string& fout, const std::string& tableName, bool force=false) : 35 30 zfits(fname, fout, tableName, force), 36 31 fOffsetCalibration(0), … … 48 43 { 49 44 zfits::StageRow(row, dest); 45 50 46 // This file does not contain fact data or no calibration to be applied 51 52 53 54 55 56 57 58 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); 59 55 60 56 /* … … 71 67 */ 72 68 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 } 101 97 102 98 bool init() … … 129 125 130 126 // Read the Drs calibration data 131 void readDrsCalib(const st ring& fileName)127 void readDrsCalib(const std::string& fileName) 132 128 { 133 129 //should not be mandatory, but improves the perfs a lot when reading not compressed, gzipped files … … 205 201 }; //class factfits 206 202 207 #ifndef __MARS__ 208 }; //namespace std 209 #endif 210 211 #endif 203 #endif -
trunk/Mars/mcore/factofits.h
r17263 r17264 12 12 #include "DrsCalib.h" 13 13 14 #ifndef __MARS__15 namespace std16 {17 #endif18 19 14 class factofits : public zofits 20 15 { 21 22 16 public: 23 17 … … 50 44 51 45 ///assign a given drs offset calibration 52 void SetDrsCalibration(const vector<float> &calib)46 void SetDrsCalibration(const std::vector<float> &calib) 53 47 { 54 48 VerifyCalibrationSize(calib.size()); … … 62 56 63 57 ///assign a given drs offset calibration 64 void SetDrsCalibration(const vector<int16_t>& vec)58 void SetDrsCalibration(const std::vector<int16_t>& vec) 65 59 { 66 60 VerifyCalibrationSize(vec.size()); … … 110 104 { 111 105 #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."); 113 107 #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; 115 109 #endif 116 110 fOffsetCalibration.resize(0); … … 123 117 { 124 118 #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."); 126 120 #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; 128 122 #endif 129 123 //throw away the calibration data … … 134 128 { 135 129 #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."); 137 131 #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; 139 133 #endif 140 134 //throw away the calibration data … … 174 168 datasum.add(swappedOffsets.data(), sizeof(int16_t)*1024*1440); 175 169 176 ostringstream dataSumStr;170 std::ostringstream dataSumStr; 177 171 dataSumStr << datasum.val(); 178 172 c.SetStr("DATASUM", dataSumStr.str()); … … 241 235 Checksum rawsum; 242 236 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())); 244 238 245 239 //compress data and calculate final, compressed size … … 281 275 c.SetFloat("ZRATIO", (float)(1024*1440*2)/(float)(compressed_size)); 282 276 c.SetInt("PCOUNT", compressed_size + catalog_size); 283 c.SetStr("DATASUM", to_string(datasum.val()));277 c.SetStr("DATASUM", std::to_string(datasum.val())); 284 278 285 279 datasum += c.WriteHeader(*this); … … 339 333 return true; 340 334 341 ostringstream str;335 std::ostringstream str; 342 336 str << "Cannot load calibration with anything else than 1440 pixels and 1024 samples per pixel. Got a total size of " << size; 343 337 #ifdef __EXCEPTIONS 344 throw runtime_error(str.str());338 throw std::runtime_error(str.str()); 345 339 #else 346 gLog << ___err___ << "ERROR - " << str.str() << endl;340 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 347 341 return false; 348 342 #endif … … 350 344 351 345 //Offsets calibration stuff. 352 vector<int16_t> fOffsetCalibration; ///< The calibration itself346 std::vector<int16_t> fOffsetCalibration; ///< The calibration itself 353 347 int32_t fStartCellsOffset; ///< Offset in bytes for the startcell data 354 348 int32_t fDataOffset; ///< Offset in bytes for the data … … 357 351 }; //class factofits 358 352 359 #ifndef __MARS360 }; //namespace std361 #endif362 363 353 #endif /* FACTOFITS_H_ */ -
trunk/Mars/mcore/ofits.h
r17263 r17264 33 33 #include "checksum.h" 34 34 35 #ifndef __MARS__36 namespace std37 {38 #endif39 40 35 // Sloppy: allow / <--- left 41 36 // allow all characters (see specs for what is possible) … … 43 38 // units: m kg s rad sr K A mol cd Hz J W V N Pa C Ohm S F Wb T Hlm lx 44 39 45 class ofits : public ofstream40 class ofits : public std::ofstream 46 41 { 47 42 public: … … 81 76 throw std::runtime_error("Key name empty."); 82 77 #else 83 gLog << ___err___ << "ERROR - Key name empty." << endl;78 gLog << ___err___ << "ERROR - Key name empty." << std::endl; 84 79 return false; 85 80 #endif … … 92 87 throw std::runtime_error(sout.str()); 93 88 #else 94 gLog << ___err___ << "ERROR - " << sout.str() << endl;89 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 95 90 return false; 96 91 #endif … … 107 102 throw std::runtime_error(sout.str()); 108 103 #else 109 gLog << ___err___ << "ERROR - " << sout.str() << endl;104 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 110 105 return false; 111 106 #endif … … 127 122 throw std::runtime_error(sout.str()); 128 123 #else 129 gLog << ___err___ << "ERROR - " << sout.str() << endl;124 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 130 125 return false; 131 126 #endif … … 154 149 throw std::runtime_error(sout.str()); 155 150 #else 156 gLog << ___err___ << "ERROR - " << sout.str() << endl;151 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 157 152 #endif 158 153 return false; … … 169 164 std::ostringstream sout; 170 165 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; 172 167 #endif 173 168 return true; … … 179 174 throw std::runtime_error(sout.str()); 180 175 #else 181 gLog << ___err___ << "ERROR - " << sout.str() << endl;176 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 182 177 return false; 183 178 #endif … … 199 194 200 195 std::ostringstream sout; 201 sout << std::left << s etw(8) << key;196 sout << std::left << std::setw(8) << key; 202 197 203 198 if (!delim) … … 209 204 sout << "= "; 210 205 sout << (!value.empty() && value[0]=='\''?std::left:std::right); 211 sout << s etw(20) << value << std::left;206 sout << std::setw(20) << value << std::left; 212 207 213 208 if (!comment.empty()) … … 219 214 Checksum checksum; 220 215 221 void Out( ofstream &fout)216 void Out(std::ofstream &fout) 222 217 { 223 218 if (!changed) … … 286 281 throw std::runtime_error(sout.str()); 287 282 #else 288 gLog << ___err___ << "ERROR - " << sout.str() << endl;283 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 289 284 return false; 290 285 #endif … … 357 352 { 358 353 } 359 ofits(const char *fname) : ofstream(),354 ofits(const char *fname) : std::ofstream(), 360 355 fCommentTrimming(false), 361 356 fManualExtName(false) … … 388 383 SetStr("DATASUM", " 0", "Checksum for the data block"); 389 384 390 ofstream::open(filename);385 std::ofstream::open(filename); 391 386 } 392 387 … … 414 409 throw std::runtime_error(sout.str()); 415 410 #else 416 gLog << ___err___ << "ERROR - " << sout.str() << endl;411 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 417 412 return false; 418 413 #endif … … 462 457 463 458 if (p<0) 464 sout << s etprecision(-p) << fixed;459 sout << std::setprecision(-p) << fixed; 465 460 if (p>0) 466 sout << s etprecision(p);461 sout << std::setprecision(p); 467 462 if (p==0) 468 sout << s etprecision(f>1e-100 && f<1e100 ? 15 : 14);463 sout << std::setprecision(f>1e-100 && f<1e100 ? 15 : 14); 469 464 470 465 sout << f; … … 558 553 throw std::runtime_error(sout.str()); 559 554 #else 560 gLog << ___err___ << "ERROR - " << sout.str() << endl;555 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 561 556 return false; 562 557 #endif … … 570 565 throw std::runtime_error(sout.str()); 571 566 #else 572 gLog << ___err___ << "ERROR - " << sout.str() << endl;567 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 573 568 return false; 574 569 #endif … … 582 577 throw std::runtime_error(sout.str()); 583 578 #else 584 gLog << ___err___ << "ERROR - " << sout.str() << endl;579 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 585 580 return false; 586 581 #endif … … 597 592 throw std::runtime_error(sout.str()); 598 593 #else 599 gLog << ___err___ << "ERROR - " << sout.str() << endl;594 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 600 595 return false; 601 596 #endif … … 727 722 728 723 729 Checksum WriteHeader( ofstream &fout)724 Checksum WriteHeader(std::ofstream &fout) 730 725 { 731 726 Checksum sum; … … 796 791 throw std::runtime_error("File not empty anymore."); 797 792 #else 798 gLog << ___err___ << "ERROR - File not empty anymore." << endl;793 gLog << ___err___ << "ERROR - File not empty anymore." << std::endl; 799 794 return false; 800 795 #endif … … 824 819 const char *pend = src + num*N; 825 820 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); 827 822 } 828 823 … … 835 830 if (cnt!=fTable.bytes_per_row) 836 831 { 837 ostringstream sout;832 std::ostringstream sout; 838 833 sout << "WriteRow - Size " << cnt << " does not match expected size " << fTable.bytes_per_row; 839 834 #ifdef __EXCEPTIONS 840 835 throw std::runtime_error(sout.str()); 841 836 #else 842 gLog << ___err___ << "ERROR - " << sout.str() << endl;837 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 843 838 return false; 844 839 #endif … … 918 913 { 919 914 920 ostringstream dataSumStr;915 std::ostringstream dataSumStr; 921 916 dataSumStr << fDataSum.val(); 922 917 SetStr("DATASUM", dataSumStr.str()); … … 943 938 const Checksum chk = UpdateHeaderChecksum(); 944 939 945 ofstream::close();940 std::ofstream::close(); 946 941 947 942 if ((chk+fDataSum).valid()) 948 943 return true; 949 944 950 ostringstream sout;945 std::ostringstream sout; 951 946 sout << "Checksum (" << std::hex << chk.val() << ") invalid."; 952 947 #ifdef __EXCEPTIONS 953 948 throw std::runtime_error(sout.str()); 954 949 #else 955 gLog << ___err___ << "ERROR - " << sout.str() << endl;950 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 956 951 return false; 957 952 #endif 958 953 } 959 954 960 pair<string, int> GetChecksumData()955 std::pair<std::string, int> GetChecksumData() 961 956 { 962 957 std::string datasum; … … 972 967 if (datasum[0] == '\'') 973 968 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())); 975 970 } 976 971 … … 997 992 } 998 993 }; 999 1000 #ifndef __MARS__1001 };1002 #endif1003 994 1004 995 #if 0 -
trunk/Mars/mcore/zofits.h
r17263 r17264 10 10 11 11 #include "ofits.h" 12 #include " zfits.h"12 #include "huffman.h" 13 13 #include "Queue.h" 14 14 #include "MemoryManager.h" … … 16 16 #ifdef USE_BOOST_THREADS 17 17 #include <boost/thread.hpp> 18 #endif19 20 #ifndef __MARS__21 namespace std22 {23 18 #endif 24 19 … … 39 34 struct CatalogEntry 40 35 { 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) { } 42 37 int64_t first; ///< Size of this column in the tile 43 38 int64_t second; ///< offset of this column in the tile, from the start of the heap area 44 39 } __attribute__((__packed__)); 45 40 46 typedef vector<CatalogEntry> CatalogRow;47 typedef list<CatalogRow> CatalogType;41 typedef std::vector<CatalogEntry> CatalogRow; 42 typedef std::list<CatalogRow> CatalogType; 48 43 49 44 … … 59 54 WriteTarget(const WriteTarget &t, uint32_t sz) : tile_num(t.tile_num), size(sz), data(t.data) { } 60 55 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 write63 s hared_ptr<char> data; ///< Memory block to write56 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 64 59 }; 65 60 … … 71 66 {} 72 67 73 CatalogRow& catalog_entry; ///< Reference to the catalog entry to deal with74 s hared_ptr<char> src; ///< Original data75 s hared_ptr<char> transposed_src; ///< Transposed data76 WriteTarget target; ///< Compressed data77 uint32_t num_rows; ///< Number of rows to compress68 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 78 73 }; 79 74 … … 92 87 uint32_t rowPerTile = DefaultNumRowsPerTile(), 93 88 uint32_t maxUsableMem= DefaultMaxMemory()) : ofits(), 94 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) 96 91 { 97 92 InitMemberVariables(numTiles, rowPerTile, maxUsableMem*1000); … … 107 102 uint32_t rowPerTile = DefaultNumRowsPerTile(), 108 103 uint32_t maxUsableMem= DefaultMaxMemory()) : ofits(fname), 109 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) 111 106 { 112 107 InitMemberVariables(numTiles, rowPerTile, maxUsableMem*1000); … … 132 127 fMaxUsableMem = maxUsableMem; 133 128 #ifdef __EXCEPTIONS 134 fThreadsException = exception_ptr();129 fThreadsException = std::exception_ptr(); 135 130 #endif 136 131 fErrno = 0; … … 208 203 209 204 // swap the catalog bytes before writing 210 vector<char> swapped_catalog(total_catalog_size);205 std::vector<char> swapped_catalog(total_catalog_size); 211 206 212 207 uint32_t shift = 0; … … 272 267 { 273 268 #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"); 275 270 #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; 277 272 return false; 278 273 #endif … … 282 277 //check if something hapenned while the compression threads were working 283 278 //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); 286 281 #endif 287 282 //copy current row to pool or rows waiting for compression … … 331 326 const WriteTarget write_target(compress_target.target, size_to_write); 332 327 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."); 334 329 335 330 // The correct 'errno' is set, because it is the main thread. … … 339 334 //if all queues are empty, use queue 0 340 335 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(); 342 337 uint32_t current_index = 0; 343 338 … … 353 348 354 349 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?"); 356 351 357 352 errno = fErrno; … … 448 443 //check if something hapenned while the compression threads were working 449 444 //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); 452 447 #endif 453 448 … … 467 462 const WriteTarget write_target(compress_target.target, size_to_write); 468 463 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."); 470 465 } 471 466 … … 502 497 SetInt("NAXIS1", total_catalog_width); 503 498 SetInt("NAXIS2", total_num_tiles_written); 504 SetStr("RAWSUM", to_string(fRawSum.val()));499 SetStr("RAWSUM", std::to_string(fRawSum.val())); 505 500 506 501 const float compression_ratio = (float)(fRealRowWidth*fTable.num_rows)/(float)heap_size; … … 519 514 const Checksum checksm = UpdateHeaderChecksum(); 520 515 521 ofstream::close();516 std::ofstream::close(); 522 517 523 518 if ((checksm+fDataSum).valid()) 524 519 return true; 525 520 526 ostringstream sout;521 std::ostringstream sout; 527 522 sout << "Checksum (" << std::hex << checksm.val() << ") invalid."; 528 523 #ifdef __EXCEPTIONS 529 throw runtime_error(sout.str());524 throw std::runtime_error(sout.str()); 530 525 #else 531 gLog << ___err___ << "ERROR - " << sout.str() << endl;526 gLog << ___err___ << "ERROR - " << sout.str() << std::endl; 532 527 return false; 533 528 #endif … … 535 530 536 531 /// 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) 538 534 { 539 535 return AddColumn(FITS::kFactRaw, cnt, typechar, name, unit, comment, addHeaderKeys); … … 541 537 542 538 /// 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) 544 541 { 545 542 if (!ofits::AddColumn(1, 'Q', name, unit, comment, addHeaderKeys)) … … 559 556 fRealColumns.emplace_back(col, comp); 560 557 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"); 563 560 564 561 return true; … … 572 569 { 573 570 #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"); 575 572 #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; 577 574 #endif 578 575 return false; … … 583 580 unsigned int num_available_cores = boost::thread::hardware_concurrency(); 584 581 #else 585 unsigned int num_available_cores = thread::hardware_concurrency();582 unsigned int num_available_cores = std::thread::hardware_concurrency(); 586 583 #endif 587 584 // could not detect number of available cores from system properties... … … 595 592 if (fCompressionQueues.size() != uint32_t(num)) 596 593 { 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)); 598 595 fNumQueues = num; 599 596 } … … 664 661 // for (uint32_t i=0;i<thisRoundNumRows;i++) 665 662 // { 666 // char* target_location = target.src.get() ->get()+ fRealRowWidth*i;663 // char* target_location = target.src.get() + fRealRowWidth*i; 667 664 // cout << "Target Location there...." << hex << static_cast<void*>(target_location) << endl; 668 665 // DrsOffsetCalibrate(target_location); … … 682 679 catch (...) 683 680 { 684 fThreadsException = current_exception();681 fThreadsException = std::current_exception(); 685 682 if (fNumQueues == 0) 686 rethrow_exception(fThreadsException);683 std::rethrow_exception(fThreadsException); 687 684 } 688 685 #endif … … 720 717 catch (...) 721 718 { 722 fThreadsException = current_exception();719 fThreadsException = std::current_exception(); 723 720 if (fNumQueues == 0) 724 rethrow_exception(fThreadsException);721 std::rethrow_exception(fThreadsException); 725 722 } 726 723 #endif … … 871 868 uint32_t compressHUFFMAN16(char* dest, const char* src, uint32_t numRows, uint32_t sizeOfElems, uint32_t numRowElems) 872 869 { 873 st ring huffmanOutput;870 std::string huffmanOutput; 874 871 uint32_t previousHuffmanSize = 0; 875 872 … … 881 878 { 882 879 #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"); 884 881 #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; 886 883 return 0; 887 884 #endif … … 942 939 int32_t fLatestWrittenTile; ///< Index of the last tile written to disk (for correct ordering while using several threads) 943 940 944 vector<Queue<CompressionTarget>> fCompressionQueues; ///< Processing queues (=threads)941 std::vector<Queue<CompressionTarget>> fCompressionQueues; ///< Processing queues (=threads) 945 942 Queue<WriteTarget, QueueMin<WriteTarget>> fWriteToDiskQueue; ///< Writing queue (=thread) 946 943 … … 967 964 FITS::Compression block_head; ///< the compression data associated with that column 968 965 }; 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 980 975 }; 981 976 982 #ifndef __MARS__ 983 }; //namespace std 984 #endif 985 986 #endif 977 #endif
Note:
See TracChangeset
for help on using the changeset viewer.