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 #ifdef VERBOSE
cout << "Loading Calibration Data" << endl; cout << "Loading Calibration Data" << endl;
#endif #endif
QString fName = QString(myDet->getCalDir()); QString fName = QString( (myDet->getCalDir()).c_str() );
qDefs::checkErrorMessage(myDet); qDefs::checkErrorMessage(myDet);
//so that even nonexisting files can be selected //so that even nonexisting files can be selected
@ -626,7 +626,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Saving Calibration Data" << endl; cout << "Saving Calibration Data" << endl;
#endif//different output directory so as not to overwrite #endif//different output directory so as not to overwrite
QString fName = QString(myDet->getCalDir()); QString fName = QString( (myDet->getCalDir()).c_str() );
qDefs::checkErrorMessage(myDet); qDefs::checkErrorMessage(myDet);
fName = QFileDialog::getSaveFileName(this, fName = QFileDialog::getSaveFileName(this,
tr("Save Current Detector Calibration Data"),fName, 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 returns the location of the calibration files
\sa sharedSlsDetector \sa sharedSlsDetector
*/ */
char* multiSlsDetector::getCalDir() string multiSlsDetector::getCalDir()
{ {
string s0 = "", s1 = "", s; return callDetectors(&slsDetector::getCalDir);
//char ans[1000]; // string s0 = "", s1 = "", s;
for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) { // //char ans[1000];
if (detectors[idet]) { // for (int idet = 0; idet < thisMultiDetector->numberOfDetectors; ++idet) {
s = detectors[idet]->getCalDir(); // if (detectors[idet]) {
if (detectors[idet]->getErrorMask()) // s = detectors[idet]->getCalDir();
setErrorMask(getErrorMask() | (1 << idet)); // if (detectors[idet]->getErrorMask())
// setErrorMask(getErrorMask() | (1 << idet));
if (s0 == "") // if (s0 == "")
s0 = s; // s0 = s;
else // else
s0 += string("+") + s; // s0 += string("+") + s;
if (s1 == "") // if (s1 == "")
s1 = s; // s1 = s;
else if (s1 != s) // else if (s1 != s)
s1 = "bad"; // s1 = "bad";
} // }
} // }
if (s1 == "bad") // if (s1 == "bad")
strcpy(ans, s0.c_str()); // strcpy(ans, s0.c_str());
else // else
strcpy(ans, s1.c_str()); // strcpy(ans, s1.c_str());
return ans; // return ans;
} }
/** /**
sets the location of the calibration files sets the location of the calibration files
\sa sharedSlsDetector \sa sharedSlsDetector
*/ */
char* multiSlsDetector::setCalDir(string s) string multiSlsDetector::setCalDir(string s)
{ {
if (s.find('+') == string::npos) { if (s.find('+') == string::npos) {

View File

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

View File

@ -493,12 +493,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
returns the location of the calibration files returns the location of the calibration files
\sa sharedSlsDetector \sa sharedSlsDetector
*/ */
char* getCalDir() {return thisDetector->calDir;}; std::string getCalDir() {return thisDetector->calDir;};
/** /**
sets the location of the calibration files sets the location of the calibration files
\sa sharedSlsDetector \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) { if (action==PUT_ACTION) {
myDet->setCalDir(string(args[1])); myDet->setCalDir(string(args[1]));
} }
if (myDet->getCalDir()==NULL) if ( (myDet->getCalDir()).empty() )
return string("undefined"); 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 returns the location of the calibration files
*/ */
virtual char* getCalDir()=0; virtual std::string getCalDir()=0;
/** /**
sets the location of the calibration files 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*/ /** Frees the shared memory - should not be used except for debugging*/
virtual int freeSharedMemory()=0; virtual int freeSharedMemory()=0;