GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FrameIO.h
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 
23 #ifndef ADF_FrameIO
24 #define ADF_FrameIO
25 #define ADF_FRAMEIO_H ADF_FrameIO
26 
27 #ifndef ADF_FrameBlock
28 #include "FrameBlock.h"
29 #endif
30 #ifndef ADF_ConfAgent
31 #include "ConfAgent.h"
32 #endif
33 #ifndef ADF_PtrStack
34 #include "PtrStack.h"
35 #endif
36 #ifndef ADF_Counter
37 #include "Counter.h"
38 #endif
39 
40 #include <iostream>
41 #include <vector>
42 
43 namespace ADF
44 {
45 
46 class Frame;
47 class DFTrigger;
48 
50 
71 {
72 public:
74  enum EStatus
75  { kUndefined = 0, kRunning = 1, kStopped = 2, kSuspended = 3, kIdle = 4, kFinished = 5 };
76 
77 private:
79  std::string fName;
81  EStatus fStatus;
82 
83 private:
85  ConfAgent *fConfAgent;
86 
87 protected:
90 
91 public:
92  BaseFrameIO(const char *);
93  virtual ~BaseFrameIO();
94 
96  virtual const char *GetStringStatus(EStatus) const;
97 
99  virtual const std::string &GetName() const
100  { return fName; }
101 
102  virtual void SetName(const char *name)
103  { fName = name; }
104 
105  virtual const Char_t *GetType() const
106  { return "BaseFrameIO"; }
107 
108  void SetModel(ConfAgent::EModel model) ;
109 
110  void SetStatus(EStatus stat)
111  { fStatus = stat; }
112 
114 
117  { if ( fConfAgent == 0x0 ) ConfAgent::theGlobalAgent(); return fConfAgent; }
118 
120 
122  ConfAgent::EModel GetModel() const ;
124 
127  { return fStatus ; }
128 
130 
132  virtual void Print(std::ostream &out = std::cout) const;
133 };
134 
135 
137 
140 class FrameIO : public BaseFrameIO
141 {
142 private:
144  FrameBlock *fDefaultInFB;
145  FrameBlock *fDefaultOuFB;
146 
148  FrameBlock *fInFB;
149  FrameBlock *fOuFB;
150 
152  Key *fKeyIn;
154  DFTrigger *fConfIO;
156  PtrStack<DFTrigger> fRegisteredTriggers;
158  PtrStack<DFTrigger> fRunningTriggers;
160  PtrStack<DFTrigger> fWriteOnlyTriggers;
162  PtrStack<DFTrigger> fZombieTriggers;
163 
166  Counter fGlobalCounter;
168  Counter fNoTrigCounterIN;
169  Counter fNoTrigCounterOUT;
171  std::vector<Counter> fTrigCountersIN;
172  std::vector<Counter> fTrigCountersOUT;
173 
175  UInt_t fRead, fWritten, fTriggerRate;
176 
178  Bool_t fDoRewind;
179 
180 protected:
181  Bool_t InitFromAgent();
182 
183 protected:
185 
188  virtual Bool_t NextFrame();
189 
190  Bool_t DoGlobalReconfiguration();
191 // void DoFrameReconfiguration();
192  // void DoNotATrigger();
193 
195  virtual Bool_t Check(DFTrigger *, PtrStack<DFTrigger> &, PtrStack<DFTrigger> &);
196 
197 public:
198  FrameIO(const char *);
199  virtual ~FrameIO() ;
200 
202  Bool_t DoRewind(Bool_t rewind = true)
203  {
204  Bool_t old =
205  fDoRewind;
206  fDoRewind = rewind;
207 
208  return old;
209  }
210 
213  { return fConfIO; }
214 
216 
219  virtual Bool_t RecordGlobalConfiguration(const std::string = "NO");
220 
222  { return fInFB; }
224  { return fOuFB; }
225  UInt_t GetFramesRead() const
226  { return fRead; }
227  UInt_t GetFramesWritten() const
228  { return fWritten; }
229 
231  virtual const Char_t *GetType() const
232  { return "FrameIO"; }
233 
235 
238  virtual Bool_t Register(DFTrigger *);
239 
241  virtual DFTrigger *GetTrigger(const Char_t *);
242 
244 // virtual UInt_t NumberOfTriggers() const
245 // { return fRegisteredTriggers.GetSize() ; }
246 
248 
272  virtual Bool_t Notify(Bool_t with_inner_trigger = false);
273 
275 
279  virtual Bool_t Record(DFTrigger *);
280  virtual Bool_t Record();
281 
283 
285  virtual void Print(std::ostream &out = std::cout) const;
286 
288  virtual void Attach(FrameBlock *in, FrameBlock *out);
289  virtual void Detach(FrameBlock *in, FrameBlock *out);
290 };
291 
292 } // namespace ADF
293 #endif
294 
295 
296 
297 
298 
virtual Bool_t Check(DFTrigger *, PtrStack< DFTrigger > &, PtrStack< DFTrigger > &)
check if a trigger is suitable for the dataflow
Definition: FrameIO.cpp:224
EStatus GetStatus() const
Definition: FrameIO.h:126
Base class for a Key.
Definition: Key.h:56
header file for FrameBlock.cpp
virtual const Char_t * GetType() const
What kind of data flow is it ?
Definition: FrameIO.h:231
Bool_t DoGlobalReconfiguration()
Definition: FrameIO.cpp:286
Bool_t DoRewind(Bool_t rewind=true)
if set true, rewind is done once a block is attached. Return the previous value
Definition: FrameIO.h:202
Bool_t InitFromAgent()
Definition: FrameIO.cpp:153
virtual Bool_t Notify(Bool_t with_inner_trigger=false)
To know the number of registered triggers.
Definition: FrameIO.cpp:447
EStatus
current state of the FrameIO
Definition: FrameIO.h:74
virtual void Print(std::ostream &out=std::cout) const
Print some informations (statistics)
Definition: FrameIO.cpp:103
A Block of Frames.
Definition: FrameBlock.h:43
A Counter.
Definition: Counter.h:42
ConfAgent::EModel GetModel() const
Definition: FrameIO.cpp:98
UInt_t GetFramesRead() const
Definition: FrameIO.h:225
void SetModel(ConfAgent::EModel model)
Definition: FrameIO.cpp:93
static ConfAgent * theGlobalAgent(std::string="Agata")
to get the global agent
Definition: ConfAgent.cpp:402
One stream as an input and one in output.
Definition: FrameIO.h:140
header file for Counter.cpp
virtual Bool_t Register(DFTrigger *)
To register a trigger.
Definition: FrameIO.cpp:368
virtual const DFTrigger * GetGlobalConfigurationTrigger()
to check whether or not a global reconfiguration has occured
Definition: FrameIO.h:212
BaseFrameIO(const char *)
Definition: FrameIO.cpp:47
virtual const std::string & GetName() const
Name of this FrameIO.
Definition: FrameIO.h:99
Base class to get/write Frames.
Definition: FrameIO.h:70
virtual const Char_t * GetType() const
Definition: FrameIO.h:105
ConfAgent.
Definition: ConfAgent.h:63
virtual void Detach(FrameBlock *in, FrameBlock *out)
Definition: FrameIO.cpp:741
template header file
void SetStatus(EStatus stat)
Definition: FrameIO.h:110
PtrStack.
Definition: PtrStack.h:59
virtual ~FrameIO()
Definition: FrameIO.cpp:202
virtual Bool_t NextFrame()
to know if there is a next frame of the dataflow
Definition: FrameIO.cpp:359
FrameIO(const char *)
Definition: FrameIO.cpp:110
Base class for a Log message.
Definition: ADFLogMessage.h:80
EModel
Model for FrameIO.
Definition: ConfAgent.h:69
const FrameBlock * GetCurrentBlockIN() const
Definition: FrameIO.h:221
const FrameBlock * GetCurrentBlockOUT() const
Definition: FrameIO.h:223
Base class for a trigger on a data flow.
Definition: Trigger.h:155
header file for ConfAgent.cpp
virtual Bool_t Record()
Definition: FrameIO.cpp:704
virtual void Print(std::ostream &out=std::cout) const
Print some informations (statistics)
Definition: FrameIO.cpp:571
UInt_t GetFramesWritten() const
Definition: FrameIO.h:227
LogMessage Log
to send messages to the log server
Definition: FrameIO.h:89
virtual void Attach(FrameBlock *in, FrameBlock *out)
Attach a block to this. Rewind called if DoRewind set to true (Default)
Definition: FrameIO.cpp:724
virtual ~BaseFrameIO()
Definition: FrameIO.cpp:60
virtual Bool_t RecordGlobalConfiguration(const std::string="NO")
write the current configuration in the output data
Definition: FrameIO.cpp:247
virtual DFTrigger * GetTrigger(const Char_t *)
To retrieve a trigger by its unique name.
Definition: FrameIO.cpp:433
ConfAgent * GetConfAgent() const
Return the agent which keeps the current configuration for that FrameIO.
Definition: FrameIO.h:116
virtual void SetName(const char *name)
Definition: FrameIO.h:102
virtual const char * GetStringStatus(EStatus) const
string corresponding to the current status
Definition: FrameIO.cpp:67