GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Trigger.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_Trigger
24 #define ADF_Trigger
25 #define ADF_TRIGGER_H ADF_Trigger
26 
27 #ifndef ADF_FrameIO
28 #include "FrameIO.h"
29 #endif
30 #ifndef ADF_Frame
31 #include "Frame.h"
32 #endif
33 #include "GenericFrame.h"
34 
35 #include <vector>
36 
37 namespace ADF
38 {
39 
40 class Key;
41 
43 
50 class Trigger
51 {
52 private:
54  static UInt_t gUniqueID;
55 
56 private:
58  UInt_t fUniqueID;
59 
60 protected:
63 
65  Bool_t fIsActive;
67  Bool_t fIsFired;
69  Bool_t fIsZombie;
71  Bool_t fIsUniversal;
72 
74  std::string fName;
75 
76 private:
77  Trigger() :
78  fUniqueID(0u),
79  fLog("Trigger"),
80  fIsActive(true),
81  fIsFired(false),
82  fIsZombie(false),
83  fIsUniversal(false),
84  fName("Base") {;}
85 
86 public:
87  Trigger(const Char_t *name):
88  fUniqueID(0u),
89  fLog("Trigger"),
90  fIsActive(true),
91  fIsFired(false),
92  fIsZombie(false),
93  fIsUniversal(false),
94  fName(name)
95  { fUniqueID = gUniqueID++; }
96  virtual ~Trigger()
97  {;}
98 
99  UInt_t GetUniqueID()
100  { return fUniqueID; }
101 
102  const std::string &GetName() const
103  { return fName; }
104 
106  void Fired(Bool_t b = true)
107  { fIsFired = b; }
108 
110  Bool_t IsFired() const
111  { return fIsFired ; }
112 
114  Bool_t IsZombie() const
115  { return fIsZombie; }
116 
118  void Zombie(Bool_t b = true)
119  { fIsZombie = b; }
120 
122  void Active(Bool_t b = true)
123  { fIsActive = b; }
124 
126  Bool_t IsActive() const
127  { return fIsActive ; }
128 
130  void Universal(Bool_t b = true)
131  { fIsUniversal = b; }
132 
134  Bool_t IsUniversal() const
135  { return fIsUniversal; }
136 
138  virtual Bool_t Check()
139  { return fIsFired = false; }
140 
142  virtual void Reset()
143  { Fired(false); }
144 
145 };
146 
148 
155 class DFTrigger : public Trigger
156 {
157 public:
158  explicit DFTrigger(const Char_t *trig_name) : Trigger(trig_name)
159  {;}
160  virtual ~DFTrigger()
161  {;}
162 
164  virtual UInt_t GetNbInputFrame() const = 0;
165 
167  virtual Bool_t HasEmbedded() const = 0;
168 
170  virtual std::string GetDFOption(UInt_t /*which*/ = 0u) const
171  {
172  std::string r("");
173  return r;
174  }
175 
177 
182  virtual SharedFP *Add(const FactoryItem &key_item, const FactoryItem &frame_item,
183  bool iscons = true, const Char_t *option = "") = 0;
184 
186  virtual SharedFP *AddAutoConf(const FactoryItem &key_item, const FactoryItem &frame_item, UInt_t which) = 0;
187 
189  virtual Frame *GetInputFrame(UInt_t which = 0u) = 0;
191  virtual SharedFP *GetInputSharedFP(UInt_t which = 0u) = 0;
192 
194  virtual const Frame *GetConstInputFrame(UInt_t which = 0u) const = 0;
196  virtual Bool_t IsConsumable(UInt_t which = 0u) const = 0;
197 
199  virtual Bool_t IsIndividualFired(UInt_t which = 0u) const = 0;
200 
201 
203  virtual SharedFP *SetOutputFrame(Frame *frame) = 0;
205  virtual SharedFP *SetOutputFrame(const FactoryItem &key_item, const FactoryItem &frame_item) = 0;
206 
208  virtual Frame *GetOutputFrame() = 0;
209 
211 
218 
220  virtual Bool_t Reconfigure( ConfAgent * ) = 0;
221 };
222 
224 
249 class FrameTrigger : public DFTrigger
250 {
251 private:
253  PtrStack<SharedFP> fInputFrames;
255  std::vector<const Key *> fInputKeyConst;
257  std::vector<Bool_t> fIsConsumable;
259  std::vector<Short_t> fFiredOn;
261  std::vector<Bool_t> fIndividualFired;
263  std::vector<UInt_t> fScanPattern;
264 private:
266  PtrStack<SharedFP> fUtilities;
267 private:
269  PtrStack<SharedFP> fInputConfFrames;
271  std::vector<UShort_t> fMap;
273  std::vector < std::pair<ConfigurationFrame *, UShort_t> > fActiveInputConfFrames;
274 
275 private:
277 
282  Bool_t fIsOwnerOfOutput;
284  SharedFP *fOutputFrame;
285 
286 private:
288  Frame *fEmbeddedOutputFrame;
289 
290 protected:
292  virtual Bool_t CheckConf();
293 
294 protected:
295  virtual void FrameTransfert (Frame *from, Frame *to);
296 
297 public:
298  explicit FrameTrigger(const Char_t *trig_name);
299  virtual ~FrameTrigger();
300 
302  virtual Bool_t IsIndividualFired(UInt_t which = 0u) const
303  {
304  if ( which < fIndividualFired.size() )
305  return fIndividualFired[which];
306  return false;
307  }
309  virtual std::string GetDFOption(UInt_t which = 0u) const
310  {
311  std::string result = "{";
312  if ( which < GetNbInputFrame() ) {
313  switch ( fFiredOn[which] ) {
314  case -1:
315  result += "|";
316  break;
317  case 0:
318  result += "!";
319  break;
320  default:
321  break;
322  }
323  }
324  if ( IsConsumable(which) ) {
325  result += "-";
326  }
327  result += "}";
328 
329  return result;
330  }
331  virtual UInt_t GetNbInputFrame() const
332  { return fInputFrames.GetSize(); }
333 
335  virtual Bool_t HasEmbedded() const
336  { return fInputFrames.GetSize() > 1u ; }
337 
339 
358  virtual SharedFP *Add(const FactoryItem &key_item, const FactoryItem &frame_item,
359  bool iscons = true, const Char_t *option = "");
360 
362  virtual SharedFP *AddUtility(const FactoryItem &key_item, const FactoryItem &frame_item);
363 
365  virtual SharedFP *AddAutoConf(const FactoryItem &key_item, const FactoryItem &frame_item, UInt_t which);
366 
368  virtual Frame *GetInputFrame(UInt_t which = 0u)
369  {
370  if ( which < fInputFrames.GetSize() )
371  return fInputFrames.At(which)->GetFrame();
372  return 0x0;
373  }
375  virtual SharedFP *GetInputSharedFP(UInt_t which = 0u)
376  { return fInputFrames.At(which); }
378  virtual const Frame *GetConstInputFrame(UInt_t which = 0u) const
379  {
380  if ( which < fInputFrames.GetSize() )
381  return fInputFrames.At(which)->GetFrame();
382  return 0x0;
383  }
385  virtual Bool_t IsConsumable(UInt_t which = 0u) const;
387  virtual void SetConsumable(UInt_t which, Bool_t value = true)
388  {
389  if ( which < fIsConsumable.size() )
390  fIsConsumable[which] = value;
391  }
392 
394 
415  virtual Frame *GetSubFrameFrom(UInt_t which_input, UInt_t which_sub, SharedFP *utility, Bool_t do_scan = false);
417  template <typename Data_T>
418  Data_T *GetSubDataFrom(UInt_t which_input, UInt_t which_sub, SharedFP *utility, Bool_t do_scan = false)
419  {
420  return GetDataPointer<Data_T>( GetSubFrameFrom(which_input,which_sub,utility,do_scan) );
421  }
422 
424  virtual SharedFP *SetOutputFrame(Frame *frame);
426  virtual SharedFP *SetOutputFrame(const FactoryItem &key_item, const FactoryItem &frame_item);
427 
430  {
431  return fOutputFrame;
432  }
434  virtual Frame *GetOutputFrame()
435  {
436  if (fOutputFrame == 0x0)
437  return 0x0;
438  return fOutputFrame->GetFrame();
439  }
440 
442 
447 
449 
452  virtual Bool_t Check();
453 
455  virtual Bool_t Reconfigure( ConfAgent * );
456 };
457 
459 
463 {
464 public:
465  explicit AgataFrameTrigger(const Char_t *trig_name):
466  FrameTrigger(trig_name) {;}
468  {;}
469 
471 
490  static AgataFrameTrigger *Build(const Char_t *name, const Char_t *in, const Char_t *out = "", ConfAgent *agent = 0x0);
491 
492  virtual SharedFP *Add(const FactoryItem &key_item, const FactoryItem &frame_item,
493  bool iscons = true, const Char_t *option = "")
494  { return FrameTrigger::Add(key_item,frame_item,iscons,option); }
495 
496  SharedFP *Add(const char *, const Version &, const Version &,
497  bool iscons = true, const Char_t *option = "");
498 
500  SharedFP *Add(const char *, const char *,
501  const ConfAgent *agent = 0x0, bool iscons = true, const Char_t *option = "");
502 
504  virtual SharedFP *AddUtility(const FactoryItem &key_item, const FactoryItem &frame_item, const ConfAgent *agent);
505  virtual SharedFP *AddUtility(const FactoryItem &key_item, const FactoryItem &frame_item)
506  {
507  return FrameTrigger::AddUtility(key_item, frame_item);
508  }
509  // for pure agata frame
510  virtual SharedFP *AddUtility(const char *, const ConfAgent *agent);
511 
512  virtual SharedFP *SetOutputFrame(Frame *frame)
513  { return FrameTrigger::SetOutputFrame(frame); }
514 
516  virtual SharedFP *SetOutputFrame(const FactoryItem &key_item, const FactoryItem &frame_item)
517  { return FrameTrigger::SetOutputFrame(key_item,frame_item); }
518 
519  SharedFP *SetOutputFrame(const char *, const Version &, const Version &);
521  SharedFP *SetOutputFrame(const char *, const char *, const ConfAgent *agent = 0x0);
522 };
523 
524 } // namespace ADF
525 #endif
526 
527 
528 
529 
530 
FrameTrigger(const Char_t *trig_name)
Definition: Trigger.cpp:51
virtual Bool_t HasEmbedded() const =0
true if this is a trigger for embedded frames
virtual SharedFP * SetOutputFrame(Frame *frame)
Once a trigger has fired, the result of the algorithm is set through this.
Definition: Trigger.cpp:448
TBrowser * b
virtual ~FrameTrigger()
Definition: Trigger.cpp:73
Bool_t fIsZombie
true if this is a zombie (EX: objects not properly allocated)
Definition: Trigger.h:69
virtual Frame * GetFrame() const
Definition: Frame.h:625
Bool_t IsUniversal() const
Check if this trigger is in fired state.
Definition: Trigger.h:134
Base class for a Frame.
Definition: Frame.h:73
virtual SharedFP * SetOutputFrame(const FactoryItem &key_item, const FactoryItem &frame_item)
Once a trigger has fired, the result of the algorithm is set through this.
Definition: Trigger.h:516
virtual Frame * GetOutputFrame()=0
to get back the output frame
virtual SharedFP * Add(const FactoryItem &key_item, const FactoryItem &frame_item, bool iscons=true, const Char_t *option="")
Add a frame to the list of required frames.
Definition: Trigger.h:492
virtual SharedFP * AddUtility(const FactoryItem &key_item, const FactoryItem &frame_item)
Add utilities, used to decode/encode composite frames.
Definition: Trigger.h:505
virtual SharedFP * GetInputSharedFP(UInt_t which=0u)=0
to get back the Shared pointer that define this trigger
virtual std::string GetDFOption(UInt_t which=0u) const
get option for the input frame ( consumed: {-} , anti : {!} mandatory {} or not {|} ...
Definition: Trigger.h:309
Bool_t IsActive() const
Check if this trigger is in fired state.
Definition: Trigger.h:126
virtual ~AgataFrameTrigger()
Definition: Trigger.h:467
virtual ~Trigger()
Definition: Trigger.h:96
virtual Bool_t Check()
Check if the currently read key fired this trigger. If yes, IsFired is true.
Definition: Trigger.h:138
virtual Bool_t IsIndividualFired(UInt_t which=0u) const
fine tuning of the trigger current conditions
Definition: Trigger.h:302
UInt_t value[MaxValue]
Definition: ReadDaqAlone.C:29
virtual SharedFP * AddAutoConf(const FactoryItem &key_item, const FactoryItem &frame_item, UInt_t which)=0
Add a configuration frame to the input frame #which.
virtual Bool_t IsConsumable(UInt_t which=0u) const
to know if the frame is consumable or not
Definition: Trigger.cpp:589
void Fired(Bool_t b=true)
Fired (default) or not this trigger.
Definition: Trigger.h:106
virtual SharedFP * SetOutputFrame(Frame *frame)=0
Once a trigger has fired, the result of the algorithm is set through this.
UInt_t GetUniqueID()
Definition: Trigger.h:99
Trigger(const Char_t *name)
Definition: Trigger.h:87
std::string fName
the trigger name
Definition: Trigger.h:74
LogMessage fLog
to send messages to the log server
Definition: Trigger.h:62
static AgataFrameTrigger * Build(const Char_t *name, const Char_t *in, const Char_t *out="", ConfAgent *agent=0x0)
Build a new AgataFrame Trigger.
Definition: Trigger.cpp:839
virtual UInt_t GetNbInputFrame() const =0
number of input frames that define this trigger
virtual ~DFTrigger()
Definition: Trigger.h:160
virtual SharedFP * GetInputSharedFP(UInt_t which=0u)
to get back the Shared pointer that define this trigger
Definition: Trigger.h:375
virtual Frame * GetSubFrameFrom(UInt_t which_input, UInt_t which_sub, SharedFP *utility, Bool_t do_scan=false)
to extract a sub frame from one event frame of the current trigger
Definition: Trigger.cpp:667
virtual void FrameTransfert(Frame *from, Frame *to)
Definition: Trigger.cpp:90
Bool_t fIsActive
true if this is an active trigger
Definition: Trigger.h:65
Base class for a generic frame trigger.
Definition: Trigger.h:249
virtual Frame * GetEmbeddedOutputFrame(ConfAgent::EModel model=ConfAgent::kStrict)=0
Return the true output frame.
header file for Frame.cpp
Base class for version numbers.
Definition: Version.h:38
virtual SharedFP * AddUtility(const FactoryItem &key_item, const FactoryItem &frame_item)
Add utilities, used to decode/encode composite frames.
Definition: Trigger.cpp:652
ConfAgent.
Definition: ConfAgent.h:63
virtual SharedFP * SetOutputFrame(Frame *frame)
Once a trigger has fired, the result of the algorithm is set through this.
Definition: Trigger.h:512
PtrStack.
Definition: PtrStack.h:59
virtual Frame * GetInputFrame(UInt_t which=0u)=0
to get back the frames that define this trigger
void Active(Bool_t b=true)
Active this trigger.
Definition: Trigger.h:122
virtual const Frame * GetConstInputFrame(UInt_t which=0u) const
to get back the frames that define this trigger
Definition: Trigger.h:378
virtual Bool_t Reconfigure(ConfAgent *)
Modify the Frame definitions respecting the new data flow definition and the acceptable Frame changes...
Definition: Trigger.cpp:104
virtual Bool_t Check()
Check the content of the frame if the primary frame is a composite one.
Definition: Trigger.cpp:748
virtual SharedFP * Add(const FactoryItem &key_item, const FactoryItem &frame_item, bool iscons=true, const Char_t *option="")
Add a frame to the list of required frames.
Definition: Trigger.cpp:596
const std::string & GetName() const
Definition: Trigger.h:102
To be used for Agata Data Flow.
Definition: Trigger.h:462
Bool_t fIsFired
true if this has just been fired
Definition: Trigger.h:67
Bool_t IsFired() const
Check if this trigger is in fired state.
Definition: Trigger.h:110
Base class for a Log message.
Definition: ADFLogMessage.h:80
A Shared Frame Pointer.
Definition: Frame.h:597
EModel
Model for FrameIO.
Definition: ConfAgent.h:69
virtual Bool_t HasEmbedded() const
true if this is a trigger for embedded frames
Definition: Trigger.h:335
DFTrigger(const Char_t *trig_name)
Definition: Trigger.h:158
virtual Frame * GetOutputFrame()
to get back the output frame
Definition: Trigger.h:434
Bool_t IsZombie() const
Check if this trigger is in fired state.
Definition: Trigger.h:114
void Zombie(Bool_t b=true)
this trigger
Definition: Trigger.h:118
Base class for a trigger on a data flow.
Definition: Trigger.h:155
header file for FrameIO.cpp
Data_T * GetSubDataFrom(UInt_t which_input, UInt_t which_sub, SharedFP *utility, Bool_t do_scan=false)
Same as GetSubFrameFrom but to get directly a data part.
Definition: Trigger.h:418
AgataFrameTrigger(const Char_t *trig_name)
Definition: Trigger.h:465
virtual std::string GetDFOption(UInt_t=0u) const
data flow option for that particular input
Definition: Trigger.h:170
virtual UInt_t GetNbInputFrame() const
number of input frames that define this trigger
Definition: Trigger.h:331
virtual SharedFP * AddAutoConf(const FactoryItem &key_item, const FactoryItem &frame_item, UInt_t which)
Add a configuration frame to the input frame #which.
Definition: Trigger.cpp:690
virtual Frame * GetEmbeddedOutputFrame(ConfAgent::EModel model=ConfAgent::kStrict)
In case the output frame should be embedded.
Definition: Trigger.cpp:486
virtual SharedFP * AddUtility(const FactoryItem &key_item, const FactoryItem &frame_item, const ConfAgent *agent)
Add utilities, used to decode/encode composite frames.
Definition: Trigger.cpp:936
virtual Bool_t IsConsumable(UInt_t which=0u) const =0
to know if the frame is consumable or not
virtual Bool_t Reconfigure(ConfAgent *)=0
Modify the Frame definitions respecting the new data flow definition and the acceptable Frame changes...
virtual SharedFP * Add(const FactoryItem &key_item, const FactoryItem &frame_item, bool iscons=true, const Char_t *option="")=0
Add a frame to the Embedded list of required frames.
void Universal(Bool_t b=true)
Set this trigger as universal or not.
Definition: Trigger.h:130
virtual Frame * GetInputFrame(UInt_t which=0u)
to get back the frames that define this trigger
Definition: Trigger.h:368
virtual Bool_t CheckConf()
Check if the currently read key fired this trigger. If yes, IsFired is true.
Definition: Trigger.cpp:718
virtual SharedFP * GetOutputSharedFP()
to get back the output frame
Definition: Trigger.h:429
virtual Bool_t IsIndividualFired(UInt_t which=0u) const =0
fine tuning of the trigger current conditions
Bool_t fIsUniversal
true if this is an universal trigger (means suitable for any dataflow)
Definition: Trigger.h:71
General trigger.
Definition: Trigger.h:50
virtual void Reset()
Check if this trigger is in fired state.
Definition: Trigger.h:142
virtual void SetConsumable(UInt_t which, Bool_t value=true)
to change the consumable flag.
Definition: Trigger.h:387
Base class that described an item in a Factory.
Definition: FactoryItem.h:52
virtual const Frame * GetConstInputFrame(UInt_t which=0u) const =0
to get back the frames that define this trigger