GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DEmulator.cpp
Go to the documentation of this file.
1 
2 #include "DEmulator.h"
3 #include <stdexcept>
4 
5 using namespace Gw;
6 
8 {
9  // this connection is already owned by the consumer actor, so return true only if the block has not been fully consumed
10  if ( fBlock->IsOwner(fConsumer->GetActor()) ) {
11  if ( fBlock->IsEoB() )
12  return false;
13  else
14  return true;
15  }
16  if ( fBlock->IsOwner(0x0) && fBlock->GetSize() > 0 )
17  return true;
18 
19  return false;
20 }
22 {
23  // connection already owned by the consumer
24  if ( fBlock->IsOwner(fConsumer->GetActor()) ) {
25  if ( fBlock->IsEoB() ) {
26  fBlock->SetOwner(0x0);
27  return false;
28  }
29  else
30  return true;
31  }
32 
33  // new block coming from the producer part, so set consumer has owner and rewinf to be ready for reading
35  // rewind for READING
36  fBlock->Rewind(ConfAgent::kRead);
37 
38  return true;
39 }
41 {
42  // this connection is already owned by the producer actor, so return true only if the block has not been fully filled
43  if ( fBlock->IsOwner(fProducer->GetActor()) ) {
44  if ( fBlock->IsEoB() )
45  return false;
46  else
47  return true;
48  }
49 
50  if ( fBlock->IsOwner(0x0) )
51  return true;
52 
53  return false;
54 }
56 {
57  // connection already owned by the producer
58  if ( fBlock->IsOwner(fProducer->GetActor()) ) {
59  if ( fBlock->IsEoB() ) {
60  fBlock->SetOwner(0x0);
61  return false;
62  }
63  else
64  return true;
65  }
66 
67  // new block to be filled
69  // rewind for WRITING
70  fBlock->Rewind(ConfAgent::kWrite);
71 
72  return true;
73 }
74 
76 {
77  AnActorConnection *connection;
78 
79  // allocate a new connection and add it to the pool of connection
80  if ( left ) {
81  // look at the buffer size (name) is the globals
82  const Char_t *opt = (GetItem<std::string>("TypeDataBlockC",fGlobals)->Get()).data();
83  connection =
84  new DActorConnection(left,middle,GetItem<UInt_t>("SizeDataBlockC",fGlobals)->Get(),opt);
85  fAllConnections.push_back(connection);
86 
87  left->AddOutput(connection); middle->AddInput(connection);
88  }
89  if ( right ) {
90  // look at the buffer size (name) is the globals
91  const Char_t *opt = (GetItem<std::string>("TypeDataBlockP",fGlobals)->Get()).data();
92  connection =
93  new DActorConnection(middle,right,GetItem<UInt_t>("SizeDataBlockP",fGlobals)->Get(),opt);
94  fAllConnections.push_back(connection);
95 
96  middle->AddOutput(connection); right->AddInput(connection);
97  }
98 }
99 
100 
101 
102 
103 
104 
105 
106 
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
std::vector< ANamedItem * > fGlobals
to configure the emulator. The name of each item should be unique !
Definition: BaseEmulator.h:70
virtual void * SetOwner(void *owner=0x0)
Name of the block ... used to distinguish several blocks in a topology.
Definition: FrameBlock.h:104
virtual Long64_t GetSize(UInt_t=0u) const
size of the current block
Definition: FrameBlock.h:141
FrameBlock * fBlock
Block use to exchange data between the producer and the consumer.
Definition: DEmulator.h:46
virtual void AddOutput(AnActorConnection *)
Add one input line to the actor. It does not check if possible ... it has to be done by the user befo...
Default connection between actors : to be used in non-multi threaded programs.
Definition: DEmulator.h:38
std::vector< AnActorConnection * > fAllConnections
list of all connections. Owned by the emulator thus delete by this
Definition: BaseEmulator.h:76
ALoadedActor * fConsumer
right actor ==> Consumer
Definition: DEmulator.h:44
Bool_t IsEoB() const
Definition: FrameBlock.h:86
An actor looded in an emulator.
Definition: ALoadedActor.h:88
virtual NarvalInterface * GetActor() const
get loaded actor, should have the narval interface
Definition: ALoadedActor.h:160
virtual void AddInput(AnActorConnection *)
Add one input line to the actor. It does not check if possible ... it has to be done by the user befo...
virtual Bool_t IsOwner(void *owner=0x0) const
Definition: FrameBlock.h:108
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 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
virtual void Rewind(ConfAgent::EMode mode=ConfAgent::kRead)=0
Rewind to be ready to be used again.
header file for DEmulator.cpp
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