GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4EventServerFactory.cxx
Go to the documentation of this file.
1 // $Id: TGo4EventServerFactory.cxx 2748 2020-04-16 09:50:56Z linev $
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(0)
50 {
51  GO4TRACE((15,"TGo4EventServerFactory::TGo4EventServerFactory(const char*)",__LINE__, __FILE__));
52 }
53 
55  TGo4EventFactory("Go4 Event Server Factory"),fxEvent(0)
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, 0, 0, 0, 0);
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 = 0;
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 ");
113 
114  return rev;
115 }
116 
117 
119 {
120  GO4TRACE((14,"TGo4EventServerFactory::CreateEventSource(TGo4EventSourceParameter*)",__LINE__, __FILE__));
121 
122 
123  TGo4EventSource* rev=0;
124 
125  if(par!=0) {
126  if(!strcmp(par->ClassName(),"TGo4FileSourceParameter"))
127  {
128  rev = new TGo4FileSource(dynamic_cast<TGo4FileSourceParameter* > (par) );
129  }
130  else if(!strcmp(par->ClassName(),"TGo4TreeSourceParameter"))
131  {
132  //rev= new TGo4TreeSource(dynamic_cast<TGo4TreeSourceParameter* > (par) );
133  TGo4Log::Debug(" EventServer Factory: TreeSource is not recommended, PLEASE USE TGo4FileSource !!!! ");
134  }
135  else if(!strcmp(par->ClassName(),"TGo4MbsFileParameter"))
136  {
137  rev = new TGo4MbsFile(dynamic_cast<TGo4MbsFileParameter* > (par) );
138  //par->PrintParameter();
139  }
140  else if(!strcmp(par->ClassName(),"TGo4MbsStreamParameter"))
141  {
142  rev = new TGo4MbsStream(dynamic_cast<TGo4MbsStreamParameter* > (par) );
143  }
144  else if(!strcmp(par->ClassName(),"TGo4MbsTransportParameter"))
145  {
146  rev = new TGo4MbsTransport(dynamic_cast<TGo4MbsTransportParameter* > (par) );
147  }
148  else if(!strcmp(par->ClassName(),"TGo4MbsEventServerParameter"))
149  {
150  rev = new TGo4MbsEventServer(dynamic_cast<TGo4MbsEventServerParameter* > (par) );
151  }
152 
153  else if(!strcmp(par->ClassName(),"TGo4RevServParameter"))
154  {
155  rev = new TGo4RevServ(dynamic_cast<TGo4RevServParameter* > (par) );
156  }
157  else if(!strcmp(par->ClassName(),"TGo4MbsRandomParameter"))
158  {
159  rev = new TGo4MbsRandom(dynamic_cast<TGo4MbsRandomParameter* > (par) );
160  }
161 #ifdef __GO4HDF5__
162  else if(!strcmp(par->ClassName(),"TGo4HDF5SourceParameter"))
163  {
164  rev = new TGo4HDF5Source(dynamic_cast<TGo4HDF5SourceParameter* > (par));
165  }
166 #endif
167 
168 
169  else if(!strcmp(par->ClassName(),"TGo4UserSourceParameter"))
170  {
171  rev = new TGo4MbsRandom(par->GetName());
172  }
173  }
174 
175  if(rev)
176  TGo4Log::Debug(" EventServer Factory: creating event source %s ", rev->ClassName());
177  else
178  TGo4Log::Debug(" EventServer Factory: Unknown eventsource parameter ");
179 
180  return rev;
181 }
virtual TGo4EventSource * CreateEventSource(TGo4EventSourceParameter *par)
virtual TGo4EventElement * CreateInputEvent()
#define GO4TRACE(X)
Definition: TGo4Log.h:26
virtual TGo4EventStore * CreateEventStore(TGo4EventStoreParameter *par)
static void Debug(const char *text,...)
Definition: TGo4Log.cxx:284