added string concat to ToString

This commit is contained in:
Erik Frojdh 2019-08-20 12:17:42 +02:00
parent 0c4ae89cd9
commit d1ea74120d
5 changed files with 49 additions and 31 deletions

View File

@ -103,11 +103,11 @@ endif()
if(SLS_USE_SANITIZER) if(SLS_USE_SANITIZER)
target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer) # target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer)
#target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined) #target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined)
target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined) # target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined)
# target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread) target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread)
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread) target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
endif() endif()
#rapidjson #rapidjson

View File

@ -264,21 +264,21 @@ class DetectorPythonInterface {
return det.setPatternWaitTime(level, -1, detPos); return det.setPatternWaitTime(level, -1, detPos);
} }
bool getFlippedDataX(int i) { // bool getFlippedDataX(int i) {
return det.getFlippedData(slsDetectorDefs::dimension::X, i); // return det.getFlippedData(slsDetectorDefs::dimension::X, i);
} // }
bool getFlippedDataY(int i) { // bool getFlippedDataY(int i) {
return det.getFlippedData(slsDetectorDefs::dimension::Y, i); // return det.getFlippedData(slsDetectorDefs::dimension::Y, i);
} // }
void setFlippedDataX(int i, bool value) { // void setFlippedDataX(int i, bool value) {
det.setFlippedData(slsDetectorDefs::dimension::X, value, i); // det.setFlippedData(slsDetectorDefs::dimension::X, value, i);
} // }
void setFlippedDataY(int i, bool value) { // void setFlippedDataY(int i, bool value) {
det.setFlippedData(slsDetectorDefs::dimension::Y, value, i); // det.setFlippedData(slsDetectorDefs::dimension::Y, value, i);
} // }
/*** Frame and file settings ***/ /*** Frame and file settings ***/
void setFileName(std::string fname) { det.setFileName(fname); } void setFileName(std::string fname) { det.setFileName(fname); }
@ -520,13 +520,13 @@ class DetectorPythonInterface {
det.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER, nframes); det.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER, nframes);
} }
std::string getTimingMode() { // std::string getTimingMode() {
return det.externalCommunicationType( // return det.externalCommunicationType(
det.setExternalCommunicationMode()); // det.setExternalCommunicationMode());
} // }
void setTimingMode(const std::string mode) { // void setTimingMode(const std::string mode) {
det.setExternalCommunicationMode(det.externalCommunicationType(mode)); // det.setExternalCommunicationMode(det.externalCommunicationType(mode));
} // }
void freeSharedMemory() { det.freeSharedMemory(); } void freeSharedMemory() { det.freeSharedMemory(); }

View File

@ -183,8 +183,8 @@ PYBIND11_MODULE(_sls_detector, m) {
.def("setNumberOfStorageCells", &DetectorPythonInterface::setNumberOfStorageCells) .def("setNumberOfStorageCells", &DetectorPythonInterface::setNumberOfStorageCells)
.def("getNumberOfStorageCells", &DetectorPythonInterface::getNumberOfStorageCells) .def("getNumberOfStorageCells", &DetectorPythonInterface::getNumberOfStorageCells)
.def("getTimingMode", &DetectorPythonInterface::getTimingMode) // .def("getTimingMode", &DetectorPythonInterface::getTimingMode)
.def("setTimingMode", &DetectorPythonInterface::setTimingMode) // .def("setTimingMode", &DetectorPythonInterface::setTimingMode)
.def("getDetectorType", &DetectorPythonInterface::getDetectorType) .def("getDetectorType", &DetectorPythonInterface::getDetectorType)
@ -282,10 +282,10 @@ PYBIND11_MODULE(_sls_detector, m) {
&DetectorPythonInterface::getReceiverCurrentFrameIndex) &DetectorPythonInterface::getReceiverCurrentFrameIndex)
.def("getGapPixels", &DetectorPythonInterface::getGapPixels) .def("getGapPixels", &DetectorPythonInterface::getGapPixels)
.def("setGapPixels", &DetectorPythonInterface::setGapPixels) .def("setGapPixels", &DetectorPythonInterface::setGapPixels)
.def("getFlippedDataX", &DetectorPythonInterface::getFlippedDataX) // .def("getFlippedDataX", &DetectorPythonInterface::getFlippedDataX)
.def("getFlippedDataY", &DetectorPythonInterface::getFlippedDataY) // .def("getFlippedDataY", &DetectorPythonInterface::getFlippedDataY)
.def("setFlippedDataX", &DetectorPythonInterface::setFlippedDataX) // .def("setFlippedDataX", &DetectorPythonInterface::setFlippedDataX)
.def("setFlippedDataY", &DetectorPythonInterface::setFlippedDataY) // .def("setFlippedDataY", &DetectorPythonInterface::setFlippedDataY)
.def("getServerLock", &DetectorPythonInterface::getServerLock) .def("getServerLock", &DetectorPythonInterface::getServerLock)
.def("setServerLock", &DetectorPythonInterface::setServerLock) .def("setServerLock", &DetectorPythonInterface::setServerLock)

View File

@ -19,8 +19,17 @@
namespace sls { namespace sls {
// std::string ToString(const std::vector<std::string> &vec, inline std::string ToString(const std::vector<std::string> &vec,
// const char delimiter = ' '); const char delimiter = ' ') {
std::ostringstream os;
if(!vec.empty()){
auto it = vec.begin();
os << *it++;
while(it != vec.end())
os << delimiter << *it++;
}
return os.str();
}
/** Convert std::chrono::duration with specified output unit */ /** Convert std::chrono::duration with specified output unit */
template <typename T, typename Rep = double> template <typename T, typename Rep = double>

View File

@ -96,3 +96,12 @@ TEST_CASE("Convert types with str method"){
REQUIRE(ToString(addr) == "0.0.0.0"); REQUIRE(ToString(addr) == "0.0.0.0");
REQUIRE(ToString(sls::IpAddr{}) == "0.0.0.0"); REQUIRE(ToString(sls::IpAddr{}) == "0.0.0.0");
} }
TEST_CASE("vector of strings"){
std::vector<std::string> vec{"5", "s"};
REQUIRE(ToString(vec) == "5 s");
std::vector<std::string> vec2{"some", "strange", "words", "75"};
REQUIRE(ToString(vec2) == "some strange words 75");
}