11 #ifndef EVIO_6_0_STRUCTURETRANSFORMER_H
12 #define EVIO_6_0_STRUCTURETRANSFORMER_H
54 static std::shared_ptr<EvioBank>
transform(std::shared_ptr<EvioSegment>
const & segment, uint8_t num) {
56 auto const & segHeader = segment->getHeader();
58 auto const & bankHeader = bank->getHeader();
59 bankHeader->setLength(segHeader->getLength() + 1);
60 bankHeader->setPadding(segHeader->getPadding());
63 bank->transform(segment);
76 static void copy(std::shared_ptr<EvioBank>
const & bank,
77 std::shared_ptr<EvioSegment>
const & segment,
81 auto const & segHeader = segment->getHeader();
82 auto const & bankHeader = bank->getHeader();
83 bankHeader->copy(segHeader);
84 bankHeader->setNumber(num);
85 bankHeader->setLength(segHeader->getLength() + 1);
86 bankHeader->setPadding(segHeader->getPadding());
89 bank->transform(segment);
107 static std::shared_ptr<EvioBank>
transform(std::shared_ptr<EvioTagSegment>
const & tagsegment, uint8_t num) {
108 auto const & tagsegHeader = tagsegment->getHeader();
110 auto const & bankHeader = bank->getHeader();
111 bankHeader->setLength(tagsegHeader->getLength() + 1);
113 bank->transform(tagsegment);
129 static void copy(std::shared_ptr<EvioBank>
const & bank,
130 std::shared_ptr<EvioTagSegment>
const & tagsegment,
133 auto const & tagsegHeader = tagsegment->getHeader();
134 auto const & bankHeader = bank->getHeader();
135 bankHeader->copy(tagsegHeader);
136 bankHeader->setNumber(num);
137 bankHeader->setLength(tagsegHeader->getLength() + 1);
139 bank->transform(tagsegment);
158 static std::shared_ptr<EvioTagSegment>
transform(std::shared_ptr<EvioSegment>
const & segment) {
159 auto const & segHeader = segment->getHeader();
161 auto const & tsHeader = ts->getHeader();
162 tsHeader->setLength(segHeader->getLength());
163 tsHeader->setPadding(segHeader->getPadding());
175 ts->transform(segment);
192 static void copy(std::shared_ptr<EvioTagSegment>
const & tagsegment,
193 std::shared_ptr<EvioSegment>
const & segment) {
195 auto const & segHeader = segment->getHeader();
196 auto const & tsHeader = tagsegment->getHeader();
197 tsHeader->copy(segHeader);
208 tagsegment->transform(segment);
228 static std::shared_ptr<EvioSegment>
transform(std::shared_ptr<EvioTagSegment>
const & tagsegment) {
229 auto const & tsHeader = tagsegment->getHeader();
231 auto const & segHeader = seg->getHeader();
232 segHeader->setLength(tsHeader->getLength());
234 seg->transform(tagsegment);
252 static void copy(std::shared_ptr<EvioSegment>
const & segment,
253 std::shared_ptr<EvioSegment>
const & tagsegment) {
255 auto const & tsHeader = tagsegment->getHeader();
256 auto const & segHeader = segment->getHeader();
257 segHeader->copy(tsHeader);
258 tagsegment->transform(segment);
284 static std::shared_ptr<EvioSegment>
transform(std::shared_ptr<EvioBank>
const & bank) {
285 auto const & bankHeader = bank->getHeader();
286 size_t bankLen = bankHeader->getLength();
287 if (bankLen > 65535) {
288 throw new EvioException(
"Bank is too long to transform into segment");
291 auto const & segHeader = segment->getHeader();
292 segHeader->setLength(bankLen - 1);
293 segHeader->setPadding(bankHeader->getPadding());
294 segHeader->setNumber(bankHeader->getNumber());
296 segment->transform(bank);
321 static void copy(std::shared_ptr<EvioSegment>
const & segment,
322 std::shared_ptr<EvioBank>
const & bank) {
324 auto const & bankHeader = bank->getHeader();
325 size_t bankLen = bankHeader->getLength();
326 if (bankLen > 65535) {
327 throw new EvioException(
"Bank is too long to transform into segment");
329 auto const & segHeader = segment->getHeader();
330 segHeader->copy(bankHeader);
331 segHeader->setLength(bankLen - 1);
333 segment->transform(bank);
364 static std::shared_ptr<EvioTagSegment>
transform(std::shared_ptr<EvioBank>
const & bank,
366 auto const & bankHeader = bank->getHeader();
367 if (bankHeader->getLength() > 65535) {
368 throw new EvioException(
"Bank is too long to transform into segment");
371 auto const & tsHeader = ts->getHeader();
372 tsHeader->setLength(bankHeader->getLength() - 1);
373 tsHeader->setPadding(bankHeader->getPadding());
374 tsHeader->setNumber(bankHeader->getNumber());
409 static void copy(std::shared_ptr<EvioTagSegment>
const & tagsegment,
410 std::shared_ptr<EvioBank>
const & bank) {
412 auto const & bankHeader = bank->getHeader();
413 size_t bankLen = bankHeader->getLength();
414 if (bankLen > 65535) {
415 throw new EvioException(
"Bank is too long to transform into tagsegment");
417 auto const & tsHeader = tagsegment->getHeader();
418 tsHeader->copy(bankHeader);
419 tsHeader->setLength(bankLen - 1);
429 tagsegment->transform(bank);
439 #endif //EVIO_6_0_STRUCTURETRANSFORMER_H
static const DataType ALSOBANK
Bank alternate value.
Definition: DataType.h:50
static std::shared_ptr< EvioSegment > getInstance(std::shared_ptr< SegmentHeader > const &head)
Method to return a shared pointer to a constructed object of this class.
Definition: EvioSegment.h:54
static const DataType SEGMENT
Segment.
Definition: DataType.h:53
Exception class for Evio software package.
Definition: EvioException.h:29
static const DataType & getDataType(uint32_t val)
Get the object from the integer value.
Definition: DataType.h:100
static const DataType BANK
Bank.
Definition: DataType.h:52
static std::shared_ptr< EvioTagSegment > getInstance(std::shared_ptr< TagSegmentHeader > const &head)
Method to return a shared pointer to a constructed object of this class.
Definition: EvioTagSegment.h:53
static const DataType ALSOSEGMENT
Segment alternate value.
Definition: DataType.h:49
Numerical values associated with evio data types.
Definition: DataType.h:32
static std::shared_ptr< EvioBank > getInstance()
Method to return a shared pointer to a constructed object of this class.
Definition: EvioBank.h:57