Skip to content

Commit 5bc2219

Browse files
authored
Drop ability of DataHeader to print itself (#5743)
This allows us to drop the templated Print policy from the DataHeader.h classes, hopefully simplifying the code. As a replacement for the various print methods one can use DataHeaderHelpers.h in conjuction with the various fmt / Logger.h methods.
1 parent e468a5e commit 5bc2219

2 files changed

Lines changed: 7 additions & 70 deletions

File tree

DataFormats/Headers/include/Headers/DataHeader.h

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
4242
#include "MemoryResources/Types.h"
4343
#include <cerrno>
4444

45-
namespace o2
46-
{
47-
namespace header
45+
namespace o2::header
4846
{
4947

5048
//__________________________________________________________________________________________________
@@ -148,10 +146,6 @@ struct TraitsIntType<4> {
148146
using Type = uint32_t;
149147
};
150148

151-
struct defaultPrinter {
152-
void operator()(const char* str) const {}
153-
};
154-
155149
/// compile time evaluation of a string length, which is either N - 1 or
156150
/// shorter if one character in the array has been set to 0.
157151
template <int N>
@@ -253,7 +247,7 @@ struct DescriptorCompareTraits<2> {
253247
/// solution is working also for multiples of 64 bit, but then the itg member needs
254248
/// to be an array for all. This has not been enabled yet, first the implications
255249
/// have to be studied.
256-
template <std::size_t N, typename PrinterPolicy = internal::defaultPrinter>
250+
template <std::size_t N>
257251
struct Descriptor {
258252
static_assert(internal::NumberOfActiveBits<N>::value == 1,
259253
"Descriptor size is required to be a power of 2");
@@ -351,13 +345,6 @@ struct Descriptor {
351345
std::string ret(str, len);
352346
return std::move(ret);
353347
}
354-
// print function needs to be implemented for every derivation
355-
void print() const
356-
{
357-
// eventually terminate string before printing
358-
PrinterPolicy printer;
359-
printer(str);
360-
};
361348
};
362349

363350
//__________________________________________________________________________________________________
@@ -593,20 +580,8 @@ T stoui(const std::string& str, size_t* pos = nullptr, int base = 10)
593580
}
594581
};
595582

596-
//__________________________________________________________________________________________________
597-
/// this 128 bit type for a header field describing the payload data type
598-
struct printDataDescription {
599-
void operator()(const char* str) const;
600-
};
601-
602-
using DataDescription = Descriptor<gSizeDataDescriptionString, printDataDescription>;
603-
604-
//__________________________________________________________________________________________________
605-
// 32bit (4 characters) for data origin, ex. the detector or subsystem name
606-
struct printDataOrigin {
607-
void operator()(const char* str) const;
608-
};
609-
using DataOrigin = Descriptor<gSizeDataOriginString, printDataOrigin>;
583+
using DataOrigin = Descriptor<gSizeDataOriginString>;
584+
using DataDescription = Descriptor<gSizeDataDescriptionString>;
610585

611586
//__________________________________________________________________________________________________
612587
/// @defgroup data_description_defines Defines for data description
@@ -789,7 +764,6 @@ struct DataHeader : public BaseHeader {
789764
bool operator==(const DataOrigin&) const; //comparison
790765
bool operator==(const DataDescription&) const; //comparison
791766
bool operator==(const SerializationMethod&) const; //comparison
792-
void print() const; ///pretty print the contents
793767

794768
static const DataHeader* Get(const BaseHeader* baseHeader)
795769
{
@@ -818,7 +792,6 @@ struct DataIdentifier {
818792
}
819793

820794
bool operator==(const DataIdentifier&) const;
821-
void print() const;
822795
};
823796

824797
//__________________________________________________________________________________________________
@@ -843,12 +816,10 @@ template <typename T>
843816
struct is_descriptor : std::false_type {
844817
};
845818

846-
template <std::size_t S, typename P>
847-
struct is_descriptor<o2::header::Descriptor<S, P>> : std::true_type {
819+
template <std::size_t S>
820+
struct is_descriptor<o2::header::Descriptor<S>> : std::true_type {
848821
};
849822

850-
} //namespace header
851-
852-
} //namespace o2
823+
} //namespace o2::header
853824

854825
#endif

DataFormats/Headers/src/DataHeader.cxx

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,6 @@ void o2::header::BaseHeader::throwInconsistentStackError() const
5151
throw std::runtime_error("inconsistent header stack, no O2 header at expected offset " + std::to_string(this->headerSize) + "for header of type " + this->description.as<std::string>());
5252
}
5353

54-
//__________________________________________________________________________________________________
55-
void o2::header::DataHeader::print() const
56-
{
57-
printf("Data header version %u, flags: %u\n", headerVersion, flags);
58-
printf(" origin : %s\n", dataOrigin.str);
59-
printf(" serialization: %s\n", payloadSerializationMethod.str);
60-
printf(" description : %s\n", dataDescription.str);
61-
printf(" sub spec. : %llu\n", (long long unsigned int)subSpecification);
62-
printf(" header size : %d\n", headerSize);
63-
printf(" payloadSize : %llu\n", (long long unsigned int)payloadSize);
64-
printf(" firstTFOrbit : %u\n", firstTForbit);
65-
printf(" tfCounter : %u\n", tfCounter);
66-
printf(" runNumber : %u\n", runNumber);
67-
}
68-
6954
//__________________________________________________________________________________________________
7055
bool o2::header::DataHeader::operator==(const DataOrigin& that) const
7156
{
@@ -98,18 +83,6 @@ bool o2::header::DataHeader::operator==(const DataHeader& that) const
9883
subSpecification == that.subSpecification);
9984
}
10085

101-
//__________________________________________________________________________________________________
102-
void o2::header::printDataDescription::operator()(const char* str) const
103-
{
104-
printf("Data description : %s\n", str);
105-
}
106-
107-
//__________________________________________________________________________________________________
108-
void o2::header::printDataOrigin::operator()(const char* str) const
109-
{
110-
printf("Data origin : %s\n", str);
111-
}
112-
11386
//__________________________________________________________________________________________________
11487
o2::header::DataIdentifier::DataIdentifier()
11588
: dataDescription(), dataOrigin()
@@ -129,13 +102,6 @@ bool o2::header::DataIdentifier::operator==(const DataIdentifier& other) const
129102
return true;
130103
}
131104

132-
//__________________________________________________________________________________________________
133-
void o2::header::DataIdentifier::print() const
134-
{
135-
dataOrigin.print();
136-
dataDescription.print();
137-
}
138-
139105
//__________________________________________________________________________________________________
140106
void o2::header::hexDump(const char* desc, const void* voidaddr, size_t len, size_t max)
141107
{

0 commit comments

Comments
 (0)