#include <DataFile1D.h>
Inherits ICLIB::DataFile.
Inheritance diagram for ICLIB::DataFile1D:


Public Member Functions | |
| DataFile1D () | |
| virtual | ~DataFile1D () |
| virtual void | load (const std::string &filename) |
| virtual void | save (const std::string &filename) |
| void | getArrayValues (vector< double > &aray, int &xdim, int &ydim) |
| void | setArrayValues (const vector< double > &aray, int xdim, int ydim) |
Definition at line 8 of file DataFile1D.h.
|
|
Definition at line 6 of file DataFile1D.cpp. References ICLIB::DataFile::mFilename. 00006 { 00007 mFilename = "<unknown filename>"; 00008 }
|
|
|
Definition at line 10 of file DataFile1D.cpp.
|
|
||||||||||||||||
|
Implements ICLIB::DataFile. Definition at line 96 of file DataFile1D.cpp. References ICLIB::DataFile::mValues. 00096 { 00097 xdim = 0; 00098 ydim = 0; 00099 if(mValues.size()>0) { 00100 xdim = mValues[0].second.size(); 00101 ydim = mValues.size(); 00102 aray.resize(xdim*ydim); 00103 for(int j=0; j<ydim; ++j) { 00104 for(int i=0; i<xdim; ++i) { 00105 aray[xdim*j+i] = mValues[j].second[i]; 00106 } 00107 } 00108 } 00109 }
|
|
|
Implements ICLIB::DataFile. Definition at line 13 of file DataFile1D.cpp. References ICLIB::DataFile::clear(), and ICLIB::DataFile::mFilename. 00013 { 00014 mFilename = filename; 00015 clear(); 00016 // read file 00017 std::ifstream file(filename.c_str()); 00018 if(!file) { 00019 std::ostringstream err; 00020 err << "could not open file " << filename << " for reading"; 00021 throw FileNotFoundException(filename, 00022 "DataFile1D::load", 00023 __FILE__, 00024 __LINE__); 00025 /*Tango::Except::throw_exception( 00026 static_cast<const char*>("TANGO_DEVICE_ERROR"), 00027 static_cast<const char*>(err.str().c_str()), 00028 static_cast<const char*>("DataFile1D::load"));*/ 00029 } 00030 std::string line; 00031 std::vector< std::string > keys; 00032 if(std::getline(file,line)) { 00033 std::istringstream iline(line); 00034 std::string key; 00035 while(std::getline(iline,key,',')) 00036 keys.push_back(key); 00037 } 00038 if(keys.size()<2) { 00039 std::ostringstream err; 00040 err << "error while parsing file " << filename << " : invalid header"; 00041 throw ParseException ( filename, 00042 "DataFile1D::load", 00043 __FILE__, 00044 __LINE__); 00045 /*Tango::Except::throw_exception( 00046 static_cast<const char*>("TANGO_DEVICE_ERROR"), 00047 static_cast<const char*>(err.str().c_str()), 00048 static_cast<const char*>("DataFile2D::load"));*/ 00049 } 00050 int numkey = 0; 00051 while(std::getline(file,line) && numkey<keys.size()) { 00052 std::vector< double > data; 00053 std::istringstream iline(line); 00054 double tmp; 00055 while(iline >> tmp) 00056 data.push_back(tmp); 00057 setValues(keys[numkey++],data); 00058 } 00059 }
Here is the call graph for this function: ![]() |
|
|
Implements ICLIB::DataFile. Definition at line 61 of file DataFile1D.cpp. References ICLIB::DataFile::mValues. 00061 { 00062 std::ofstream file(filename.c_str(),ios::out); 00063 if(!file) { 00064 std::ostringstream err; 00065 err << "could not open file " << filename << " for writing"; 00066 throw FileNotFoundException(filename, 00067 "DataFile1D::save", 00068 __FILE__, 00069 __LINE__); 00070 /*Tango::Except::throw_exception( 00071 static_cast<const char*>("TANGO_DEVICE_ERROR"), 00072 static_cast<const char*>(err.str().c_str()), 00073 static_cast<const char*>("DataFile1D::save"));*/ 00074 } 00075 ValuesMap::iterator it=mValues.begin(); 00076 while(it!=mValues.end()) { 00077 file << it->first; 00078 if(++it!=mValues.end()) 00079 file << ","; 00080 else 00081 file << std::endl; 00082 } 00083 for(it = mValues.begin(); it!=mValues.end(); ++it) { 00084 std::vector< double >& data = it->second; 00085 long i=0; 00086 while(i<data.size()) { 00087 file << data[i]; 00088 if(++i<data.size()) 00089 file << "\t"; 00090 else 00091 file << std::endl; 00092 } 00093 } 00094 }
|
|
||||||||||||||||
|
Implements ICLIB::DataFile. Definition at line 111 of file DataFile1D.cpp.
|
1.4.5