GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4EventServerFactory.cxx
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4EventServerFactory.h"
15 
16 #include "TGo4Log.h"
17 #include "TGo4MbsEvent.h"
18 #include "TGo4EventStore.h"
19 #include "TGo4FileStore.h"
20 #include "TGo4BackStore.h"
21 #include "TGo4FileStoreParameter.h"
22 #include "TGo4BackStoreParameter.h"
23 
24 #ifdef __GO4HDF5__
25 #include "TGo4HDF5StoreParameter.h"
26 #include "TGo4HDF5Store.h"
28 #include "TGo4HDF5Source.h"
29 #endif
30 
31 #include "TGo4EventSource.h"
32 #include "TGo4FileSource.h"
33 #include "TGo4MbsFile.h"
34 #include "TGo4MbsStream.h"
35 #include "TGo4MbsTransport.h"
36 #include "TGo4MbsEventServer.h"
37 #include "TGo4RevServ.h"
38 #include "TGo4MbsRandom.h"
40 #include "TGo4MbsFileParameter.h"
41 #include "TGo4MbsStreamParameter.h"
44 #include "TGo4RevServParameter.h"
45 #include "TGo4MbsRandomParameter.h"
46 
47 
49  TGo4EventFactory(name), fxEvent(nullptr)
50 {
51  GO4TRACE((15,"TGo4EventServerFactory::TGo4EventServerFactory(const char *)",__LINE__, __FILE__));
52 }
53 
55  TGo4EventFactory("Go4 Event Server Factory"), fxEvent(nullptr)
56 {
57  GO4TRACE((15,"TGo4EventServerFactory::TGo4EventServerFactory()",__LINE__, __FILE__));
58 }
59 
61 {
62  GO4TRACE((15,"TGo4EventServerFactory::~TGo4EventServerFactory()",__LINE__, __FILE__));
63 }
64 
66 {
67  GO4TRACE((14,"TGo4EventServerFactory::CreateInputEvent()",__LINE__, __FILE__));
68 
69 // variant 1: create one default subevent with default identifiers
70 // Short_t procidfield[1]= {1};
71 // Char_t subcratefield[1]={0};
72 // Char_t ctrlfield[1]={0};
73 // UInt_t sizefield[1]={1};
74 // TGo4MbsEvent *event = new TGo4MbsEvent(1, subcratefield, ctrlfield, procidfield, sizefield);
75 // variant 2: empty event without predefined subevents
76  TGo4MbsEvent *event = new TGo4MbsEvent(0, nullptr, nullptr, nullptr, nullptr);
77  TGo4Log::Debug(" EventServer Factory: creating input event %s ", event->ClassName());
78  return event;
79 }
80 
82 {
83  GO4TRACE((14,"TGo4EventServerFactory::CreateEventStore(TGo4EventStoreParameter *)",__LINE__, __FILE__));
84 
85  TGo4EventStore *rev = nullptr;
86 
87  if(par) {
88  if(!strcmp(par->ClassName(), "TGo4FileStoreParameter"))
89  {
90  rev = new TGo4FileStore(dynamic_cast<TGo4FileStoreParameter *>(par) );
91  }
92  else if(!strcmp(par->ClassName(), "TGo4TreeStoreParameter"))
93  {
94  //rev= new TGo4TreeStore(dynamic_cast<TGo4TreeStoreParameter *>(par), fxEvent );
95  TGo4Log::Debug(" EventServer Factory: TreeStore is not recommended, PLEASE USE TGo4FileStore !!!! ");
96  }
97  else if(!strcmp(par->ClassName(), "TGo4BackStoreParameter"))
98  {
99  rev = new TGo4BackStore(dynamic_cast<TGo4BackStoreParameter *>(par));
100  }
101 #ifdef __GO4HDF5__
102  else if(!strcmp(par->ClassName(), "TGo4HDF5StoreParameter"))
103  {
104  rev = new TGo4HDF5Store(dynamic_cast<TGo4HDF5StoreParameter *>(par));
105  }
106 #endif
107  }
108 
109  if(rev)
110  TGo4Log::Debug(" EventServer Factory: creating event store %s ", rev->ClassName());
111  else
112  TGo4Log::Debug(" EventServer Factory: Unknown eventstore parameter %s", par ? par->ClassName() : "---");
113 
114  return rev;
115 }
116 
117 
119 {
120  GO4TRACE((14,"TGo4EventServerFactory::CreateEventSource(TGo4EventSourceParameter *)",__LINE__, __FILE__));
121 
122  TGo4EventSource *rev = nullptr;
123 
124  if(par) {
125  if(!strcmp(par->ClassName(), "TGo4FileSourceParameter"))
126  {
127  rev = new TGo4FileSource(dynamic_cast<TGo4FileSourceParameter *>(par));
128  }
129  else if(!strcmp(par->ClassName(), "TGo4TreeSourceParameter"))
130  {
131  //rev= new TGo4TreeSource(dynamic_cast<TGo4TreeSourceParameter* > (par) );
132  TGo4Log::Debug(" EventServer Factory: TreeSource is not recommended, PLEASE USE TGo4FileSource !!!! ");
133  }
134  else if(!strcmp(par->ClassName(), "TGo4MbsFileParameter"))
135  {
136  rev = new TGo4MbsFile(dynamic_cast<TGo4MbsFileParameter *>(par));
137  //par->Print();
138  }
139  else if(!strcmp(par->ClassName(), "TGo4MbsStreamParameter"))
140  {
141  rev = new TGo4MbsStream(dynamic_cast<TGo4MbsStreamParameter *>(par));
142  }
143  else if(!strcmp(par->ClassName(), "TGo4MbsTransportParameter"))
144  {
145  rev = new TGo4MbsTransport(dynamic_cast<TGo4MbsTransportParameter *>(par));
146  }
147  else if(!strcmp(par->ClassName(), "TGo4MbsEventServerParameter"))
148  {
149  rev = new TGo4MbsEventServer(dynamic_cast<TGo4MbsEventServerParameter *>(par));
150  }
151  else if(!strcmp(par->ClassName(), "TGo4RevServParameter"))
152  {
153  rev = new TGo4RevServ(dynamic_cast<TGo4RevServParameter *>(par) );
154  }
155  else if(!strcmp(par->ClassName(), "TGo4MbsRandomParameter"))
156  {
157  rev = new TGo4MbsRandom(dynamic_cast<TGo4MbsRandomParameter *>(par) );
158  }
159 #ifdef __GO4HDF5__
160  else if(!strcmp(par->ClassName(), "TGo4HDF5SourceParameter"))
161  {
162  rev = new TGo4HDF5Source(dynamic_cast<TGo4HDF5SourceParameter *>(par));
163  }
164 #endif
165  else if(!strcmp(par->ClassName(), "TGo4UserSourceParameter"))
166  {
167  rev = new TGo4MbsRandom(par->GetName());
168  }
169  }
170 
171  if(rev)
172  TGo4Log::Debug(" EventServer Factory: creating event source %s ", rev->ClassName());
173  else
174  TGo4Log::Debug(" EventServer Factory: Unknown eventsource parameter %s ", par ? par->ClassName() : "---");
175 
176  return rev;
177 }
TGo4EventSource * CreateEventSource(TGo4EventSourceParameter *par) override
static void Debug(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:281
TGo4EventStore * CreateEventStore(TGo4EventStoreParameter *par) override
#define GO4TRACE(X)
Definition: TGo4Log.h:25
TGo4EventElement * CreateInputEvent() override