Skip to content

Commit bbc6710

Browse files
committed
Olympia build fixes
- Add DISABLE_STF_TESTS CMake option (needed to avoid same-name regress target collision) - Use std::enable_if for defaultProtocolFieldFormatter functions in stf_protocol_fields.hpp to fix build errors in gcc 10
1 parent f87fbe5 commit bbc6710

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

CMakeLists.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ if(BUILD_STF_PYTHON_LIB)
2323
add_subdirectory(stfpy)
2424
endif()
2525

26-
enable_testing()
27-
add_subdirectory (tests)
26+
if(NOT DISABLE_STF_TESTS)
27+
enable_testing()
28+
add_subdirectory (tests)
29+
endif()

stf-inc/stf_protocol_fields.hpp

+12-18
Original file line numberDiff line numberDiff line change
@@ -271,23 +271,18 @@ namespace stf {
271271
* Default formatter function used for ProtocolField objects
272272
*/
273273
template<typename Value>
274-
inline void defaultProtocolFieldFormatter(std::ostream& os, const char* name, const Value& data) {
274+
inline std::enable_if_t<std::negation_v<type_utils::is_array_or_serializable_vector_like<Value>>>
275+
defaultProtocolFieldFormatter(std::ostream& os, const char* name, const Value& data) {
275276
format_utils::formatLabel(os, name);
276277
format_utils::formatHex(os, data);
277278
}
278279

279280
/**
280-
* \typedef ProtocolFieldFormatter
281-
* Expected type of a ProtocolField formatter function
281+
* Default formatter function used for ProtocolArrayField, ProtocolVectorField, and ProtocolPackedBitVectorField objects
282282
*/
283283
template<typename Value>
284-
using ProtocolFieldFormatter = decltype(&defaultProtocolFieldFormatter<Value>);
285-
286-
/**
287-
* Default formatter function used for ProtocolVectorField objects
288-
*/
289-
template<typename VectorType>
290-
inline void defaultProtocolVectorFieldFormatter(std::ostream& os, const char* name, const VectorType& data) {
284+
inline std::enable_if_t<type_utils::is_array_or_serializable_vector_like<Value>::value>
285+
defaultProtocolFieldFormatter(std::ostream& os, const char* name, const Value& data) {
291286
format_utils::formatLabel(os, name);
292287
os << '[';
293288
if(!data.empty()) {
@@ -304,12 +299,11 @@ namespace stf {
304299
}
305300

306301
/**
307-
* Default formatter function used for ProtocolArrayField objects
302+
* \typedef ProtocolFieldFormatter
303+
* Expected type of a ProtocolField formatter function
308304
*/
309-
template<typename Value, size_t N>
310-
inline void defaultProtocolArrayFieldFormatter(std::ostream& os, const char* name, const std::array<Value, N>& data) {
311-
defaultProtocolVectorFieldFormatter(os, name, data);
312-
}
305+
template<typename Value>
306+
using ProtocolFieldFormatter = decltype(&defaultProtocolFieldFormatter<Value>);
313307

314308
/**
315309
* \class ProtocolField
@@ -396,7 +390,7 @@ namespace stf {
396390
template<size_t Size,
397391
typename FieldType,
398392
typename DataType,
399-
ProtocolFieldFormatter<std::array<DataType, Size>> Formatter = defaultProtocolArrayFieldFormatter>
393+
ProtocolFieldFormatter<std::array<DataType, Size>> Formatter = defaultProtocolFieldFormatter<std::array<DataType, Size>>>
400394
using ProtocolArrayField = ProtocolField<FieldType, std::array<DataType, Size>, Formatter>;
401395

402396
/**
@@ -408,7 +402,7 @@ namespace stf {
408402
typename DataType,
409403
typename SizeType,
410404
typename VectorType = SerializableVector<DataType, SizeType>,
411-
ProtocolFieldFormatter<VectorType> Formatter = defaultProtocolVectorFieldFormatter>
405+
ProtocolFieldFormatter<VectorType> Formatter = defaultProtocolFieldFormatter<VectorType>>
412406
class ProtocolVectorField : public ProtocolField<FieldType,
413407
VectorType,
414408
Formatter>
@@ -465,7 +459,7 @@ namespace stf {
465459
template<typename FieldType,
466460
typename DataType,
467461
typename SizeType,
468-
ProtocolFieldFormatter<SerializablePackedBitVector<DataType, SizeType>> Formatter = defaultProtocolVectorFieldFormatter>
462+
ProtocolFieldFormatter<SerializablePackedBitVector<DataType, SizeType>> Formatter = defaultProtocolFieldFormatter<SerializablePackedBitVector<DataType, SizeType>>>
469463
using ProtocolPackedBitVectorField = ProtocolVectorField<FieldType, DataType, SizeType, SerializablePackedBitVector<DataType, SizeType>, Formatter>;
470464
}
471465

stf-inc/stf_serializable_container.hpp

+19
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,25 @@ namespace stf {
298298
}
299299
};
300300

301+
namespace type_utils {
302+
template<typename T>
303+
struct is_serializable_vector : std::false_type {};
304+
305+
template<typename DataType, typename SizeType>
306+
struct is_serializable_vector<SerializableVector<DataType, SizeType>> : std::true_type {};
307+
308+
template<typename T>
309+
struct is_serializable_packed_bit_vector : std::false_type {};
310+
311+
template<typename DataType, typename SizeType>
312+
struct is_serializable_packed_bit_vector<SerializablePackedBitVector<DataType, SizeType>> : std::true_type {};
313+
314+
template<typename Value>
315+
using is_array_or_serializable_vector_like = std::disjunction<std::is_array<Value>,
316+
type_utils::is_serializable_vector<Value>,
317+
type_utils::is_serializable_packed_bit_vector<Value>>;
318+
}
319+
301320
/**
302321
* \class SerializableString
303322
*

0 commit comments

Comments
 (0)