105 std::string
filename =
"test_RootTreeWriter.root";
106 const char* treename =
"testtree";
108 using Container = std::vector<o2::test::Polymorphic>;
114 auto const* dataHeader = DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
115 return dataHeader->subSpecification;
117 auto getName = [](std::string base,
size_t i) -> std::string {
120 auto customClose = [](TFile*
file, TTree*
tree) {
124 INFO(
"Custom close, tree has " <<
tree->GetEntries() <<
" entries");
134 std::vector<std::string>({
"input2",
"input3"}),
"containerbranch",
148 CHECK(writer.getStoreSize() == 7);
151 auto transport = fair::mq::TransportFactory::CreateTransportFactory(
"zeromq");
152 std::vector<fair::mq::MessagePtr> store;
154 auto createPlainMessage = [&transport, &store](
DataHeader&& dh,
auto&
data) {
155 dh.payloadSize =
sizeof(
data);
159 fair::mq::MessagePtr header = transport->CreateMessage(
stack.size());
160 fair::mq::MessagePtr payload = transport->CreateMessage(
sizeof(
data));
161 memcpy(header->GetData(),
stack.data(),
stack.size());
162 memcpy(payload->GetData(), &
data,
sizeof(
data));
163 store.emplace_back(std::move(header));
164 store.emplace_back(std::move(payload));
167 auto createVectorMessage = [&transport, &store](
DataHeader&& dh,
auto&
data) {
168 dh.payloadSize =
data.size() *
sizeof(
typename std::remove_reference<
decltype(
data)>::type::value_type);
172 fair::mq::MessagePtr header = transport->CreateMessage(
stack.size());
173 fair::mq::MessagePtr payload = transport->CreateMessage(dh.payloadSize);
174 memcpy(header->GetData(),
stack.data(),
stack.size());
175 memcpy(payload->GetData(),
data.data(), dh.payloadSize);
176 store.emplace_back(std::move(header));
177 store.emplace_back(std::move(payload));
180 auto createSerializedMessage = [&transport, &store](
DataHeader&& dh,
auto&
data) {
181 fair::mq::MessagePtr payload = transport->CreateMessage();
182 payload->Rebuild(4096, {64});
183 auto* cl = TClass::GetClass(
typeid(
decltype(
data)));
185 dh.payloadSize = payload->GetSize();
189 fair::mq::MessagePtr header = transport->CreateMessage(
stack.size());
190 memcpy(header->GetData(),
stack.data(),
stack.size());
191 store.emplace_back(std::move(header));
192 store.emplace_back(std::move(payload));
199 std::vector<int> intvec{10, 21, 42};
200 std::vector<o2::test::TriviallyCopyable> trivvec{{10, 21, 42}, {1, 2, 3}};
216 std::vector<InputRoute> schema = {
217 {
InputSpec{
"input1",
"TST",
"INT"}, 0,
"input1", 0},
218 {
InputSpec{
"input2",
"TST",
"CONTAINER"}, 1,
"input2", 0},
219 {
InputSpec{
"input3",
"TST",
"CONTAINER"}, 2,
"input3", 0},
220 {
InputSpec{
"input4",
"TST",
"BINARY"}, 3,
"input4", 0},
221 {
InputSpec{
"input5",
"TST",
"MSGABLE"}, 4,
"input5", 0},
222 {
InputSpec{
"input6",
"TST",
"FDMTLVEC"}, 5,
"input6", 0},
223 {
InputSpec{
"input7",
"TST",
"TRIV_VEC"}, 6,
"input7", 0},
224 {
InputSpec{
"input8",
"TST",
"SRLZDVEC"}, 7,
"input8", 0},
227 auto getter = [&store](
size_t i) ->
DataRef {
228 return DataRef{
nullptr,
static_cast<char const*
>(store[2 *
i]->GetData()),
static_cast<char const*
>(store[2 *
i + 1]->GetData())};
241 BranchContent<
decltype(
a)>{
"intbranch", a},
242 BranchContent<
decltype(
b)>{
"containerbranch_0", b},
243 BranchContent<
decltype(
c)>{
"containerbranch_1", c},
244 BranchContent<
decltype(msgable)>{
"msgablebranch", msgable},
245 BranchContent<
decltype(intvec)>{
"intvecbranch", intvec},
246 BranchContent<
decltype(trivvec)>{
"trivvecbranch", trivvec},
247 BranchContent<
decltype(trivvec)>{
"srlzdvecbranch", trivvec});
296 static_assert(std::is_same<Trait<int>::store_type,
int>
::value ==
true);
304 static_assert(std::is_same<Trait<Polymorphic>::store_type,
Polymorphic*>
::value ==
true);
312 static_assert(std::is_same<Trait<std::vector<int>>::store_type, std::vector<int>*>
::value ==
true);
316 static_assert(std::is_same<Trait<std::vector<TriviallyCopyable>>::store_type, std::vector<TriviallyCopyable>*>
::value ==
true);
320 static_assert(std::is_same<Trait<std::vector<Polymorphic>>::store_type, std::vector<Polymorphic>*>
::value ==
true);
#define CHECK_MESSAGE(cond, msg)