00001 #include "RawDataWriter.h"
00002 #include "scan.h"
00003 #include "ScanWriterFactory.h"
00004 #include "ScanResultWriter.h"
00005 #include "dataTypes.h"
00006 #include "Sct/UnsupportedOperationError.h"
00007
00008 using namespace std;
00009
00010 namespace SctData {
00011
00012
00013 bool RawDataWriter::inMap = ScanWriterFactory::getFactory().addWriterToMap(SR_DT_RAWHIST, ScanResultWriter::getRawWriter(), *(new RawDataWriter())) && ScanWriterFactory::getFactory().addWriterToMap(SR_DT_SLICE_COMPRESSED, ScanResultWriter::getRawWriter(), *(new RawDataWriter()));
00014
00015
00016 void RawDataWriter::writeData(scan_result_ptrs& scanResult, OStream& out) {
00017 ScanResultWriter::writeClass("RawRawData", out);
00018
00019
00020 switch (scanResult.header.width) {
00021 case SR_WD_32: {
00022 out << scanResult.header.size/2 << scanResult.header.dataType << scanResult.header.width;
00023
00024 UINT32* data = reinterpret_cast<UINT32*>(scanResult.data);
00025 out.put(data, scanResult.header.size/2);
00026 }
00027 break;
00028
00029 case SR_WD_16: {
00030
00031 out << scanResult.header.size << scanResult.header.dataType << scanResult.header.width;
00032
00033 UINT16* data = reinterpret_cast<UINT16*>(scanResult.data);
00034 out.put(data, scanResult.header.size);
00035 }
00036 break;
00037
00038 default:
00039 ostringstream oss;
00040 oss << "RawDataWriter only supports 16 and 32 bit widths, was given: " << scanResult.header.width;
00041 throw UnsupportedOperationError(oss.str(), __FILE__, __LINE__);
00042 break;
00043 }
00044 }
00045
00046 }