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)
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_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined)
# target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread)
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined)
target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread)
target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
endif()
#rapidjson

View File

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

View File

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

View File

@ -19,8 +19,17 @@
namespace sls {
// std::string ToString(const std::vector<std::string> &vec,
// const char delimiter = ' ');
inline std::string ToString(const std::vector<std::string> &vec,
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 */
template <typename T, typename Rep = double>

View File

@ -95,4 +95,13 @@ TEST_CASE("Convert types with str method"){
sls::IpAddr addr;
REQUIRE(ToString(addr) == "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");
}