GeezerVison is showing github.com — Hide header::Stack internals in preparation of future updates · coppedis/AliceO2@e69458b
File treeExpand file treeCollapse file tree Open diff view settings Utilities/O2Device/include/O2Device
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Algorithm/test/headerstack.cxx +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(test_headerstack) | 44 | 44 | o2::header::Stack stack(dh, nh); | 45 | 45 |
| 46 | 46 | // check that the call without any other arguments is compiling | 47 | | - o2::algorithm::dispatchHeaderStackCallback(stack.buffer.get(), stack.bufferSize); | | 47 | + o2::algorithm::dispatchHeaderStackCallback(stack.data(), stack.size()); | 48 | 48 |
| 49 | 49 | // lambda functor given as argument for dispatchHeaderStackCallback | 50 | 50 | auto checkDataHeader = [&dh] (const auto & header) { | @@ -60,26 +60,26 @@ BOOST_AUTO_TEST_CASE(test_headerstack) | 60 | 60 | }; | 61 | 61 |
| 62 | 62 | // check extraction of headers via callbacks | 63 | | - o2::algorithm::dispatchHeaderStackCallback(stack.buffer.get(), stack.bufferSize, | | 63 | + o2::algorithm::dispatchHeaderStackCallback(stack.data(), stack.size(), | 64 | 64 | o2::header::DataHeader(), | 65 | 65 | checkDataHeader, | 66 | 66 | Name8Header(), | 67 | 67 | checkNameHeader | 68 | 68 | ); | 69 | 69 |
| 70 | 70 | // check extraction of only one header via callback | 71 | | - o2::algorithm::dispatchHeaderStackCallback(stack.buffer.get(), stack.bufferSize, | | 71 | + o2::algorithm::dispatchHeaderStackCallback(stack.data(), stack.size(), | 72 | 72 | Name8Header(), | 73 | 73 | checkNameHeader | 74 | 74 | ); | 75 | 75 |
| 76 | 76 | // check that the call without any other arguments is compiling | 77 | | - o2::algorithm::parseHeaderStack(stack.buffer.get(), stack.bufferSize); | | 77 | + o2::algorithm::parseHeaderStack(stack.data(), stack.size()); | 78 | 78 |
| 79 | 79 | // check extraction of headers via object references | 80 | 80 | o2::header::DataHeader targetDataHeader; | 81 | 81 | Name8Header targetNameHeader; | 82 | | - o2::algorithm::parseHeaderStack(stack.buffer.get(), stack.bufferSize, | | 82 | + o2::algorithm::parseHeaderStack(stack.data(), stack.size(), | 83 | 83 | targetDataHeader, | 84 | 84 | targetNameHeader | 85 | 85 | ); | |
Collapse file Copy file name to clipboardExpand all lines: DataFormats/Headers/include/Headers/DataHeader.h +6-4Lines changed: 6 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -446,7 +446,12 @@ auto get(const void* buffer, size_t len = 0) | 446 | 446 | // - arguments can be headers, or stacks, all will be concatenated in a new Stack | 447 | 447 | /// - returns a Stack ready to be shipped. | 448 | 448 | struct Stack { | | 449 | + protected: | | 450 | + using Buffer = std::unique_ptr<byte[]>; | | 451 | + size_t bufferSize; | | 452 | + Buffer buffer; | 449 | 453 |
| | 454 | + public: | 450 | 455 | // This is ugly and needs fixing BUT: | 451 | 456 | // we need a static deleter for fairmq. | 452 | 457 | // TODO: maybe use allocator_traits if custom allocation is desired | @@ -455,17 +460,14 @@ struct Stack { | 455 | 460 | // The copy can be avoided if we construct in place inside a FairMQMessage directly (instead of | 456 | 461 | // allocating a unique_ptr we would hold a FairMQMessage which for the large part has similar semantics). | 457 | 462 | // | 458 | | - using Buffer = std::unique_ptr<byte[]>; | 459 | 463 | static std::default_delete<byte[]> sDeleter; | 460 | 464 | static void freefn(void* /*data*/, void* hint) { | 461 | 465 | Stack::sDeleter(static_cast<byte*>(hint)); | 462 | 466 | } | 463 | 467 |
| 464 | | - size_t bufferSize; | 465 | | - Buffer buffer; | 466 | | - | 467 | 468 | byte* data() const {return buffer.get();} | 468 | 469 | size_t size() const {return bufferSize;} | | 470 | + void release() {buffer.release();} | 469 | 471 |
| 470 | 472 | ///The magic constructor: takes arbitrary number of arguments and serialized them | 471 | 473 | /// into the buffer. | |
Collapse file Copy file name to clipboardExpand all lines: DataFormats/Headers/test/testDataHeader.cxx +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -166,10 +166,10 @@ namespace o2 { | 166 | 166 | Stack s1{ DataHeader{ gDataDescriptionInvalid, gDataOriginInvalid, DataHeader::SubSpecificationType{ 0 }, 0 }, | 167 | 167 | NameHeader<9>{ "somename" } }; | 168 | 168 |
| 169 | | - const DataHeader* h1 = get<DataHeader*>(s1.buffer.get()); | | 169 | + const DataHeader* h1 = get<DataHeader*>(s1.data()); | 170 | 170 | BOOST_CHECK(h1 != nullptr); | 171 | 171 | BOOST_CHECK(*h1 == dh1); | 172 | | - const NameHeader<0>* h2 = get<NameHeader<0>*>(s1.buffer.get()); | | 172 | + const NameHeader<0>* h2 = get<NameHeader<0>*>(s1.data()); | 173 | 173 | BOOST_CHECK(h2 != nullptr); | 174 | 174 | BOOST_CHECK(0 == std::strcmp(h2->getName(), "somename")); | 175 | 175 | BOOST_CHECK(h2->description == NameHeader<0>::sHeaderType); | |
Collapse file Copy file name to clipboardExpand all lines: Framework/Core/src/DataAllocator.cxx +12-12Lines changed: 12 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -64,11 +64,11 @@ DataAllocator::newChunk(const Output& spec, size_t size) { | 64 | 64 | //we have to move the incoming data | 65 | 65 | o2::header::Stack headerStack{dh, dph}; | 66 | 66 | FairMQMessagePtr headerMessage = mDevice->NewMessageFor(channel, 0, | 67 | | - headerStack.buffer.get(), | 68 | | - headerStack.bufferSize, | | 67 | + headerStack.data(), | | 68 | + headerStack.size(), | 69 | 69 | &o2::header::Stack::freefn, | 70 | | - headerStack.buffer.get()); | 71 | | - headerStack.buffer.release(); | | 70 | + headerStack.data()); | | 71 | + headerStack.release(); | 72 | 72 | FairMQMessagePtr payloadMessage = mDevice->NewMessageFor(channel, 0, size); | 73 | 73 | auto dataPtr = payloadMessage->GetData(); | 74 | 74 | auto dataSize = payloadMessage->GetSize(); | @@ -99,11 +99,11 @@ DataAllocator::adoptChunk(const Output& spec, char *buffer, size_t size, fairmq_ | 99 | 99 | //we have to move the incoming data | 100 | 100 | o2::header::Stack headerStack{dh, dph}; | 101 | 101 | FairMQMessagePtr headerMessage = mDevice->NewMessageFor(channel, 0, | 102 | | - headerStack.buffer.get(), | 103 | | - headerStack.bufferSize, | | 102 | + headerStack.data(), | | 103 | + headerStack.size(), | 104 | 104 | &o2::header::Stack::freefn, | 105 | | - headerStack.buffer.get()); | 106 | | - headerStack.buffer.release(); | | 105 | + headerStack.data()); | | 106 | + headerStack.release(); | 107 | 107 |
| 108 | 108 | FairMQParts parts; | 109 | 109 |
| @@ -135,11 +135,11 @@ DataAllocator::headerMessageFromOutput(Output const &spec, | 135 | 135 | //we have to move the incoming data | 136 | 136 | o2::header::Stack headerStack{dh, dph}; | 137 | 137 | FairMQMessagePtr headerMessage = mDevice->NewMessageFor(channel, 0, | 138 | | - headerStack.buffer.get(), | 139 | | - headerStack.bufferSize, | | 138 | + headerStack.data(), | | 139 | + headerStack.size(), | 140 | 140 | &o2::header::Stack::freefn, | 141 | | - headerStack.buffer.get()); | 142 | | - headerStack.buffer.release(); | | 141 | + headerStack.data()); | | 142 | + headerStack.release(); | 143 | 143 | return std::move(headerMessage); | 144 | 144 | } | 145 | 145 |
| |
Collapse file Copy file name to clipboardExpand all lines: Framework/Core/src/ExternalFairMQDeviceProxy.cxx +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -38,11 +38,11 @@ void broadcastMessage(FairMQDevice &device, o2::header::Stack &&headerStack, Fai | 38 | 38 | // FIXME: this assumes there is only one output from here... This should | 39 | 39 | // really do the matchmaking between inputs and output channels. | 40 | 40 | FairMQMessagePtr headerMessage = device.NewMessageFor(channel, index, | 41 | | - headerStack.buffer.get(), | 42 | | - headerStack.bufferSize, | | 41 | + headerStack.data(), | | 42 | + headerStack.size(), | 43 | 43 | &o2::header::Stack::freefn, | 44 | | - headerStack.buffer.get()); | 45 | | - headerStack.buffer.release(); | | 44 | + headerStack.data()); | | 45 | + headerStack.release(); | 46 | 46 | FairMQParts out; | 47 | 47 | out.AddPart(std::move(headerMessage)); | 48 | 48 | out.AddPart(std::move(payloadMessage)); | |
Collapse file Copy file name to clipboardExpand all lines: Utilities/O2Device/include/O2Device/O2Device.h +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -74,11 +74,11 @@ class O2Device : public FairMQDevice | 74 | 74 | o2::header::Stack headerStack{std::move(incomingStack)}; | 75 | 75 | FairMQMessagePtr dataMessage{std::move(incomingDataMessage)}; | 76 | 76 |
| 77 | | - FairMQMessagePtr headerMessage = NewMessage(headerStack.buffer.get(), | 78 | | - headerStack.bufferSize, | | 77 | + FairMQMessagePtr headerMessage = NewMessage(headerStack.data(), | | 78 | + headerStack.size(), | 79 | 79 | &o2::header::Stack::freefn, | 80 | | - headerStack.buffer.get()); | 81 | | - headerStack.buffer.release(); | | 80 | + headerStack.data()); | | 81 | + headerStack.release(); | 82 | 82 |
| 83 | 83 | parts.AddPart(std::move(headerMessage)); | 84 | 84 | parts.AddPart(std::move(dataMessage)); | |
|