| Face Engine SDK 5.2.0 A face detection, recognition and tracking engine.

ResultValue.h
1 #pragma once
2
3 #include <type_traits>
4
5 namespace fsdk
6 {
17 template<
18 typename R,
19 typename V,
20 class Enable = void>
21 struct ResultValue: Result<R> {};
22
23 template<
24 typename R,
25 typename V>
26 struct ResultValue<R, V, typename std::enable_if<std::is_copy_constructible<V>::value>::type>
27 : Result<R>
28 {
30 typedef R EnumType;
31
33 typedef V ValueType;
34
38 ResultValue(R result) noexcept
39 : Result<R>(result)
40 {}
41
46 ResultValue(R result, const V& value) noexcept
47 : Result<R>(result)
48 , m_value(value)
49 {}
50
55 ResultValue(R result, V&& value) noexcept
56 : Result<R>(result)
57 , m_value(std::move(value))
58 {}
59
64 const V& getValue() const noexcept {
65 assert(this->isOk() && "Acessing value of erroneous result.");
66 return m_value;
67 }
68
75 V&& takeValue() noexcept {
76 return std::move(m_value);
77 }
78
83 const V* operator -> () const noexcept {
84 return &getValue();
85 }
86
87 protected:
88 V m_value;
89 };
90
100 template<
101 typename R,
102 typename V>
103 struct ResultValue<R, V, typename std::enable_if<std::is_copy_constructible<V>::value == false>::type>
104 : Result<R>
105 {
107 typedef R EnumType;
108
110 typedef V ValueType;
111
115 ResultValue(R result) noexcept
116 : Result<R>(result)
117 {}
118
123 ResultValue(R result, V&& value) noexcept
124 : Result<R>(result)
125 , m_value(std::move(value))
126 {}
127
132 const V& getValue() const noexcept {
133 assert(this->isOk() && "Acessing value of erroneous result.");
134 return m_value;
135 }
136
143 V&& takeValue() noexcept {
144 return std::move(m_value);
145 }
146
151 const V* operator -> () const noexcept {
152 return &getValue();
153 }
154
155 protected:
156 V m_value;
157 };
158
169 template<
170 typename R,
171 typename V>
172 inline ResultValue<R,
173 typename std::remove_const<typename std::remove_reference<V>::type>::type>
174 makeResultValue(R result, V&& value) noexcept {
175 return ResultValue<R,
176 typename std::remove_const<typename std::remove_reference<V>::type>::type>(
177 result,
178 std::forward<V>(value));
179 };
180 }
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value==false >::type >::ValueType
V ValueType
Result value type.
Definition: ResultValue.h:110
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value==false >::type >::ResultValue
ResultValue(R result, V &&value) noexcept
Initializes result.
Definition: ResultValue.h:123
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value==false >::type >::takeValue
V && takeValue() noexcept
Gets result value as rvalue.
Definition: ResultValue.h:143
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value==false >::type >::EnumType
R EnumType
Result enumeration type.
Definition: ResultValue.h:107
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value==false >::type >::m_value
V m_value
Actual value.
Definition: ResultValue.h:156
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value==false >::type >::getValue
const V & getValue() const noexcept
Gets result value.
Definition: ResultValue.h:132
fsdk
SDK namespace.
Definition: IAGSEstimator.h:8
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value >::type >::m_value
V m_value
Actual value.
Definition: ResultValue.h:88
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value >::type >::takeValue
V && takeValue() noexcept
Gets result value as rvalue.
Definition: ResultValue.h:75
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value >::type >::EnumType
R EnumType
Result enumeration type.
Definition: ResultValue.h:30
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value >::type >::ResultValue
ResultValue(R result, V &&value) noexcept
Initializes result.
Definition: ResultValue.h:55
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value >::type >::ResultValue
ResultValue(R result) noexcept
Initializes result.
Definition: ResultValue.h:38
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value >::type >::getValue
const V & getValue() const noexcept
Gets result value.
Definition: ResultValue.h:64
fsdk::Result< R >::isOk
bool isOk() const noexcept
Checks for a success.
Definition: Result.h:63
fsdk::Result
A structure that encapsulates an action result enumeration.
Definition: Result.h:30
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value >::type >::ValueType
V ValueType
Result value type.
Definition: ResultValue.h:33
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value >::type >::ResultValue
ResultValue(R result, const V &value) noexcept
Initializes result.
Definition: ResultValue.h:46
fsdk::makeResultValue
ResultValue< R, typename std::remove_const< typename std::remove_reference< V >::type >::type > makeResultValue(R result, V &&value) noexcept
Addon for Result to output some value aside the result.
Definition: ResultValue.h:174
fsdk::ResultValue< R, V, typename std::enable_if< std::is_copy_constructible< V >::value==false >::type >::ResultValue
ResultValue(R result) noexcept
Initializes result.
Definition: ResultValue.h:115
fsdk::ResultValue
Addon for Result to output some value aside the result. Specialization for copiable types.
Definition: ResultValue.h:21