evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EventBuilder.h
Go to the documentation of this file.
1 //
2 // Copyright 2020, Jefferson Science Associates, LLC.
3 // Subject to the terms in the LICENSE file found in the top-level directory.
4 //
5 // EPSCI Group
6 // Thomas Jefferson National Accelerator Facility
7 // 12000, Jefferson Ave, Newport News, VA 23606
8 // (757)-269-7100
9 
10 
11 #ifndef EVIO_6_0_EVENTBUILDER_H
12 #define EVIO_6_0_EVENTBUILDER_H
13 
14 
15 #include <iostream>
16 #include <cstdio>
17 #include <stdexcept>
18 #include <memory>
19 
20 
21 #include "DataType.h"
22 #include "EvioEvent.h"
23 #include "EvioBank.h"
24 #include "EvioSegment.h"
25 #include "EvioTagSegment.h"
26 #include "BaseStructure.h"
27 #include "StructureType.h"
28 #include "EventWriter.h"
29 #include "CompositeData.h"
30 
31 
32 namespace evio {
33 
43  class EventBuilder {
44 
45  private:
46 
48  std::shared_ptr<EvioEvent> event;
49 
50  public:
51 
52  EventBuilder(uint16_t tag, DataType const dataType, uint8_t num) ;
53  EventBuilder(std::shared_ptr<EvioEvent> & event);
54 
55  void setAllHeaderLengths();
56  void clearData(std::shared_ptr<BaseStructure> structure);
57  void addChild(std::shared_ptr<BaseStructure> parent, std::shared_ptr<BaseStructure> child);
58  void remove(std::shared_ptr<BaseStructure> child);
59 
60  void setIntData(std::shared_ptr<BaseStructure> structure, int32_t* data, size_t count);
61  void setUIntData(std::shared_ptr<BaseStructure> structure, uint32_t* data, size_t count);
62  void setShortData(std::shared_ptr<BaseStructure> structure, int16_t* data, size_t count);
63  void setUShortData(std::shared_ptr<BaseStructure> structure, uint16_t* data, size_t count);
64  void setLongData(std::shared_ptr<BaseStructure> structure, int64_t* data, size_t count);
65  void setULongData(std::shared_ptr<BaseStructure> structure, uint64_t* data, size_t count);
66  void setCharData(std::shared_ptr<BaseStructure> structure, char* data, size_t count);
67  void setUCharData(std::shared_ptr<BaseStructure> structure, unsigned char* data, size_t count);
68  void setFloatData(std::shared_ptr<BaseStructure> structure, float* data, size_t count);
69  void setDoubleData(std::shared_ptr<BaseStructure> structure, double* data, size_t count);
70 
71  // TODO: Need to look at adding strings & composite data,, vectors???????
72  void setStringData(std::shared_ptr<BaseStructure> structure, std::string* data, size_t count);
73  void setCompositeData(std::shared_ptr<BaseStructure> structure,
74  std::shared_ptr<CompositeData> *data, size_t count);
75 
76  void appendIntData(std::shared_ptr<BaseStructure> structure, int32_t* data, size_t count);
77  void appendUIntData(std::shared_ptr<BaseStructure> structure, uint32_t* data, size_t count);
78  void appendShortData(std::shared_ptr<BaseStructure> structure, int16_t* data, size_t count);
79  void appendUShortData(std::shared_ptr<BaseStructure> structure, uint16_t* data, size_t count);
80  void appendLongData(std::shared_ptr<BaseStructure> structure, int64_t* data, size_t count);
81  void appendULongData(std::shared_ptr<BaseStructure> structure, uint64_t* data, size_t count);
82  void appendCharData(std::shared_ptr<BaseStructure> structure, char* data, size_t count);
83  void appendUCharData(std::shared_ptr<BaseStructure> structure, unsigned char* data, size_t count);
84  void appendFloatData(std::shared_ptr<BaseStructure> structure, float* data, size_t count);
85  void appendDoubleData(std::shared_ptr<BaseStructure> structure, double* data, size_t count);
86  void appendStringData(std::shared_ptr<BaseStructure> structure, std::string* data, size_t count);
87  void appendCompositeData(std::shared_ptr<BaseStructure> structure,
88  std::shared_ptr<CompositeData> *data, size_t count);
89 
90  std::shared_ptr<EvioEvent> getEvent();
91  void setEvent(std::shared_ptr<EvioEvent> & ev);
92 
93  static int main(int argc, char **argv);
94 
95  private:
96 
97  static void fakeIntArray(uint32_t* array, uint32_t size);
98  static void fakeShortArray(uint16_t* array, uint32_t size);
99  static std::string* fakeStringArray();
100  static void fakeDoubleArray(double *array, uint32_t size);
101 
102  };
103 
104 
105 }
106 
107 
108 #endif //EVIO_6_0_EVENTBUILDER_H
void appendFloatData(std::shared_ptr< BaseStructure > structure, float *data, size_t count)
Append float data to the structure.
Definition: EventBuilder.cpp:671
std::shared_ptr< EvioEvent > getEvent()
Get the underlying event.
Definition: EventBuilder.cpp:773
void setAllHeaderLengths()
This goes through the event recursively, and makes sure all the length fields in the headers are prop...
Definition: EventBuilder.cpp:41
void setIntData(std::shared_ptr< BaseStructure > structure, int32_t *data, size_t count)
Set int data in the structure.
Definition: EventBuilder.cpp:158
void appendUCharData(std::shared_ptr< BaseStructure > structure, unsigned char *data, size_t count)
Append unsigned char data to the structure.
Definition: EventBuilder.cpp:645
void setUIntData(std::shared_ptr< BaseStructure > structure, uint32_t *data, size_t count)
Set unsigned int data in the structure.
Definition: EventBuilder.cpp:183
void setUCharData(std::shared_ptr< BaseStructure > structure, unsigned char *data, size_t count)
Set unsigned char data in the structure.
Definition: EventBuilder.cpp:333
void setUShortData(std::shared_ptr< BaseStructure > structure, uint16_t *data, size_t count)
Set unsigned short data in the structure.
Definition: EventBuilder.cpp:233
void setLongData(std::shared_ptr< BaseStructure > structure, int64_t *data, size_t count)
Set long data in the structure.
Definition: EventBuilder.cpp:258
This class is used for creating and manipulating events.
Definition: EventBuilder.h:43
void addChild(std::shared_ptr< BaseStructure > parent, std::shared_ptr< BaseStructure > child)
Add a child to a parent structure.
Definition: EventBuilder.cpp:72
void appendLongData(std::shared_ptr< BaseStructure > structure, int64_t *data, size_t count)
Append long data to the structure.
Definition: EventBuilder.cpp:567
void setEvent(std::shared_ptr< EvioEvent > &ev)
Set the underlying event.
Definition: EventBuilder.cpp:781
void appendDoubleData(std::shared_ptr< BaseStructure > structure, double *data, size_t count)
Append double data to the structure.
Definition: EventBuilder.cpp:697
void setShortData(std::shared_ptr< BaseStructure > structure, int16_t *data, size_t count)
Set short data in the structure.
Definition: EventBuilder.cpp:208
void setCharData(std::shared_ptr< BaseStructure > structure, char *data, size_t count)
Set char data in the structure.
Definition: EventBuilder.cpp:308
void setStringData(std::shared_ptr< BaseStructure > structure, std::string *data, size_t count)
Set string data in the structure.
Definition: EventBuilder.cpp:408
void appendIntData(std::shared_ptr< BaseStructure > structure, int32_t *data, size_t count)
Append int data to the structure.
Definition: EventBuilder.cpp:462
void setFloatData(std::shared_ptr< BaseStructure > structure, float *data, size_t count)
Set float data in the structure.
Definition: EventBuilder.cpp:358
void appendULongData(std::shared_ptr< BaseStructure > structure, uint64_t *data, size_t count)
Append unsigned long data to the structure.
Definition: EventBuilder.cpp:593
void appendStringData(std::shared_ptr< BaseStructure > structure, std::string *data, size_t count)
Append string data to the structure.
Definition: EventBuilder.cpp:723
Numerical values associated with evio data types.
Definition: DataType.h:32
void setCompositeData(std::shared_ptr< BaseStructure > structure, std::shared_ptr< CompositeData > *data, size_t count)
Set composite data in the structure.
Definition: EventBuilder.cpp:433
void setULongData(std::shared_ptr< BaseStructure > structure, uint64_t *data, size_t count)
Set unsigned long data in the structure.
Definition: EventBuilder.cpp:283
void clearData(std::shared_ptr< BaseStructure > structure)
This clears all the data fields in a structure, but not the parent or the children.
Definition: EventBuilder.cpp:57
void appendCharData(std::shared_ptr< BaseStructure > structure, char *data, size_t count)
Append char data to the structure.
Definition: EventBuilder.cpp:619
void appendCompositeData(std::shared_ptr< BaseStructure > structure, std::shared_ptr< CompositeData > *data, size_t count)
Append string data to the structure.
Definition: EventBuilder.cpp:749
void appendUIntData(std::shared_ptr< BaseStructure > structure, uint32_t *data, size_t count)
Append unsigned int data to the structure.
Definition: EventBuilder.cpp:489
void appendShortData(std::shared_ptr< BaseStructure > structure, int16_t *data, size_t count)
Append short data to the structure.
Definition: EventBuilder.cpp:515
EventBuilder(uint16_t tag, DataType const dataType, uint8_t num)
This is the constructor to use for an EventBuilder object that will operate on a new, empty event.
Definition: EventBuilder.cpp:24
static int main(int argc, char **argv)
Main program for testing.
Definition: EventBuilder.cpp:792
void appendUShortData(std::shared_ptr< BaseStructure > structure, uint16_t *data, size_t count)
Append unsigned short data to the structure.
Definition: EventBuilder.cpp:541
void setDoubleData(std::shared_ptr< BaseStructure > structure, double *data, size_t count)
Set double data in the structure.
Definition: EventBuilder.cpp:383