Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer

This commit is contained in:
maliakal_d 2019-10-01 17:35:03 +02:00
commit d597636c1e
2 changed files with 21 additions and 10 deletions

View File

@ -20,6 +20,17 @@
namespace sls {
inline std::string ToString(const slsDetectorDefs::runStatus s){
return slsDetectorDefs::runStatusType(s);
}
// in case we already have a string
// causes a copy but might be needed in generic code
inline std::string ToString(const std::string& s){
return s;
}
/** Convert std::chrono::duration with specified output unit */
template <typename T, typename Rep = double>
typename std::enable_if<is_duration<T>::value, std::string>::type
@ -73,6 +84,9 @@ ToString(const T &value) {
return std::to_string(value);
}
/**
* For a container loop over all elements and call ToString on the element
* Container<std::string> is excluded
@ -177,17 +191,8 @@ ToString(const T &obj) {
return obj.str();
}
/**
* Call ToString with a string, causes copy but might be needed
* in generic code.
*/
inline std::string ToString(const std::string& s){
return s;
}
inline std::string ToString(slsDetectorDefs::runStatus s){
return slsDetectorDefs::runStatusType(s);
}
} // namespace sls

View File

@ -135,3 +135,9 @@ TEST_CASE("string to detectorType"){
REQUIRE(StringTo<dt>("Gotthard2") == dt::GOTTHARD2);
}
TEST_CASE("vec"){
using rs = slsDetectorDefs::runStatus;
std::vector<rs> vec{rs::ERROR, rs::IDLE};
REQUIRE(ToString(vec) == "[error, idle]");
}