mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 03:10:02 +02:00
less public headers
This commit is contained in:
parent
0dd5a099c8
commit
ea7cc9db8c
@ -45,6 +45,7 @@ option(SLS_USE_CTBGUI "ctb GUI" OFF)
|
|||||||
option(SLS_BUILD_DOCS "docs" OFF)
|
option(SLS_BUILD_DOCS "docs" OFF)
|
||||||
option(SLS_BUILD_EXAMPLES "examples" OFF)
|
option(SLS_BUILD_EXAMPLES "examples" OFF)
|
||||||
option(SLS_TUNE_LOCAL "tune to local machine" OFF)
|
option(SLS_TUNE_LOCAL "tune to local machine" OFF)
|
||||||
|
option(SLS_DEVEL_HEADERS "install headers for devel" OFF)
|
||||||
|
|
||||||
# set(ClangFormat_BIN_NAME clang-format)
|
# set(ClangFormat_BIN_NAME clang-format)
|
||||||
set(ClangFormat_EXCLUDE_PATTERNS "build/"
|
set(ClangFormat_EXCLUDE_PATTERNS "build/"
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "TimeHelper.h"
|
|
||||||
#include "ToString.h"
|
#include "ToString.h"
|
||||||
#include "container_utils.h"
|
#include "container_utils.h"
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <cstring>
|
|
||||||
#include <unistd.h>
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@short data structure to hold the detector data after postprocessing
|
@short data structure to hold the detector data after postprocessing
|
||||||
*/
|
*/
|
||||||
|
@ -18,23 +18,29 @@ set(HEADERS
|
|||||||
set(PUBLICHEADERS
|
set(PUBLICHEADERS
|
||||||
include/sls_detector_defs.h
|
include/sls_detector_defs.h
|
||||||
include/sls_detector_funcs.h
|
include/sls_detector_funcs.h
|
||||||
include/versionAPI.h
|
|
||||||
include/sls_detector_exceptions.h
|
include/sls_detector_exceptions.h
|
||||||
include/file_utils.h
|
|
||||||
include/container_utils.h
|
include/container_utils.h
|
||||||
include/string_utils.h
|
include/string_utils.h
|
||||||
|
include/network_utils.h
|
||||||
|
include/ToString.h
|
||||||
|
include/TypeTraits.h
|
||||||
|
include/TimeHelper.h
|
||||||
|
)
|
||||||
|
|
||||||
|
if(SLS_DEVEL_HEADERS)
|
||||||
|
set(PUBLICHEADERS
|
||||||
|
${PUBLICHEADERS}
|
||||||
|
include/file_utils.h
|
||||||
include/ClientSocket.h
|
include/ClientSocket.h
|
||||||
include/DataSocket.h
|
include/DataSocket.h
|
||||||
include/ServerSocket.h
|
include/ServerSocket.h
|
||||||
include/ServerInterface.h
|
include/ServerInterface.h
|
||||||
include/network_utils.h
|
|
||||||
include/StaticVector.h
|
|
||||||
include/ToString.h
|
|
||||||
include/TimeHelper.h
|
|
||||||
include/TypeTraits.h
|
|
||||||
include/Timer.h
|
include/Timer.h
|
||||||
|
include/StaticVector.h
|
||||||
include/UdpRxSocket.h
|
include/UdpRxSocket.h
|
||||||
|
include/versionAPI.h
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(slsSupportLib SHARED
|
add_library(slsSupportLib SHARED
|
||||||
${SOURCES}
|
${SOURCES}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "TypeTraits.h"
|
#include "TypeTraits.h"
|
||||||
|
#include "ToString.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -47,28 +48,6 @@ template <typename T, size_t Capacity> class StaticVector {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compare StaticVector with any other container*/
|
|
||||||
// template <typename V>
|
|
||||||
// typename std::enable_if<is_container<V>::value, bool>::type
|
|
||||||
// operator==(const V &other) const noexcept {
|
|
||||||
// if (current_size != other.size()) {
|
|
||||||
// return false;
|
|
||||||
// } else {
|
|
||||||
// for (size_t i = 0; i != current_size; ++i) {
|
|
||||||
// if (data_[i] != other[i]) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// template <typename V>
|
|
||||||
// typename std::enable_if<is_container<V>::value, bool>::type
|
|
||||||
// operator!=(const V &other) const noexcept {
|
|
||||||
// return !(*this == other);
|
|
||||||
// }
|
|
||||||
|
|
||||||
operator std::vector<T>() { return std::vector<T>(begin(), end()); }
|
operator std::vector<T>() { return std::vector<T>(begin(), end()); }
|
||||||
|
|
||||||
T &operator[](size_t i) { return data_[i]; }
|
T &operator[](size_t i) { return data_[i]; }
|
||||||
@ -204,20 +183,13 @@ bool operator!=(const std::vector<T> &lhs,
|
|||||||
return !rhs.is_equal(lhs);
|
return !rhs.is_equal(lhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** support flipped order compare */
|
template <typename T, size_t Capacity>
|
||||||
// template <typename T, size_t Capacity, typename C>
|
std::ostream &operator<<(std::ostream &os,
|
||||||
// typename std::enable_if<is_container<C>::value, bool>::type operator==(
|
const sls::StaticVector<T, Capacity> &c) {
|
||||||
// const C &container,
|
return os << ToString(c);
|
||||||
// const StaticVector<T, Capacity> &fixed_container) noexcept {
|
}
|
||||||
// return fixed_container.operator==(container);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /** support flipped order compare */
|
|
||||||
// template <typename T, size_t Capacity, typename C>
|
|
||||||
// typename std::enable_if<is_container<C>::value, bool>::type operator!=(
|
|
||||||
// const C &container,
|
|
||||||
// const StaticVector<T, Capacity> &fixed_container) noexcept {
|
|
||||||
// return fixed_container.operator!=(container);
|
|
||||||
// }
|
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "StaticVector.h"
|
|
||||||
#include "TimeHelper.h"
|
#include "TimeHelper.h"
|
||||||
#include "TypeTraits.h"
|
#include "TypeTraits.h"
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
@ -40,11 +39,7 @@ std::string ToString(const defs::timingSourceType s);
|
|||||||
std::string ToString(const slsDetectorDefs::ROI &roi);
|
std::string ToString(const slsDetectorDefs::ROI &roi);
|
||||||
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::ROI &roi);
|
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::ROI &roi);
|
||||||
|
|
||||||
template <typename T, size_t Capacity>
|
|
||||||
std::ostream &operator<<(std::ostream &os,
|
|
||||||
const sls::StaticVector<T, Capacity> &c) {
|
|
||||||
return os << ToString(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string &ToString(const std::string &s);
|
const std::string &ToString(const std::string &s);
|
||||||
|
|
||||||
|
@ -584,7 +584,8 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
|
|||||||
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";
|
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";
|
||||||
default: return "Unknown Function";
|
default: return "Unknown Function";
|
||||||
}
|
}
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -50,29 +50,5 @@ implementation should not be used in a performance critical place.
|
|||||||
*/
|
*/
|
||||||
std::vector<std::string> split(const std::string &strToSplit, char delimeter);
|
std::vector<std::string> split(const std::string &strToSplit, char delimeter);
|
||||||
|
|
||||||
/*
|
|
||||||
Concatenate the non empty strings in the vector using +
|
|
||||||
*/
|
|
||||||
std::string concatenateNonEmptyStrings(const std::vector<std::string> &vec);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Concatenate strings using + if the strings are different
|
|
||||||
*/
|
|
||||||
std::string concatenateIfDifferent(const std::vector<std::string> &container);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Concatenate vector of things with str method using + if the strings are
|
|
||||||
different
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
std::string concatenateIfDifferent(const std::vector<T> &container);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Convert an ip address string to a string in hex format. (removing dots)
|
|
||||||
*/
|
|
||||||
std::string stringIpToHex(const std::string &ip);
|
|
||||||
|
|
||||||
// remove the end of the string starting with the first aplhabetic character
|
|
||||||
// return the end
|
|
||||||
std::string RemoveUnit(std::string &str);
|
std::string RemoveUnit(std::string &str);
|
||||||
}; // namespace sls
|
} // namespace sls
|
||||||
|
@ -17,36 +17,6 @@ std::vector<std::string> split(const std::string &strToSplit, char delimeter) {
|
|||||||
return splittedStrings;
|
return splittedStrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string concatenateNonEmptyStrings(const std::vector<std::string> &vec) {
|
|
||||||
std::string ret;
|
|
||||||
for (const auto &s : vec)
|
|
||||||
if (!s.empty())
|
|
||||||
ret += s + '+';
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string concatenateIfDifferent(const std::vector<std::string> &container) {
|
|
||||||
if (allEqual(container)) {
|
|
||||||
return container.front();
|
|
||||||
} else {
|
|
||||||
std::string result;
|
|
||||||
for (const auto &s : container)
|
|
||||||
result += s + '+';
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template <typename T>
|
|
||||||
std::string concatenateIfDifferent(const std::vector<T> &container) {
|
|
||||||
if (allEqual(container)) {
|
|
||||||
return container.front().str();
|
|
||||||
} else {
|
|
||||||
std::string result;
|
|
||||||
for (const auto &s : container)
|
|
||||||
result += s.str() + '+';
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string RemoveUnit(std::string &str) {
|
std::string RemoveUnit(std::string &str) {
|
||||||
auto it = str.begin();
|
auto it = str.begin();
|
||||||
while (it != str.end()) {
|
while (it != str.end()) {
|
||||||
@ -60,7 +30,4 @@ std::string RemoveUnit(std::string &str) {
|
|||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
template std::string concatenateIfDifferent(const std::vector<IpAddr> &);
|
|
||||||
template std::string concatenateIfDifferent(const std::vector<MacAddr> &);
|
|
||||||
|
|
||||||
}; // namespace sls
|
}; // namespace sls
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
using sls::StaticVector;
|
using sls::StaticVector;
|
||||||
|
|
||||||
TEST_CASE("StaticVector is a container") {
|
TEST_CASE("StaticVector is a container") {
|
||||||
@ -313,3 +314,20 @@ SCENARIO("Converting to vector", "[support]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("sls::StaticVector") {
|
||||||
|
sls::StaticVector<int, 5> vec;
|
||||||
|
vec.push_back(3);
|
||||||
|
vec.push_back(8);
|
||||||
|
REQUIRE(sls::ToString(vec) == "[3, 8]");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("sls::StaticVector stream") {
|
||||||
|
sls::StaticVector<int, 5> vec;
|
||||||
|
vec.push_back(33);
|
||||||
|
vec.push_back(85667);
|
||||||
|
vec.push_back(2);
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << vec;
|
||||||
|
REQUIRE(oss.str() == "[33, 85667, 2]");
|
||||||
|
}
|
||||||
|
@ -232,19 +232,3 @@ TEST_CASE("Streaming of slsDetectorDefs::ROI") {
|
|||||||
REQUIRE(oss.str() == "[-10, 1]");
|
REQUIRE(oss.str() == "[-10, 1]");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("sls::StaticVector") {
|
|
||||||
sls::StaticVector<int, 5> vec;
|
|
||||||
vec.push_back(3);
|
|
||||||
vec.push_back(8);
|
|
||||||
REQUIRE(ToString(vec) == "[3, 8]");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("sls::StaticVector stream") {
|
|
||||||
sls::StaticVector<int, 5> vec;
|
|
||||||
vec.push_back(33);
|
|
||||||
vec.push_back(85667);
|
|
||||||
vec.push_back(2);
|
|
||||||
std::ostringstream oss;
|
|
||||||
oss << vec;
|
|
||||||
REQUIRE(oss.str() == "[33, 85667, 2]");
|
|
||||||
}
|
|
@ -30,22 +30,7 @@ TEST_CASE("copy a long string") {
|
|||||||
REQUIRE(dst[2] == '\0');
|
REQUIRE(dst[2] == '\0');
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
TEST_CASE("Concat") {
|
|
||||||
std::vector<std::string> v{"one", "one", "one"};
|
|
||||||
std::vector<std::string> v2{"one", "one", "one"};
|
|
||||||
auto r = sls::concatenateIfDifferent(v);
|
|
||||||
REQUIRE(r == std::string("one"));
|
|
||||||
r.clear();
|
|
||||||
|
|
||||||
// make sure we didn't modify the string
|
|
||||||
REQUIRE(v == v2);
|
|
||||||
|
|
||||||
SECTION("add a different value") {
|
|
||||||
v.emplace_back("two");
|
|
||||||
REQUIRE(v != v2);
|
|
||||||
REQUIRE(sls::concatenateIfDifferent(v) == "one+one+one+two+");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("split a string with end delimiter") {
|
TEST_CASE("split a string with end delimiter") {
|
||||||
std::string s("abra+kadabra+");
|
std::string s("abra+kadabra+");
|
||||||
@ -64,26 +49,6 @@ TEST_CASE("split a string without end delimiter") {
|
|||||||
REQUIRE(r[2] == "filibom");
|
REQUIRE(r[2] == "filibom");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("concatenate non empty strings") {
|
|
||||||
std::vector<std::string> vec{"hej", "kalas", "", "foto"};
|
|
||||||
REQUIRE(vec.size() == 4);
|
|
||||||
auto ret = sls::concatenateNonEmptyStrings(vec);
|
|
||||||
REQUIRE(ret == "hej+kalas+foto+");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("concatenate non empty strings with only emty") {
|
|
||||||
std::vector<std::string> vec{"", "", ""};
|
|
||||||
REQUIRE(vec.size() == 3);
|
|
||||||
auto ret = sls::concatenateNonEmptyStrings(vec);
|
|
||||||
REQUIRE(ret.empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("concatenate non empty strings with one element") {
|
|
||||||
std::vector<std::string> vec{"", "hej", "", "", ""};
|
|
||||||
REQUIRE(vec.size() == 5);
|
|
||||||
auto ret = sls::concatenateNonEmptyStrings(vec);
|
|
||||||
REQUIRE(ret == "hej+");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("Remove char from string") {
|
TEST_CASE("Remove char from string") {
|
||||||
char str[] = "sometest";
|
char str[] = "sometest";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user