mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 15:57:13 +02:00
ensuring no duplicate rx hostname port combo (#604)
* rx_hostname and port combo to one, or hostname to all, or a vector of hostnames and ports, ignoring none or empty, then verifying no duplicates for the host port combo including from shared memory * extracted function for rx_hostname (#694) * c++14 revert * unique hostname-port combo for port, hostname, rx_tcpport (#696) * verify unique combo for rx_port as well * check unique hostname-port combo also when setting control port, hostname, rx_hostname and rx_tcpport --------- Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com> Co-authored-by: Erik Frojdh <erik.frojdh@psi.ch>
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
// #include <utility> //support pair in vectors
|
||||
|
||||
#include "sls/TypeTraits.h"
|
||||
|
||||
@ -148,6 +149,12 @@ Squash(const Container &c, typename Container::value_type default_value = {}) {
|
||||
return default_value;
|
||||
}
|
||||
|
||||
template <typename Container> bool hasDuplicates(Container c) {
|
||||
std::sort(c.begin(), c.end());
|
||||
auto pos = std::adjacent_find(c.begin(), c.end());
|
||||
return pos != c.end(); // if we found something there are duplicates
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<is_container<T>::value, bool>::type
|
||||
removeDuplicates(T &c) {
|
||||
|
Reference in New Issue
Block a user