GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BlackHole.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 
23 #include "BlackHole.h"
24 
25 #include <iostream>
26 #include <iomanip>
27 #include <fstream>
28 
29 using namespace ADF;
30 
31 BlackHole::BlackHole() : NarvalConsumer(), fConsumedBytes(0UL)
32 {
33  // log system
34  Log.GetProcessName() = "BlackHole";
35  Log.SetPID(GetPID());
36 
37  // frameio related
38  GetFrameIO().SetName("BlackHole");
39  // to be sure unknown frames are written in the ouput
40  GetFrameIO().SetModel(ConfAgent::kSafe);
41 }
42 
44 {
45  // in principle not needed ... just in case reset it has not been called by narval
46  UInt_t error = 0u; process_reset(&error) ;
47 }
48 
49 void BlackHole::process_config (const Char_t *directory_path, UInt_t *error_code)
50 {
51  // first init narval stuff
52  NarvalInterface::process_config(directory_path,error_code);
53 
54  if ( (*error_code) == 0u ) {
55  // now init your stuff if required
56  }
57 }
58 
60 {
61  Log.ClearMessage(); Log.SetProcessMethod("ProcessBlock");
62 
63  // just switch to kRead to tell that the block has been consumed
64  in.SetModeIO(ConfAgent::kRead);
65 // printf(" Black::ProcessBlock %d \n ",in.GetSize());
66  fConsumedBytes += in.GetSize();
67 
68  return 0u;
69 }
70 
71 
72 void BlackHole::process_initialise (UInt_t *error_code)
73 {
74  *error_code = 0;
75  Log.ClearMessage(); Log.SetProcessMethod("process_initialise");
76 
77  Log << dolog;
78 }
79 
80 void BlackHole::process_reset (UInt_t *error_code)
81 {
82  *error_code = 0;
83  Log.ClearMessage(); Log.SetProcessMethod("process_reset");
84 
85  Log << info << fConsumedBytes << " bytes have been consumed " << dolog;
86 }
87 
static void process_config(const Char_t *, UInt_t *)
to init globals (static) from a directory
Definition: BlackHole.cpp:49
virtual Long64_t GetSize(UInt_t=0u) const
size of the current block
Definition: FrameBlock.h:141
UInt_t GetPID() const
To get the ID number for that algorithm.
virtual void process_reset(UInt_t *error_code)
Destructor implementation.
Definition: BlackHole.cpp:80
LogMessage & error(LogMessage &)
virtual UInt_t ProcessBlock(ADF::FrameBlock &)
virtual method to be implemented
Definition: BlackHole.cpp:59
A Block of Frames.
Definition: FrameBlock.h:43
virtual void process_initialise(UInt_t *error_code)
Constructor implementation.
Definition: BlackHole.cpp:72
virtual void SetModeIO(ConfAgent::EMode mode)
Definition: FrameBlock.h:81
void SetModel(ConfAgent::EModel model)
Definition: FrameIO.cpp:93
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
virtual void SetPID(unsigned int pid)
To set the Process ID number.
virtual void SetProcessMethod(const char *)
To set the current method.
It defines the interface needed to be a consumer.
LogMessage & dolog(LogMessage &)
virtual ~BlackHole()
Definition: BlackHole.cpp:43
virtual void ClearMessage()
To clear the current message.
header file for BlackHole.cpp
virtual std::string & GetProcessName()
To get the Process name.
LogMessage Log
to send messages to the log server
virtual void SetName(const char *name)
Definition: FrameIO.h:102