32 fRefToLoadedActor(lactor),
43 fRefToLoadedActor->GetGlobal(conf_path);
47 fConfigFunction(path.data(),&fError);
61 fActorType( kUnknown ),
62 fActorStatus( kUndefined ),
70 AConfigurator *old_conf = fConfigurator; fConfigurator = new_conf;
83 fInputs.push_back(aconnection);
90 fOutputs.push_back(aconnection);
95 if ( GetNbInput() == 0 )
100 Int_t tmp_depth = depth, max_depth = 0;
102 for (Int_t i = 0; i < GetNbInput() ; i++) {
108 if ( tmp_depth > max_depth ) {
109 max_depth = tmp_depth;
117 for (
size_t i = 0; i < globals.size(); i++) {
118 Bool_t add_new =
true;
119 for (
size_t j = 0; j < fGlobals.size(); j++) {
121 if ( globals[i]->GetName() == fGlobals[j]->GetName() ) {
123 if ( fGlobals[j]->Set(globals[i]) ) {
130 fGlobals.push_back( globals[i]->MakeAClone() );
134 if ( fGeneration == 0x0 ) {
135 for (
size_t j = 0; j < fGlobals.size(); j++) {
136 if ( fGlobals[j]->GetName() == std::string(
"Generation") ) {
145 Bool_t add_new =
true;
147 for (
size_t j = 0; j < fGlobals.size(); j++) {
149 if ( global.
GetName() == fGlobals[j]->GetName() ) {
151 if ( fGlobals[j]->Set(&global) ) {
160 if ( fGeneration == 0x0 ) {
161 for (
size_t j = 0; j < fGlobals.size(); j++) {
162 if ( fGlobals[j]->GetName() == std::string(
"Generation") ) {
171 Bool_t is_set =
false;
173 for (
size_t j = 0; j < fGlobals.size(); j++) {
175 if ( global.
GetName() == fGlobals[j]->GetName() ) {
177 if ( global.
Set(fGlobals[j]) ) {
191 for (UInt_t i = 0; i < fInputs.size(); i++) {
192 if ( fInputs[i]->GetProducer() == actor ) {
193 connection = fInputs[i];
201 for (UInt_t i = 0; i < fOutputs.size(); i++) {
202 if ( fOutputs[i]->GetConsumer() == actor ) {
203 connection = fOutputs[i];
209 connection = 0x0;
return result;
214 fConfigurator->SetError(0u);
215 fConfigurator->Configure();
217 SetLastError(fConfigurator->GetError());
222 fLog.SetProcessMethod(
"RegisterActor()");
224 if ( fConfigurator == 0x0 )
225 throw std::bad_alloc();
227 fConfigurator->SetError(0u);
229 fConfigurator->Register();
231 if ( fActor == 0x0 || fConfigurator->GetError() != 0u ) {
232 SetLastError(fConfigurator->GetError());
234 throw std::bad_alloc();
237 if ( fActor->GetMaxInput() == 0 && fActor->GetMaxOutput() == 0 ) {
239 fLog <<
error <<
"The registered actor " << GetName() <<
" cannot have any input and output " <<
dolog;
241 fActorType = kUnknown;
242 SetLastError(fConfigurator->GetError());
247 if ( fActor->GetMaxInput() > 1 || fActor->GetMaxOutput() > 1 ) {
250 if ( fGeneration->Get() > 0 ) {
251 for (
size_t i = 0; i < fInputs.size(); i++) {
252 if ( fActor->AttachInput(fInputs[i]->GetBlock(
'c') ) < 0 ) {
257 for (
size_t i = 0; i < fOutputs.size(); i++) {
258 if ( fActor->AttachOutput(fOutputs[i]->GetBlock(
'p') ) < 0 ) {
267 fActorType = kShunter;
273 if ( fActor->GetMaxInput() == 0 ) {
274 if ( fInputs.size() != 0 || fOutputs.size() != 1 ) {
275 fLog <<
error <<
"The registered producer " << GetName() <<
" has not the right number of [input and/or output] [" << fInputs.size() <<
"," << fOutputs.size() <<
"]" <<
nline;
279 if ( fGeneration->Get() > 0 ) {
280 fActor->AttachOutput(fOutputs[0]->GetBlock(
'p'));
282 fActorType = kProducer;
286 if ( fActor->GetMaxOutput() == 0 ) {
287 if ( fInputs.size() != 1 || fOutputs.size() != 0 ) {
288 fLog <<
error <<
"The registered consumer " << GetName() <<
" has not the right number of [input and/or output] [" << fInputs.size() <<
"," << fOutputs.size() <<
"]" <<
nline;
292 if ( fGeneration->Get() > 0 ) {
293 fActor->AttachInput(fInputs[0]->GetBlock(
'c'));
295 fActorType = kConsumer;
299 if ( fInputs.size() != 1 || fOutputs.size() != 1 ) {
300 fLog <<
error <<
"The registered filter " << GetName() <<
" has not the right number of [input and/or output] [" << fInputs.size() <<
"," << fOutputs.size() <<
"]" <<
nline;
304 if ( fGeneration->Get() > 0 ) {
305 fActor->AttachInput(fInputs[0]->GetBlock(
'c'));
306 fActor->AttachOutput(fOutputs[0]->GetBlock(
'p'));
308 fActorType = kFilter;
318 UInt_t error_code = 0u;
319 fActor->process_initialise(&error_code);
321 SetLastError(error_code);
328 switch ( generation ) {
333 switch (fActorType) {
335 p =
dynamic_cast<NarvalProducer *
> (fActor); block_out = fOutputs[0]->GetBlock(
'p');
340 p->
process_block(output_buffer,size_out,&used_size_out,&error_code);
346 block_out->
SetBlock(output_buffer,used_size_out,
'-');
347 if ( used_size_out > 0u )
353 c =
dynamic_cast<NarvalConsumer *
> (fActor); block_in = fInputs[0]->GetBlock(
'c');
358 if ( size_in > 0u ) {
368 f =
dynamic_cast<NarvalFilter *
> (fActor); block_in = fInputs[0]->GetBlock(
'c'); block_out = fOutputs[0]->GetBlock(
'p');
375 if ( size_in > 0u ) {
376 f->
process_block(input_buffer,size_in,output_buffer,size_out,&used_size_out,&error_code);
377 if ( used_size_out > 0u )
384 block_out->
SetBlock(output_buffer,used_size_out,
'-');
388 throw std::logic_error(
"Unknown actor for emulator generation 0,1");
397 switch (fActorType) {
399 block = fOutputs[0]->GetBlock(
'p'); block->
Rewind(ConfAgent::kWrite);
400 if ( GetStatus() == kDoRunning ) {
405 std::cout <<
"Actor " << GetName() <<
" has produced " << block->
GetSize() <<
" bytes " <<
std::endl;
424 c =
dynamic_cast<NarvalConsumer *
> (fActor); block_in = fInputs[0]->GetBlock(
'c');
426 std::cout <<
"cunsumer " << GetName() <<
" has " << block_in->
GetSize() <<
" bytes to consume " <<
std::endl;
431 if ( block_in->
IsEoB() )
443 f =
dynamic_cast<NarvalFilter *
> (fActor); block_in = fInputs[0]->GetBlock(
'c'); block_out = fOutputs[0]->GetBlock(
'p');
445 std::cout <<
"Filter " << GetName() <<
" has " << block_in->
GetSize() <<
" bytes to consume " <<
std::endl;
452 std::cout <<
"Filter " << GetName() <<
" has produced " << block_out->
GetSize() <<
" bytes " <<
std::endl;
486 throw std::logic_error(
"Unknown actor for emulator generation 0");
497 SetLastError(error_code);
505 std::vector <UInt_t> inputs_off, outputs_off;
508 Short_t generation = fGeneration->Get();
513 if ( generation < 1 ) {
514 ProcessActorGeneration_2_1_0(generation);
521 UInt_t ok_condition = fInputs.size() + fOutputs.size(), ok_val = 0u, nb_lazy = 0u, identical; inputs_off.clear(); outputs_off.clear();
522 for (UInt_t i = 0; i < fInputs.size(); i++) {
524 inputs_off.push_back(fInputs[i]->GetBlock(
'c')->GetOffset());
525 if ( fInputs[i]->IsLazy() ) {
528 if ( fInputs[i]->IsReadyforConsumer() ) {
529 if ( !fInputs[i]->IsLazy() )
531 fInputs[i]->SetReadyforConsumer();
534 for (UInt_t i = 0; i < fOutputs.size(); i++) {
536 outputs_off.push_back(fOutputs[i]->GetBlock(
'p')->GetOffset());
538 if ( fOutputs[i]->IsLazy() ) {
541 if ( fOutputs[i]->IsReadyforProducer() ) {
542 if ( !fOutputs[i]->IsLazy() )
544 fOutputs[i]->SetReadyforProducer();
547 ok_condition -= nb_lazy;
550 if ( ok_condition == ok_val ) {
551 fActor->ProcessBlocks();
556 for (UInt_t i = 0; i < fInputs.size(); i++) {
557 if ( inputs_off[i] == fInputs[i]->GetBlock(
'c')->GetOffset() )
560 for (UInt_t i = 0; i < fOutputs.size(); i++) {
561 if ( outputs_off[i] == fOutputs[i]->GetBlock(
'p')->GetOffset() )
564 if ( identical == (inputs_off.size()+outputs_off.size()) )
595 catch (
const std::exception& ex)
597 std::cout <<
" ERROR " << ex.what() <<
std::endl ;
void(* ConfigFunction)(const Char_t *, UInt_t *)
the function used to configure the underlying actor. Added to allow configuration by calling explicit...
virtual Long64_t GetSize(UInt_t=0u) const
size of the current block
virtual Bool_t Set(const ANamedItem *)=0
change value of this nmaed item using the passed one. it checks if asked, it check first if of the sa...
virtual void ConfigureActor()
configure this actor i.e call static methods. The way it is done depends on the Globals set by using ...
void ProcessActorGeneration_2_1_0(Short_t generation)
to deal with generation for which the interface depends of the kind of actor
Short_t IsLinked(ALoadedActor *, AnActorConnection *&) const
try to see if the two actors are linked: 0 no, -1 yes as input, +1 yes as output
virtual void InitActor()
Init this actor. The way it is done depends on the Globals set by using SetEnvironment (most of the t...
It defines the interface needed to be a narval actor (producer).
virtual ANamedItem * MakeAClone() const =0
clone that named item
LogMessage & error(LogMessage &)
virtual Long64_t GetMaxSize(UInt_t=0u) const
max size of the block
void ComputeDepth(Int_t &depth)
compute depth (the highest one) of this in the data flow.
header file for ALoadedActor.cpp
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...
ALoadedActor(const Char_t *name)
LogMessage & nline(LogMessage &)
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.
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.
std::string GetName() const
change value of this nmaed item using the passed one. it checks if asked, it check first if of the sa...
AConfigurator(ALoadedActor *, ConfigFunction)
virtual void RegisterActor()
Register this actor. The way it is done depends on the Globals set by using SetEnvironment (most of t...
An actor looded in an emulator.
It defines the interface needed to be a consumer.
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...
LogMessage & dolog(LogMessage &)
virtual Data_T Get() const
Get the data.
virtual BufferIO * GetBufferIO(UInt_t which=0u)=0
To get the address of the underlying buffer.
virtual UInt_t ProcessBlock(FrameBlock &)=0
virtual method to be implemented
virtual void ProcessActor()
do the job
virtual Bool_t SetBlock(Char_t *=0x0, UInt_t=0u, char= 'r', char= 'l', UInt_t=0u)=0
Attach a external block to this.
ADF::LogMessage & endl(ADF::LogMessage &log)
virtual void SetGlobals(const std::vector< ANamedItem * > &)
change all globals simultaneously
virtual Bool_t GetGlobal(ANamedItem &) const
to get back one global
virtual AConfigurator * SetConfigurator(AConfigurator *)
adopt it so it is delete by this. It returns the previous one so that the user can delete it once the...
virtual void SetGlobal(const ANamedItem &)
change one global
virtual UInt_t ProcessBlock(FrameBlock &)=0
process one block, virtual method to be implemented
Char_t * Address()
for classes that needs it to write directly data into it.
virtual UInt_t ProcessBlock(FrameBlock &, FrameBlock &)=0
virtual method to be implemented
virtual void Rewind(ConfAgent::EMode mode=ConfAgent::kRead)=0
Rewind to be ready to be used again.
base class in charge of configurating, allocating the true actor loaded in a LoadedActor ...
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.
It defines the interface needed to be a narval actor (Filter).
Base class that connects two actors in a general topology.
virtual void Configure()
configure environment for the actor.