Skip to content

Commit f98e7ac

Browse files
Gabriele Gaetano Fronzématthiasrichter
authored andcommitted
Renaming serialization methods based on boost and fixing copyright noticey
1 parent 1372106 commit f98e7ac

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

Common/Utils/include/CommonUtils/BoostSerializer.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class is_boost_serializable
6969
template <typename ContT>
7070
typename std::enable_if<check::is_boost_serializable<ContT, boost::archive::binary_oarchive>::value
7171
&& std::is_class<typename ContT::value_type>::value, std::ostringstream>::type
72-
SerializeContainer(const ContT& dataSet)
72+
BoostSerialize(const ContT &dataSet)
7373
{
7474
static_assert(check::is_boost_serializable<typename ContT::value_type, boost::archive::binary_oarchive>::value,
7575
"This class doesn't provide a boost serializer.");
@@ -84,7 +84,7 @@ typename std::enable_if<check::is_boost_serializable<ContT, boost::archive::bina
8484
template <typename ContT, typename ContentT = typename ContT::value_type>
8585
typename std::enable_if<check::is_boost_serializable<ContT, boost::archive::binary_oarchive>::value
8686
&& !(std::is_class<ContentT>::value), std::ostringstream>::type
87-
SerializeContainer(const ContT& dataSet)
87+
BoostSerialize(const ContT &dataSet)
8888
{
8989
static_assert(boost::serialization::is_bitwise_serializable<typename ContT::value_type>::value,
9090
"This type doesn't provide a boost serializer.");
@@ -99,7 +99,7 @@ typename std::enable_if<check::is_boost_serializable<ContT, boost::archive::bina
9999
template <typename ContT>
100100
typename std::enable_if<check::is_boost_serializable<ContT, boost::archive::binary_iarchive>::value
101101
&& std::is_class<typename ContT::value_type>::value, ContT>::type
102-
DeserializeContainer(std::string& msgStr)
102+
BoostDeserialize(std::string &msgStr)
103103
{
104104
static_assert(check::is_boost_serializable<typename ContT::value_type, boost::archive::binary_oarchive>::value,
105105
"This class doesn't provide a boost deserializer.");
@@ -114,7 +114,7 @@ typename std::enable_if<check::is_boost_serializable<ContT, boost::archive::bina
114114
template <typename ContT, typename ContentT = typename ContT::value_type>
115115
typename std::enable_if<check::is_boost_serializable<ContT, boost::archive::binary_iarchive>::value
116116
&& !(std::is_class<ContentT>::value), ContT>::type
117-
DeserializeContainer(std::string& msgStr)
117+
BoostDeserialize(std::string &msgStr)
118118
{
119119
static_assert(boost::serialization::is_bitwise_serializable<typename ContT::value_type>::value,
120120
"This type doesn't provide a boost serializer.");
@@ -125,6 +125,21 @@ typename std::enable_if<check::is_boost_serializable<ContT, boost::archive::bina
125125
inputArchive >> output;
126126
return std::move(output);
127127
}
128+
129+
template <typename T>
130+
struct has_serializer
131+
{
132+
template <class, class> class checker;
133+
134+
template <typename C>
135+
static std::true_type test(checker<C, decltype(&o2::utils::BoostSerialize<C>)> *);
136+
137+
template <typename C>
138+
static std::false_type test(...);
139+
140+
typedef decltype(test<T>(nullptr)) type;
141+
static const bool value = std::is_same<std::true_type, decltype(test<T>(nullptr))>::value;
142+
};
128143
} // namespace utils
129144
} // namespace o2
130145

Common/Utils/test/testBoostSerializer.cxx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
//
21
// Copyright CERN and copyright holders of ALICE O2. This software is
32
// distributed under the terms of the GNU General Public License v3 (GPL
43
// Version 3), copied verbatim in the file "COPYING".
54
//
6-
// See https://alice-o2.web.cern.ch/ for full licensing information.
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
76
//
87
// In applying this license CERN does not waive the privileges and immunities
98
// granted to it by virtue of its status as an Intergovernmental Organization
@@ -32,8 +31,8 @@ BOOST_AUTO_TEST_CASE(testTrivialTypeVect)
3231

3332
contType inputV{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
3433

35-
auto msgStr = SerializeContainer(inputV).str();
36-
auto inputV2 = DeserializeContainer<contType>(msgStr);
34+
auto msgStr = BoostSerialize(inputV).str();
35+
auto inputV2 = BoostDeserialize<contType>(msgStr);
3736

3837
BOOST_TEST(inputV.size() == inputV2.size());
3938

@@ -50,8 +49,8 @@ BOOST_AUTO_TEST_CASE(testTrivialTypeArray)
5049

5150
contType inputV{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
5251

53-
auto msgStr = SerializeContainer(inputV).str();
54-
auto inputV2 = DeserializeContainer<contType>(msgStr);
52+
auto msgStr = BoostSerialize(inputV).str();
53+
auto inputV2 = BoostDeserialize<contType>(msgStr);
5554

5655
BOOST_TEST(inputV.size() == inputV2.size());
5756

@@ -68,8 +67,8 @@ BOOST_AUTO_TEST_CASE(testTrivialTypeList)
6867

6968
contType inputV{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
7069

71-
auto msgStr = SerializeContainer(inputV).str();
72-
auto inputV2 = DeserializeContainer<contType>(msgStr);
70+
auto msgStr = BoostSerialize(inputV).str();
71+
auto inputV2 = BoostDeserialize<contType>(msgStr);
7372

7473
BOOST_TEST(inputV.size() == inputV2.size());
7574

@@ -92,8 +91,8 @@ BOOST_AUTO_TEST_CASE(testBoostSerialisedType)
9291
inputV.emplace_back(o2::mid::Cluster2D{ (uint8_t)i, 0.3f * iFloat, 0.5f * iFloat, 0.7f / iFloat, 0.9f / iFloat });
9392
}
9493

95-
auto msgStr = SerializeContainer(inputV).str();
96-
auto inputV2 = DeserializeContainer<contType>(msgStr);
94+
auto msgStr = BoostSerialize(inputV).str();
95+
auto inputV2 = BoostDeserialize<contType>(msgStr);
9796

9897
BOOST_TEST(inputV.size() == inputV2.size());
9998

@@ -108,4 +107,4 @@ BOOST_AUTO_TEST_CASE(testBoostSerialisedType)
108107
}
109108
}
110109

111-
BOOST_AUTO_TEST_SUITE_END()
110+
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)