Result

Result is a thin wrapper around std::vector and used for returning values from the detector. Since every module could have a different value, we need to return a vector instead of just a single value.

Easy conversions to single values are provided using the squash and tsquash method.

namespace sls

functions basic implemenation of shared memory

creates/destroys a thread

creates & manages a listener thread each

abstract for setting/getting properties of detector data

constructs the fifo structure

creates & manages a data streamer thread each

creates & manages a data processor thread each

creates/destroys an ARPing child process to arping the interfaces slsReceiver is listening to.

Functions

template<typename T>
std::ostream &operator<<(std::ostream &os, const Result<T> &res)

operator << overload to print Result, uses ToString for the conversion

Template Parameters

T – type stored in the Result

template<class T, class Allocator = std::allocator<T>>
class Result
#include <Result.h>
Template Parameters
  • T – type to store in the result

  • Allocator – for the underlying vector, default

Public Types

using value_type = typename std::vector<T>::value_type
using iterator = typename std::vector<T>::iterator
using const_iterator = typename std::vector<T>::const_iterator
using size_type = typename std::vector<T>::size_type
using reference = typename std::vector<T>::reference
using const_reference = typename std::vector<T>::const_reference

Public Functions

Result() = default
inline Result(std::initializer_list<T> list)
template<typename V, typename = typename std::enable_if<std::is_integral<V>::value && (std::is_same<T, time::ns>::value || std::is_same<T, bool>::value)>::type>
inline Result(const Result<V> &from)

Custom constructor from integer type to Result<ns> or Result<bool>

template<typename V, typename = typename std::enable_if<std::is_integral<V>::value && (std::is_same<T, time::ns>::value || std::is_same<T, bool>::value)>::type>
inline Result(Result<V> &from)

Custom constructor from integer type to Result<ns> or Result<bool>

template<typename V, typename = typename std::enable_if<std::is_integral<V>::value && (std::is_same<T, time::ns>::value || std::is_same<T, bool>::value)>::type>
inline Result(Result<V> &&from)

Custom constructor from integer type to Result<ns> or Result<bool>

template<typename ...Args>
inline Result(Args&&... args)

Forward arguments to the constructor of std::vector

Template Parameters

Args – template paramter pack to forward

inline auto begin() noexcept -> decltype(vec.begin())
inline auto begin() const noexcept -> decltype(vec.begin())
inline auto cbegin() const noexcept -> decltype(vec.cbegin())
inline auto end() noexcept -> decltype(vec.end())
inline auto end() const noexcept -> decltype(vec.end())
inline auto cend() const noexcept -> decltype(vec.cend())
inline auto size() const noexcept -> decltype(vec.size())
inline auto empty() const noexcept -> decltype(vec.empty())
inline auto front() -> decltype(vec.front())
inline auto front() const -> decltype(vec.front())
inline void reserve(size_type new_cap)
template<typename V>
inline auto push_back(V value) -> decltype(vec.push_back(value))
inline auto operator[](size_type pos) -> decltype(vec[pos])
inline const_reference operator[](size_type pos) const
inline T squash() const

If all elements are equal it returns the front value otherwise a default constructed T

inline T tsquash(const std::string &error_msg)

If all elements are equal it returns the front value otherwise throws an exception with custom message provided

inline T squash(const T &default_value) const

If all elements are equal return the front value, otherwise return the supplied default value

inline bool equal() const noexcept

Test whether all elements of the result are equal

inline bool any(const T &value) const noexcept

Test whether any element of the result are equal to a value

template<typename V, typename ...Args, typename = AllSame<V, Args...>>
inline std::enable_if<std::is_same<V, T>::value, bool>::type contains_only(const V &a, const Args&... args) const noexcept
inline operator std::vector<T>()

Convert Result<T> to std::vector<T>

Private Members

std::vector<T, Allocator> vec

wrapped vector