GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AgataFrameFactory.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004 by Olivier Stezowski *
3  * stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
24 #include "AgataFrameFactory.h"
25 #include "AgataKeyFactory.h"
26 #include "AgataCompositeFrame.h"
27 #include "PSAFrame.h"
28 #include "CrystalFrame.h"
29 #include "TrackedFrame.h"
31 #include "AgataRawFrame.h"
32 #include "MetaFrame.h"
33 
34 using namespace ADF;
35 
36 // To help managing the various kind of Frame,
37 // each file of type icpp (for 'include in .cpp') contains one implementation
38 #include "AgataCompositeFrame.icpp"
39 #include "PSAFrame.icpp"
40 #include "CrystalFrame.icpp"
41 #include "TrackedFrame.icpp"
42 
43 #include "PSAFrame_dev.icpp"
44 #include "CrystalFrame_dev.icpp"
45 #include "TrackedFrame_dev.icpp"
46 
47 #include "MetaFrame.icpp"
48 
49 AgataFrameFactory::AgataFrameFactory(): AFrameFactory<AgataFrameFactory>("Agata")
50 {
51 }
52 
53 SharedFP *AgataFrameFactory::DoNew(Key *key, const FactoryItem & which_frame)
54 {
55  // cannot deal with request asking for a version greater that this version
56  if ( which_frame.GetFactoryVersion() > GetMaxVersion() )
57  return 0x0;
58 
59  // allocation is done in two steps. First Frame, then the SharedFP. Specific ones (inheriting for SharedFP) could be implemented. So far only SharedFP
60  SharedFP *sfp = 0x0; Frame *frame = 0x0;
61 
62 // just a raw Frame
63  if ( which_frame.GetItemName().find("agata") == 0 ) {
64  frame = new AgataRawFrame(key);
65  }
66 // any conf frames
67  if ( which_frame.GetItemName().find("conf") == 0 ) {
68  frame = new AgataConfigurationFrame(key);
69  }
70 // any algo frames
71  if ( which_frame.GetItemName().find("algo") == 0 ) {
72  frame = new AgataConfigurationFrame(key);
73  }
74 // just a raw frame that can be used by the user to send messages
75  if ( which_frame.GetItemName().find("rmess") == 0 ) {
76  frame = new AgataRawFrame(key);
77  }
78 // just a conf frame that can be used by the user to send messages
79  if ( which_frame.GetItemName().find("cmess") == 0 ) {
80  frame = new AgataConfigurationFrame(key);
81  }
82 
83 // data frames
84 // CRYSTAL --------------------------------------------------------------------------- //
85  if ( which_frame.GetItemName() == "data:crystal" ) {
86  if ( which_frame.GetVersion() == Version(0,0) )
87  frame = new CrystalFrame_0(key);
88  }
89  if ( which_frame.GetItemName() == "data:ccrystal" ) {
90  if ( which_frame.GetVersion() == Version(0,0) )
91  frame = new CrystalFrame_1(key);
92  }
93  if ( which_frame.GetItemName() == "data:crystal" ) {
94  if ( which_frame.GetVersion() == Version(65000,0) )
95  frame = new CrystalFrame_0(key);
96  }
97  if ( which_frame.GetItemName() == "data:ccrystal" ) {
98  if ( which_frame.GetVersion() == Version(65000,0) )
99  frame = new CrystalFrame_1(key);
100  }
101 // PSA --------------------------------------------------------------------------- //
102  if ( which_frame.GetItemName() == "data:psa" ) {
103  if ( which_frame.GetVersion() == Version(65000,0) )
104  frame = new PSAFrame_65000_0(key);
105  if ( which_frame.GetVersion() == Version(65000,1) )
106  frame = new PSAFrame_65000_1(key);
107  if ( which_frame.GetVersion() == Version(0,0) )
108  frame = new PSAFrame_0_0(key);
109  }
110 // Tracked --------------------------------------------------------------------------- //
111  if ( which_frame.GetItemName() == "data:tracked" ) {
112  if ( which_frame.GetVersion() == Version(65000,0) )
113  frame = new TrackedFrame_65000_0(key);
114  if ( which_frame.GetVersion() == Version(65000,1) )
115  frame = new TrackedFrame_65000_1(key);
116  if ( which_frame.GetVersion() == Version(0,0) )
117  frame = new TrackedFrame_0_0(key);
118  }
119 // by default not specific data means raw
120  if ( frame == 0x0 && which_frame.GetItemName().find("data") == 0 ) {
121  frame = new AgataRawFrame(key);
122  }
123 // data frames
124 
125 // meta --------------------------------------------------------------------------- //
126  // eof End Of Frame/File
127  if ( which_frame.GetItemName() == "meta:eof" ) {
128  frame = new AgataRawFrame(key);
129  }
130  //
131  if ( which_frame.GetItemName() == "meta:sync" ) {
132  if ( which_frame.GetVersion() == Version(0,0) )
133  frame = new SyncFrame_0_0(key);
134  }
135  // VertexFrame
136  if ( which_frame.GetItemName() == "meta:vertex" ) {
137  if ( which_frame.GetVersion() == Version(0,0) )
138  frame = new VertexFrame_0_0(key);
139  if ( which_frame.GetVersion() == Version(0,1) )
140  frame = new VertexFrame_0_1(key);
141  if ( which_frame.GetVersion() == Version(1,0) )
142  frame = new VertexFrame_1_0(key);
143  if ( which_frame.GetVersion() == Version(1,1) )
144  frame = new VertexFrame_1_1(key);
145  }
146  // by default not specific data means raw
147  if ( frame == 0x0 && which_frame.GetItemName().find("meta") == 0 ) {
148  frame = new AgataRawFrame(key);
149  }
150 // meta --------------------------------------------------------------------------- //
151 
152 // composite frames --------------------------------------------------------------------------- //
153 
154  if ( which_frame.GetItemName().find("event") == 0 ) { //
155  //
156  std::string event_data_type(which_frame.GetItemName(),6);
157  // to test if the composite frame exists i.e. if the version of the key exist
158  Key *keytest = 0x0;
159  //
160  FactoryItem secondary_key =
161  key->GetSignature();
162  secondary_key.SetItemName(event_data_type.data());
163  //
164  keytest = MainKeyFactory::theMainFactory().New(secondary_key);
165  if ( keytest ) {
166  // frames are composed of any kind of agata keys
167  frame =
168  new AgataCompositeFrame(key,secondary_key);
169 
170  // not needed anymore
171  delete keytest;
172  }
173  }
174 
175 // composite frames --------------------------------------------------------------------------- //
176 
177  // now return SharedFP. If not specific, and frame is allocated, create a base one and add Frame to it
178  if ( sfp == 0x0 && frame )
179  sfp = new SharedFP(frame);
180 
181  // WARNING : could be 0x0 !
182 
183  return sfp;
184 }
185 
186 
187 
188 
189 
190 
191 
192 
Base class for a Key.
Definition: Key.h:56
header file for AgataFrameFactory.cpp
Base class for a Frame.
Definition: Frame.h:73
const FactoryItem & GetSignature() const
Definition: Key.h:115
header file for TrackedFrame.cpp
header file for CrystalFrame.cpp
header file for AgataCompositeFrame.cpp
A configuration frame is just an encapsulation of a string.
header file for PSAFrame.cpp
Short_t GetFactoryVersion() const
Ask the factory version.
Definition: FactoryItem.h:82
Base class for version numbers.
Definition: Version.h:38
A AgataRawFrame gives direct access to the underlying buffer.
Definition: AgataRawFrame.h:37
header file for AgataKeyFactory.cpp
void SetItemName(const char *iname)
Definition: FactoryItem.h:107
AgataFrameFactory, implements agata's like Frame Factory.
A Shared Frame Pointer.
Definition: Frame.h:597
Version GetVersion() const
Definition: FactoryItem.h:88
header file for MetaFrame.cpp
header file for AgataRawFrame.cpp
Base class for any kind of Frame factory.
Definition: FrameFactory.h:181
const std::string & GetItemName() const
Definition: FactoryItem.h:78
Base class that described an item in a Factory.
Definition: FactoryItem.h:52