changed type of getCalDir to std::string

This commit is contained in:
Erik Frojdh 2018-05-25 10:30:02 +02:00
parent abdf4b1ada
commit f45e2b4ab9
6 changed files with 35 additions and 34 deletions

View File

@ -603,7 +603,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
#ifdef VERBOSE
cout << "Loading Calibration Data" << endl;
#endif
QString fName = QString(myDet->getCalDir());
QString fName = QString( (myDet->getCalDir()).c_str() );
qDefs::checkErrorMessage(myDet);
//so that even nonexisting files can be selected
@ -626,7 +626,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
#ifdef VERBOSE
cout << "Saving Calibration Data" << endl;
#endif//different output directory so as not to overwrite
QString fName = QString(myDet->getCalDir());
QString fName = QString( (myDet->getCalDir()).c_str() );
qDefs::checkErrorMessage(myDet);
fName = QFileDialog::getSaveFileName(this,
tr("Save Current Detector Calibration Data"),fName,

View File

@ -3552,38 +3552,39 @@ int multiSlsDetector::getTrimEn(int* ene)
returns the location of the calibration files
\sa sharedSlsDetector
*/
char* multiSlsDetector::getCalDir()
string multiSlsDetector::getCalDir()
{
string s0 = "", s1 = "", s;
//char ans[1000];
for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) {
if (detectors[idet]) {
s = detectors[idet]->getCalDir();
if (detectors[idet]->getErrorMask())
setErrorMask(getErrorMask() | (1 << idet));
return callDetectors(&slsDetector::getCalDir);
// string s0 = "", s1 = "", s;
// //char ans[1000];
// for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) {
// if (detectors[idet]) {
// s = detectors[idet]->getCalDir();
// if (detectors[idet]->getErrorMask())
// setErrorMask(getErrorMask() | (1 << idet));
if (s0 == "")
s0 = s;
else
s0 += string("+") + s;
if (s1 == "")
s1 = s;
else if (s1 != s)
s1 = "bad";
}
}
if (s1 == "bad")
strcpy(ans, s0.c_str());
else
strcpy(ans, s1.c_str());
return ans;
// if (s0 == "")
// s0 = s;
// else
// s0 += string("+") + s;
// if (s1 == "")
// s1 = s;
// else if (s1 != s)
// s1 = "bad";
// }
// }
// if (s1 == "bad")
// strcpy(ans, s0.c_str());
// else
// strcpy(ans, s1.c_str());
// return ans;
}
/**
sets the location of the calibration files
\sa sharedSlsDetector
*/
char* multiSlsDetector::setCalDir(string s)
string multiSlsDetector::setCalDir(string s)
{
if (s.find('+') == string::npos) {

View File

@ -1054,12 +1054,12 @@ class multiSlsDetector : public slsDetectorUtils {
returns the location of the calibration files
\sa sharedSlsDetector
*/
char* getCalDir();
std::string getCalDir();
/**
sets the location of the calibration files
\sa sharedSlsDetector
*/
char* setCalDir(std::string s);
std::string setCalDir(std::string s);
std::string getNetworkParameter(networkParameter);

View File

@ -493,12 +493,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
returns the location of the calibration files
\sa sharedSlsDetector
*/
char* getCalDir() {return thisDetector->calDir;};
std::string getCalDir() {return thisDetector->calDir;};
/**
sets the location of the calibration files
\sa sharedSlsDetector
*/
char* setCalDir(string s) {sprintf(thisDetector->calDir, s.c_str()); return thisDetector->calDir;};
std::string setCalDir(string s) {sprintf(thisDetector->calDir, s.c_str()); return thisDetector->calDir;};

View File

@ -3061,9 +3061,9 @@ string slsDetectorCommand::cmdCalDir(int narg, char *args[], int action){
if (action==PUT_ACTION) {
myDet->setCalDir(string(args[1]));
}
if (myDet->getCalDir()==NULL)
if ( (myDet->getCalDir()).empty() )
return string("undefined");
return string(myDet->getCalDir());
return myDet->getCalDir();
}

View File

@ -413,12 +413,12 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
/**
returns the location of the calibration files
*/
virtual char* getCalDir()=0;
virtual std::string getCalDir()=0;
/**
sets the location of the calibration files
*/
virtual char* setCalDir(std::string s)=0;
virtual std::string setCalDir(std::string s)=0;
/** Frees the shared memory - should not be used except for debugging*/
virtual int freeSharedMemory()=0;