GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NarvalInterface.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_NarvalInterface
24 #define ADF_NarvalInterface
25 #define ADF_NARVALINTERFACE_H ADF_NarvalInterface
26 
27 #include "FrameIO.h"
28 
29 namespace ADF
30 {
32 
47  {
48  private:
51  UInt_t fProcessID;
52 
53  protected:
54  virtual ConfAgent *GetConfAgent() const ;
55 
56  private:
58  std::string fConfPath;
59 
60  protected:
63 
66 
67  private:
69  struct G {
71  static std::string ConfPath;
73  static UInt_t ProcessID;
74  };
75 
76  public:
77  NarvalInterface() ;
78  virtual ~NarvalInterface() ;
79 
81  UInt_t GetPID() const
82  { return fProcessID; }
83 
85  static Int_t GetGlobalParameter(const char *name, UShort_t &val);
86  static Int_t GetGlobalParameter(const char *name, Int_t &val);
87  static Int_t GetGlobalParameter(const char *name, std::string &val);
88 
89  static Int_t SetGlobalParameter(const char *name, const UShort_t &);
90  static Int_t SetGlobalParameter(const char *name, const std::string &);
91 
93  static std::string GetGlobalConfPath()
94  { return G::ConfPath; }
95 
97  const std::string &GetConfPath()
98  { return fConfPath; }
99 
101  virtual Int_t GetMaxInput() const
102  { return 0; }
104  virtual Int_t GetMaxOutput() const
105  { return 0; }
107  virtual Int_t GetNbInput() const
108  {
109  return 0;
110  }
112  virtual Int_t GetNbOutput() const
113  {
114  return 0;
115  }
117 
122  virtual Int_t AttachInput(FrameBlock * /*block*/, Int_t /*slot*/ = -1)
123  {
124  return -1;
125  }
127 
132  virtual Int_t AttachOutput(FrameBlock * /*block*/, Int_t /*slot*/ = -1)
133  {
134  return -1;
135  }
137 
144  virtual UInt_t ProcessBlocks()
145  {
146  return 1u;
147  }
148 
150 
172  static void process_config(const Char_t * /*path*/, UInt_t * /*error_code*/, Short_t do_adf_conf = 0);
173 
175 
182  virtual void process_initialise (UInt_t *error_code) = 0;
183 
185 
189  virtual void process_reset (UInt_t *error_code) = 0;
190 
192 
194  virtual void process_stop (UInt_t *error_code)
195  { *error_code = 0u;
196  std::cout << "NarvalInterface::process_stop called" << std::endl;
197  }
199 
201  virtual void process_start (UInt_t *error_code)
202  { *error_code = 0u;}
204 
206  virtual void process_pause (UInt_t *error_code)
207  { *error_code = 0u;}
209 
211  virtual void process_resume (UInt_t *error_code)
212  { *error_code = 0u;}
213  };
214 
216 
219  {
220  private:
222  FrameBlock *fAttachedInputBlock;
223  private:
225  OneBlock fOneBlockIn;
226 
227  protected:
230 
231  protected:
232  virtual ConfAgent *GetConfAgent() const
233  { return fFrameIO.GetConfAgent(); }
234 
235  public:
236  NarvalConsumer();
237  virtual ~NarvalConsumer() ;
238 
240  { return fFrameIO; }
241 
243  virtual Int_t GetMaxInput() const
244  { return 1; }
245 
247 
252  virtual Int_t AttachInput(FrameBlock *block, Int_t slot = -1)
253  {
254  if ( slot < 1 ) {
255  fAttachedInputBlock = block;
256  return 0;
257  }
258  return -1;
259  }
261  virtual Int_t GetNbInput() const
262  {
263  if ( fAttachedInputBlock ) {
264  return 1;
265  }
266  return 0;
267  }
269  virtual UInt_t ProcessBlocks();
270 
272  virtual UInt_t ProcessBlock (FrameBlock &) = 0;
273 
275 
277  static void process_config (const Char_t*, UInt_t *);
278 
280 
282  virtual void process_block (void *input_buffer,
283  UInt_t size_of_input_buffer,
284  UInt_t *error_code);
285  };
286 
287 
289 
293  {
294  protected:
295  virtual Bool_t SetNbInput(Int_t /*size*/)
296  {
297  return false;
298  }
299  virtual Bool_t SetNbOutput(Int_t /* size */)
300  {
301  return false;
302  }
303 
304  public:
305  NarvalShunter();
306  virtual ~NarvalShunter() ;
307 
308  static void process_config (const Char_t *algo_path, UInt_t *error_code)
309  {
310  NarvalInterface::process_config(algo_path,error_code);
311  }
312 
313  virtual Int_t GetNbInput() const
314  {
315  return 0;
316  }
317  virtual Int_t GetNbOutput() const
318  {
319  return 0;
320  }
321 
323 
330  virtual UInt_t ProcessBlocks() = 0 ;
331  };
332 
334 
337  {
338  private:
339  FrameBlock *fAttachedInputBlock;
340  FrameBlock *fAttachedOutputBlock;
341  private:
343  OneBlock fOneBlockIn;
344  OneBlock fOneBlockOut;
345 
346  protected:
349 
350  protected:
351  virtual ConfAgent *GetConfAgent() const
352  { return fFrameIO.GetConfAgent(); }
353 
354  public:
355  NarvalFilter();
356  virtual ~NarvalFilter() ;
357 
359  { return fFrameIO; }
360 
362  virtual Int_t GetMaxInput() const
363  { return 1; }
364 
366  virtual Int_t GetMaxOutput() const
367  { return 1; }
368 
370 
375  virtual Int_t AttachInput(FrameBlock *block, Int_t slot = -1)
376  {
377  if ( slot < 1 ) {
378  fAttachedInputBlock = block;
379  return 0;
380  }
381  return -1;
382  }
384  virtual Int_t GetNbInput() const
385  {
386  if ( fAttachedInputBlock ) {
387  return 1;
388  }
389  return 0;
390  }
392 
397  virtual Int_t AttachOutput(FrameBlock *block, Int_t slot = -1)
398  {
399  if ( slot < 1 ) {
400  fAttachedOutputBlock = block;
401  return 0;
402  }
403  return -1;
404  }
406  virtual Int_t GetNbOutput() const
407  {
408  if ( fAttachedOutputBlock ) {
409  return 1;
410  }
411  return 0;
412  }
414  virtual UInt_t ProcessBlocks();
415 
417  virtual UInt_t ProcessBlock (FrameBlock &, FrameBlock &) = 0;
418 
420 
423  static void process_config (const Char_t*, UInt_t *);
424 
425  virtual void process_reset (UInt_t *error_code);
426 
428 
431  virtual void process_block (void *input_buffer,
432  UInt_t size_of_input_buffer,
433  void *output_buffer,
434  UInt_t size_of_output_buffer,
435  UInt_t *used_size_of_output_buffer,
436  UInt_t *error_code);
437  };
438 
440 
443  {
444  private:
445  FrameBlock *fAttachedOutputBlock;
446  private:
448  OneBlock fOneBlockOut;
449  protected:
452 
453  protected:
454  virtual ConfAgent *GetConfAgent() const
455  { return fFrameIO.GetConfAgent(); }
456  public:
457  NarvalProducer() ;
458  virtual ~NarvalProducer() ;
459 
461  { return fFrameIO; }
462 
464  virtual Int_t GetMaxOutput() const
465  { return 1; }
466 
468 
473  virtual Int_t AttachOutput(FrameBlock *block, Int_t slot = -1)
474  {
475  if ( slot < 1 ) {
476  fAttachedOutputBlock = block;
477  return 0;
478  }
479  return -1;
480  }
482  virtual Int_t GetNbOutput() const
483  {
484  if ( fAttachedOutputBlock ) {
485  return 1;
486  }
487  return 0;
488  }
490  virtual UInt_t ProcessBlocks();
491 
493  virtual UInt_t ProcessBlock (FrameBlock &) = 0;
494 
496 
498  static void process_config (const Char_t*, UInt_t *);
499 
501 
504  virtual void process_block ( void *output_buffer,
505  UInt_t size_of_output_buffer,
506  UInt_t *used_size_of_output_buffer,
507  UInt_t *error_code);
508  };
509 
510 } // namespace ADF
511 
512 /*
513  // c interface for Narval. Only Register and process_config are not there.
514  // They should be in the BaseClass for a given type of algi (see TrackingFilter)
515 
516  // Filter specific
517  void process_block (ADF::NarvalFilter *algo_data,
518  void *input_buffer,
519  UInt_t size_of_input_buffer,
520  void *output_buffer,
521  UInt_t size_of_output_buffer,
522  UInt_t *used_size_of_output_buffer,
523  UInt_t *error_code)
524  {
525  algo_data->process_block (input_buffer, size_of_input_buffer,
526  output_buffer, size_of_output_buffer,
527  used_size_of_output_buffer, error_code);
528  }
529  // Consumer specific
530  void process_block (ADF::NarvalConsumer *algo_data,void *input_buffer, UInt_t size_of_input_buffer, UInt_t *error_code)
531  {
532  algo_data->process_block (input_buffer, size_of_input_buffer,error_code);
533  }
534  // Producer specific
535  void process_block (ADF::NarvalProducer *algo_data, void *output_buffer,
536  UInt_t size_of_output_buffer,
537  UInt_t *used_size_of_output_buffer,
538  UInt_t *error_code)
539  {
540  algo_data->process_block
541  (output_buffer,size_of_output_buffer,used_size_of_output_buffer,error_code);
542  }
543  // any kind of algo
544  void process_initialise (ADF::NarvalInterface *algo_data, UInt_t *error_code)
545  {
546  algo_data->process_initialise (error_code);
547  }
548  void process_reset (ADF::NarvalInterface * *algo_data,UInt_t *error_code)
549  {
550  algo_data->process_reset (error_code);
551  }
552  void process_start (ADF::NarvalInterface * *algo_data, UInt_t *error_code)
553  {
554  algo_data->process_start (error_code);
555  }
556  void process_stop (ADF::NarvalInterface * *algo_data,UInt_t *error_code)
557  {
558  algo_data->process_stop (error_code);
559  }
560  void process_pause (ADF::NarvalInterface * *algo_data,UInt_t *error_code)
561  {
562  algo_data->process_pause (error_code);
563  }
564  void process_resume (ADF::NarvalInterface * *algo_data, UInt_t *error_code)
565  {
566  algo_data->process_resume (error_code);
567  }
568 
569  */
570 #endif
571 
572 
virtual Int_t GetNbInput() const
for this actor, it gives the current number of entry lines attached.
virtual Int_t GetNbOutput() const
for this actor, it gives the current number of output lines attached.
virtual Int_t GetNbInput() const
for this actor, it gives the current number of entry lines attached.
virtual void process_reset(UInt_t *error_code)
To reset the internal values (real destructor)
UInt_t GetPID() const
To get the ID number for that algorithm.
virtual Int_t GetNbOutput() const
for this actor, it gives the current number of entry lines attached.
static std::string GetGlobalConfPath()
global conf path keep since passed in static method and needed in init method
virtual ConfAgent * GetConfAgent() const
It defines the interface needed to be a narval actor (producer).
static void process_config(const Char_t *, UInt_t *, Short_t do_adf_conf=0)
Have to be overwritten and called in your implementation.
virtual void process_resume(UInt_t *error_code)
this method is called every time the system resumes data acquisition
static void process_config(const Char_t *, UInt_t *)
Have to be overwritten and called in your implementation.
virtual UInt_t ProcessBlocks()
process blocks attached by AttachInput/AttachOutput. No need to overwrite it if ProcessBlock(FrameBlo...
A Block of Frames.
Definition: FrameBlock.h:43
virtual void process_stop(UInt_t *error_code)
This method is called every time the daq stops.
virtual Int_t GetMaxInput() const
for this actor, it gives the max number of entry lines it can handle : one for a consumer ...
virtual Int_t GetNbOutput() const
for this actor, it gives the current number of output lines attached.
virtual void process_block(void *input_buffer, UInt_t size_of_input_buffer, UInt_t *error_code)
Narval interface, Ask the algorithm to process the input data block.
static void process_config(const Char_t *, UInt_t *)
Narval interface.
virtual UInt_t ProcessBlocks()=0
generic ProcessBlocks method for any kind of actor. Intput/Output should be attached using the Attach...
virtual Int_t GetNbOutput() const
for this actor, it gives the current number of entry lines attached.
virtual void process_start(UInt_t *error_code)
This method is called every time the daq starts.
FrameIO fFrameIO
Frame IO.
static void process_config(const Char_t *algo_path, UInt_t *error_code)
virtual UInt_t ProcessBlocks()
process blocks attached by AttachInput/AttachOutput. No need to overwrite it if ProcessBlock(FrameBlo...
virtual void process_block(void *input_buffer, UInt_t size_of_input_buffer, void *output_buffer, UInt_t size_of_output_buffer, UInt_t *used_size_of_output_buffer, UInt_t *error_code)
Ask the algorithm to process the data block.
virtual void process_reset(UInt_t *error_code)=0
To reset the internal values (real destructor)
One stream as an input and one in output.
Definition: FrameIO.h:140
virtual Int_t GetNbInput() const
for this actor, it gives the current number of entry lines attached.
virtual UInt_t ProcessBlocks()
process blocks attached by AttachInput/AttachOutput. No need to overwrite it if ProcessBlock(FrameBlo...
virtual Int_t GetMaxInput() const
for this actor, it gives the max number of entry lines it can handle ==> Only one for a filter ...
static Int_t GetGlobalParameter(const char *name, UShort_t &val)
to get from narval a parameter () ... IS IT mandatory to have there a static method ...
virtual Int_t AttachOutput(FrameBlock *block, Int_t slot=-1)
Attach a block as output for a given slot number.
const std::string & GetConfPath()
To get the algo path associated with the current actor.
Base class for version numbers.
Definition: Version.h:38
ConfAgent.
Definition: ConfAgent.h:63
static Int_t SetGlobalParameter(const char *name, const UShort_t &)
virtual Int_t GetNbInput() const
for this actor, it gives the current number of entry lines attached.
virtual UInt_t ProcessBlocks()
generic ProcessBlocks method for any kind of actor. Intput/Output should be attached using the Attach...
static void process_config(const Char_t *, UInt_t *)
Have to be overwritten and called in your implementation.
It defines the interface needed to be a consumer.
FrameIO fFrameIO
Frame IO ... should be private ...
virtual Int_t AttachInput(FrameBlock *block, Int_t slot=-1)
Attach a block as input for a given slot number.
FrameIO & GetFrameIO()
virtual Int_t AttachOutput(FrameBlock *block, Int_t slot=-1)
Attach a block as output for a given slot number.
virtual Int_t AttachInput(FrameBlock *block, Int_t slot=-1)
Attach a block as input for a given slot number.
Base class for a Log message.
Definition: ADFLogMessage.h:80
virtual Int_t GetMaxInput() const
for this actor, it gives the max number of entry lines it can handle (max included).
virtual UInt_t ProcessBlock(FrameBlock &)=0
virtual method to be implemented
virtual ConfAgent * GetConfAgent() const
header file for FrameIO.cpp
ADF::LogMessage & endl(ADF::LogMessage &log)
virtual Int_t GetMaxOutput() const
for this actor, it gives the max number of output lines it can handle ==> Only one for a producer ...
Version fVersion
Algo version (used to check determine suitable frame version ?)
virtual Bool_t SetNbInput(Int_t)
virtual void process_initialise(UInt_t *error_code)=0
To init the internal values (real constructor)
virtual Int_t GetMaxOutput() const
for this actor, it gives the max number of output lines it can handle ==> Only one for a filter ...
Base class for an actor with N input and M output : main purpose is to structure the dataflow...
ConfAgent * GetConfAgent() const
Return the agent which keeps the current configuration for that FrameIO.
Definition: FrameIO.h:116
virtual UInt_t ProcessBlock(FrameBlock &)=0
process one block, virtual method to be implemented
virtual ConfAgent * GetConfAgent() const
virtual UInt_t ProcessBlock(FrameBlock &, FrameBlock &)=0
virtual method to be implemented
LogMessage Log
to send messages to the log server
It defines the general interface needed to be a narval actor.
FrameIO fFrameIO
Frame IO.
It implements an in-memory block of Frames.
Definition: FrameBlock.h:206
virtual Int_t AttachOutput(FrameBlock *, Int_t=-1)
Attach a block as output for a given slot number.
virtual ConfAgent * GetConfAgent() const
virtual void process_block(void *output_buffer, UInt_t size_of_output_buffer, UInt_t *used_size_of_output_buffer, UInt_t *error_code)
Ask the algorithm to process the data block.
virtual Int_t AttachInput(FrameBlock *, Int_t=-1)
Attach a block as input for a given slot number.
It defines the interface needed to be a narval actor (Filter).
virtual void process_pause(UInt_t *error_code)
This method is called every time the system pauses data acquisition.
virtual Bool_t SetNbOutput(Int_t)
virtual Int_t GetMaxOutput() const
for this actor, it gives the max number of output lines it can handle (max included).