GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DEmulator.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2006 by Olivier Stezowski & Christian Finck *
3  * stezow(AT)ipnl.in2p3.fr, cfinck(AT)ires.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 Gw_DEmulator
24 #define Gw_DEmulator
25 
26 #include <vector>
27 #include <string>
28 #include <sstream>
29 
30 #include "BaseEmulator.h"
31 
32 namespace Gw
33 {
34 
36 
39 {
40 protected:
47 
48 public:
49  DActorConnection(ALoadedActor *producer, ALoadedActor *consumer, Int_t size, const Char_t *type = "") : AnActorConnection(), fProducer(producer), fConsumer(consumer), fBlock(0x0)
50  {
51  std::string opt = type;
52  //
53  if ( opt == "expand" ) {
54  fBlock = new ExpandableBlock(size);
55  }
56  if ( fBlock == 0x0 ) {
57  fBlock = new OneBlock(size);
58  }
59  // set name using producer, consumer name and size of the buffer
60 
61  GetName();
62  }
64  {
65  if ( fBlock )
66  delete fBlock ;
67  }
70  {
71  return fProducer ;
72  }
75  {
76  return fConsumer ;
77  }
78 
80  virtual Bool_t IsReadyforConsumer() ;
82  virtual Bool_t SetReadyforConsumer();
83 
85  virtual Bool_t IsReadyforProducer() ;
86 
88  virtual Bool_t SetReadyforProducer();
89 
91 
94  virtual std::string GetName() const
95  {
96  std::stringstream
97  name_link;
98  name_link << "[" << fProducer->GetName() << "]-" << fBlock->GetMaxSize() << "-[" << fConsumer->GetName() << "]";
99 
100  return name_link.str();
101  }
102 
103  virtual FrameBlock *GetBlock(const Char_t /* opt */)
104  {
105  return fBlock;
106  }
107 
108 };
109 
111 
113 class DLActor : public ALoadedActor
114 {
115 public:
116  DLActor(const Char_t *name) : ALoadedActor(name)
117  {;}
118  virtual ~DLActor()
119  {;}
120 };
121 
123 
125 class DEmulator : public BaseEmulator
126 {
127 protected:
129  virtual void LinkActors(ALoadedActor *left, ALoadedActor *middle, ALoadedActor *right);
130 
131 public:
132  DEmulator(std::string name = "DEmulator") : BaseEmulator(name)
133  {;}
134  virtual ~DEmulator()
135  {;}
136 
137  template <class T_actor>
138  DLActor *Add(const Char_t *name_left, const Char_t *name_new_actor, const Char_t *name_right = "-", const Char_t *conf_dir = "./")
139  {
140  return BaseEmulator::AddLoader<DLActor,T_actor>(name_left,name_new_actor,name_right,conf_dir,T_actor::process_config);
141  }
142  template <class T_actor, class T_Configurator>
143  DLActor *Add(const Char_t *name_left, const Char_t *name_new_actor, const Char_t *name_right = "-", const Char_t *conf_dir = "./")
144  {
145  return BaseEmulator::AddLoader<DLActor,T_actor>(name_left,name_new_actor,name_right,conf_dir,T_Configurator::process_config);
146  }
148  // virtual Bool_t Init();
150  // virtual Bool_t Run(UInt_t max_loop);
151 };
152 
153 } // end namespace
154 
155 
156 #endif
157 
virtual Bool_t SetReadyforProducer()
Prepare the connection so that data can be produced by the left actor : return false if someting wron...
Definition: DEmulator.cpp:55
DLActor * Add(const Char_t *name_left, const Char_t *name_new_actor, const Char_t *name_right="-", const Char_t *conf_dir="./")
Definition: DEmulator.h:143
header file for BaseEmulator.cpp
FrameBlock * fBlock
Block use to exchange data between the producer and the consumer.
Definition: DEmulator.h:46
DEmulator(std::string name="DEmulator")
Definition: DEmulator.h:132
virtual Long64_t GetMaxSize(UInt_t=0u) const
max size of the block
Definition: FrameBlock.h:144
It implements an expandable block of Frame.
Definition: FrameBlock.h:351
A Block of Frames.
Definition: FrameBlock.h:43
virtual ~DEmulator()
Definition: DEmulator.h:134
DLActor * Add(const Char_t *name_left, const Char_t *name_new_actor, const Char_t *name_right="-", const Char_t *conf_dir="./")
Definition: DEmulator.h:138
An general emulator, could run or not in multi-threading environement.
Definition: DEmulator.h:125
Default connection between actors : to be used in non-multi threaded programs.
Definition: DEmulator.h:38
virtual ALoadedActor * GetProducer()
to get back the producer
Definition: DEmulator.h:69
virtual FrameBlock * GetBlock(const Char_t)
return the address of the block - opt = p => producer, c => consumer (different in case the connectio...
Definition: DEmulator.h:103
ALoadedActor * fConsumer
right actor ==> Consumer
Definition: DEmulator.h:44
virtual std::string GetName() const
name of the connection, based on actors's names and size of the block
Definition: DEmulator.h:94
Default loader : to be used in non-multi threaded programs.
Definition: DEmulator.h:113
An actor looded in an emulator.
Definition: ALoadedActor.h:88
virtual ALoadedActor * GetConsumer()
to get back the consumer
Definition: DEmulator.h:74
virtual Bool_t IsReadyforConsumer()
test if some data are ready to be sent to the consumer (right part of the connection) ...
Definition: DEmulator.cpp:7
virtual void LinkActors(ALoadedActor *left, ALoadedActor *middle, ALoadedActor *right)
link left and right ... depends on the emulator's implementation
Definition: DEmulator.cpp:75
virtual ~DActorConnection()
Definition: DEmulator.h:63
Base class for an emulator.
Definition: BaseEmulator.h:61
virtual Bool_t IsReadyforProducer()
test if some data can be collected be the producer (left part of the connection)
Definition: DEmulator.cpp:40
ALoadedActor * fProducer
left actor ==> Producer
Definition: DEmulator.h:42
const Int_t size
Definition: BenchIO.C:24
const std::string & GetName() const
get loaded actor's name
Definition: ALoadedActor.h:213
DLActor(const Char_t *name)
Definition: DEmulator.h:116
DActorConnection(ALoadedActor *producer, ALoadedActor *consumer, Int_t size, const Char_t *type="")
Definition: DEmulator.h:49
It implements an in-memory block of Frames.
Definition: FrameBlock.h:206
Base class that connects two actors in a general topology.
virtual Bool_t SetReadyforConsumer()
Prepare the connection so that data can be consumed by the right actor: return false if someting wron...
Definition: DEmulator.cpp:21
virtual ~DLActor()
Definition: DEmulator.h:118