31 #ifndef ADF_FrameFactory
34 #ifndef ADF_ConfigurationFrame
40 #ifndef ADF_GenericFrame
49 UInt_t Trigger::gUniqueID = 0u;
62 fActiveInputConfFrames(),
63 fIsOwnerOfOutput(true),
65 fEmbeddedOutputFrame(0x0)
70 fInputConfFrames.SetOwner(
true); fInputFrames.SetOwner(
true); fUtilities.SetOwner(
true);
76 if ( !fIsOwnerOfOutput )
81 for (UInt_t i = 0u; i < fInputKeyConst.size(); i++) {
82 if ( fInputKeyConst[i] ) {
83 delete fInputKeyConst[i]; fInputKeyConst[i] = 0x0;
87 fInputConfFrames.Delete(); fInputFrames.Delete();
107 FactoryItem kitem, fitem, newkeyitem, newframeitem;
114 {
Active(
true);
return true; }
123 std::vector< UShort_t > ok, exact; UShort_t nb_ok, change_input_ok = 0u, change_output_ok = 0u, change_utility_ok = 0u ;
144 if ( ok.back() == 1u ) {
148 fLog <<
info << kitem <<
" " << fitem <<
" cannot be used for this dataflow " <<
nline;
155 Bool_t changeok =
true;
159 if ( exact[which] == 1u )
186 if ( fEmbeddedOutputFrame ) {
188 delete fEmbeddedOutputFrame;
191 if ( fEmbeddedOutputFrame == 0x0 ) {
193 fLog <<
error <<
"Input Frame " << kitem <<
" " << fitem <<
" cannot be cloned ! " <<
nline;
197 fEmbeddedOutputFrame->
Reset();
200 fLog <<
"Input Frame " << kitem <<
" " << fitem <<
" has been changed successfully into " << newkeyitem <<
" " << newframeitem <<
nline;
204 fLog <<
error <<
"Fail in changing the Frame " << kitem <<
" " << fitem <<
" into " << newkeyitem <<
" " << newframeitem <<
nline;
206 if ( changeok ==
false ) {
216 fActiveInputConfFrames.clear();
218 for (UInt_t i = 0u; i < fInputConfFrames.GetSize(); i++ ) {
228 change_input_ok = 2u;
229 fLog <<
error <<
"changing Configuration Frame " << kitem <<
" " << fitem <<
" since not known precisely " <<
nline;
241 if ( newconfframe ) {
248 std::pair<ConfigurationFrame *, UShort_t> newactiveconf;
249 newactiveconf.first = newconfframe;
250 newactiveconf.second = fMap[i];
251 fActiveInputConfFrames.push_back(newactiveconf);
256 fLog <<
"Configuration Frame " << kitem <<
" " << fitem <<
" has been changed successfully into " << newkeyitem <<
" " << newframeitem <<
nline;
259 change_input_ok = 2u;
260 fLog <<
warning <<
"Fail casting Configuration Frame " << kitem <<
" " << fitem <<
" into " << newkeyitem <<
" " << newframeitem <<
nline;
265 change_input_ok = 2u;
266 fLog <<
error <<
"Fail allocating new Configuration Frame " << newkeyitem <<
" " << newframeitem <<
nline;
272 change_input_ok = 2u;
277 change_input_ok = 1u;
278 fLog <<
info <<
"Inputs of trigger " <<
GetName() <<
" not suitable for the current dataflow " <<
nline;
282 if ( fOutputFrame ) {
292 UShort_t wcase = 10u;
303 fLog <<
info <<
"Output of trigger " <<
GetName() <<
" already suitable for the data flow " <<
nline;
306 fLog <<
info <<
"Frame " << kitem <<
" " << fitem <<
" has been added to the current agent " <<
nline;
311 Bool_t changeok =
true;
327 fLog <<
"Output Frame " << kitem <<
" " << fitem <<
" has been changed successfully into " << newkeyitem <<
" " << newframeitem <<
nline;
330 else changeok =
false;
336 change_output_ok = 2u;
342 change_output_ok = 2u;
352 for(UInt_t which = 0u; which < fUtilities.GetSize(); which++ ){
367 if ( ok.back() == 1u )
370 fLog <<
info << kitem <<
" " << fitem <<
" cannot be used for this dataflow " <<
nline;
374 okframe = (nb_ok == fUtilities.GetSize());
377 Bool_t changeok =
true;
378 for(UInt_t which = 0u; which < fUtilities.GetSize(); which++ ){
381 if ( exact[which] == 1u )
406 fLog <<
"Utility Frame " << kitem <<
" " << fitem <<
" has been changed successfully into " << newkeyitem <<
" " << newframeitem <<
nline;
411 fLog <<
error <<
"Fail in changing the Frame " << kitem <<
" " << fitem <<
" into " << newkeyitem <<
" " << newframeitem <<
nline;
414 if ( changeok ==
false )
418 change_utility_ok = 2u;
423 change_utility_ok = 1u;
424 fLog <<
info <<
"Utilities of trigger " <<
GetName() <<
" not suitable for the current dataflow " <<
nline;
428 if ( change_input_ok == 0u && change_output_ok == 0u && change_utility_ok == 0u ) {
434 if ( change_input_ok < 2u && change_output_ok < 2u && change_utility_ok < 2u ) {
453 if ( fOutputFrame == 0x0 )
461 if ( fIsOwnerOfOutput && f && f != frame )
464 fIsOwnerOfOutput =
false;
475 if ( fOutputFrame ) {
476 if ( ! fIsOwnerOfOutput )
479 delete fOutputFrame ;
481 fOutputFrame = sfp; fIsOwnerOfOutput =
true;
490 if ( fOutputFrame && fOutputFrame->
IsValid() )
496 Frame *main_frame, *single_output = 0x0; Bool_t invalid_out =
true, ok =
true; UInt_t sizemax;
499 fInputFrames.At(0u)->GetFrame();
500 if ( fOutputFrame && fOutputFrame->
IsValid() ) {
502 single_output = fOutputFrame->
GetFrame();
514 if ( !
IsConsumable(0u) && fInputFrames.At(0u)->IsValid() )
522 return single_output;
528 if ( single_output && !main_frame->
IsASubFrame((*single_output)) )
529 return single_output;
533 if (
IsConsumable(0u) || !fInputFrames.At(0u)->IsValid() )
534 return single_output;
541 fEmbeddedOutputFrame->
GetKey()->SetDataLength(0u);
545 ok = ok && fEmbeddedOutputFrame->
AddSubFrame((*single_output));
550 sizemax = (UInt_t)fScanPattern.size();
551 for (UInt_t i = 0u; i < sizemax; i++) {
552 if ( fScanPattern[i] > 0u ) {
553 if( ! fIsConsumable[fScanPattern[i]] && fInputFrames.At(fScanPattern[i])->IsValid() )
560 sizemax = (UInt_t)fScanPattern.size();
561 for (UInt_t i = 0u; i < sizemax; i++) {
562 if ( fScanPattern[i] > 0u ) {
563 if( ! fIsConsumable[fScanPattern[i]] && fInputFrames.At(fScanPattern[i])->IsValid() )
574 sizemax = (UInt_t)fScanPattern.size();
575 for (UInt_t i = 0u; i < sizemax; i++) {
584 return fEmbeddedOutputFrame;
591 if ( which < fIsConsumable.size() )
592 return fIsConsumable[which];
601 std::string opt = option;
613 if ( sfp && cstkey ) {
615 fInputFrames.Add(sfp); fInputKeyConst.push_back(cstkey);
617 fIsConsumable.push_back(iscons);
619 fIndividualFired.push_back(
false);
621 if ( opt.find(
"!") != std::string::npos )
622 fFiredOn.push_back(0);
624 if ( opt.find(
"|") != std::string::npos )
625 fFiredOn.push_back(-1);
627 fFiredOn.push_back(1);
631 if ( fEmbeddedOutputFrame == 0x0 &&
632 fInputFrames.At(0u)->GetFrame()->IsComposite() ) {
633 fEmbeddedOutputFrame =
635 if ( fEmbeddedOutputFrame == 0x0 )
637 else fEmbeddedOutputFrame->
Reset();
671 if ( fIndividualFired[which_input] ==
false )
673 Frame *composite = fInputFrames.At(which_input)->GetFrame();
678 if ( which_sub < composite->GetNbSubFrame() ) {
700 sfp = fInputFrames.At(which);
710 fInputConfFrames.Add(sfpc); fMap.push_back(which);
712 else {
delete sfpc; sfpc = 0x0; }
723 Bool_t ok =
false;
Frame *f_to_chek = fInputFrames.At(0u)->GetFrame();
725 for (UInt_t i = 0u; i < fActiveInputConfFrames.size() ; i++) {
742 ok = fInputFrames.At(fMap[i])->GetFrame()->Configure(confframe,
"in");
750 fIsFired = fIndividualFired[0] =
false;
753 if ( fInputFrames.GetSize() == 0u )
763 Frame *mainframe = fInputFrames.At(0)->GetFrame();
766 fInputKeyConst[0u]->IsAKey(mainframe->
GetKey());
773 fIsFired = fIndividualFired[0] =
true;
774 if ( fInputFrames.GetSize() == 1u ) {
775 fInputFrames.At(0)->SetValid(
true);
782 fScanPattern.clear();
783 for (UInt_t sec = 0u ; sec < mainframe->
GetNbSubFrame() ; sec++ )
784 fScanPattern.push_back(0u);
787 for (UInt_t sec = 1u ; sec < fInputFrames.GetSize() ; sec++ ) {
789 fIndividualFired[sec] =
false; fInputFrames.At(sec)->SetValid(
false);
792 Frame *subframe = fInputFrames.At(sec)->GetFrame();
795 Bool_t is_ok =
false;
796 for (UInt_t sub = 0u ; sub < mainframe->
GetNbSubFrame(); sub++ ) {
807 fScanPattern[sub] = sec;
808 fInputFrames.At(sec)->SetValid(
true);
809 fIndividualFired[sec] =
true;
815 switch ( fFiredOn[sec] ) {
841 std::string sin = in, sout = out,
tmp, opt;
ConfAgent *lagent;
857 std::istringstream decode(sin);
862 if ( !decode.good() )
865 if ( tmp.find(
"!") == 0 ) {
870 if ( tmp.find(
"|") == 0 ) {
875 trig->
Add(
"Agata",tmp.data(),lagent,
false,opt.c_str());
879 std::istringstream decode(sout);
884 if ( !decode.good() )
895 bool iscons,
const Char_t *option)
897 FactoryItem kitem(
"Agata",type,v_key), fitem(
"Agata",type,v_frame);
903 bool iscons,
const Char_t *option)
914 FactoryItem k_asked(factory_name,frame_type,
Version()), f_asked(factory_name,frame_type,
Version()), k_defined, f_defined;
947 FactoryItem k_asked(key_item), f_asked(frame_item), k_defined, f_defined;
964 FactoryItem kitem(
"Agata",type,v_key), fitem(
"Agata",type,v_frame);
FrameTrigger(const Char_t *trig_name)
virtual const Key * GetSubKey(UInt_t) const =0
Returns one of the sub-key in case this is a composite frame.
virtual const BufferIO * GetRealBuffer() const
virtual SharedFP * SetOutputFrame(Frame *frame)
Once a trigger has fired, the result of the algorithm is set through this.
virtual Bool_t IsValid() const
true if it is a valid pointer
Bool_t fIsZombie
true if this is a zombie (EX: objects not properly allocated)
virtual Key * GetKey()=0
To get the Key associated to this frame.
virtual Frame * GetFrame() const
virtual Bool_t TransfertSubFrame(const Frame &, UInt_t)
copy the sub-frame #i to the Frame given in the second argument
Bool_t IsUniversal() const
Check if this trigger is in fired state.
static MainFrameFactory & theMainFactory()
the main (global) keyfactory
header file for FactoryItem.cpp
virtual Frame * New(const FactoryItem &key_item, const FactoryItem &frame_item)
just a frame
virtual void Unlink()
Copy a buffer to this Frame.
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
virtual UInt_t Read()
It reads the content into dedicated structures from the Frame (data part)
virtual void FastReset()=0
FastReset the current frame, means the data part keep the previous values.
const FactoryItem & GetSignature() const
virtual SharedFP * Add(const FactoryItem &key_item, const FactoryItem &frame_item, bool iscons=true, const Char_t *option="")
Add a frame to the list of required frames.
A configuration frame is just an encapsulation of a string.
virtual Bool_t Copy(const Char_t *, UInt_t)
Copy an external buffer to this key.
virtual const BufferIO * GetRealBuffer() const =0
give access to the underlying buffer of the data part
LogMessage & error(LogMessage &)
Bool_t IsActive() const
Check if this trigger is in fired state.
virtual Key * GetKey()
To get the Key associated to this frame.
virtual DFAgent * GetDFAgent()=0
to get the Data Flow Agent in charge of knowing the structure of the DF
virtual UInt_t GetDataLength() const
virtual Bool_t Link(const Char_t *buf, UInt_t size, const char opt= 'b')
Link a buffer to this Frame.
static ConfAgent * theGlobalAgent(std::string="Agata")
to get the global agent
virtual Bool_t IsConsumable(UInt_t which=0u) const
to know if the frame is consumable or not
virtual std::string & GetProcessMethod()
To get the current method.
Bool_t NoChange(const FactoryItem &item_from, const FactoryItem &item_to)
No changes allowed.
const PF_FactoryItemChange & GetKeyChangeFunction() const
LogMessage fLog
to send messages to the log server
static AgataFrameTrigger * Build(const Char_t *name, const Char_t *in, const Char_t *out="", ConfAgent *agent=0x0)
Build a new AgataFrame Trigger.
UShort_t IsAKnownFrame(const FactoryItem &kit, const FactoryItem &fit, PF_FactoryItemChange kch=ChangeOfVersion, PF_FactoryItemChange fch=ChangeOfVersion) const
To know if a Frame is known by the Agent under the conditions given.
header file for Trigger.cpp
virtual Bool_t IsComposite() const
tells if this frame is a composite frame i.e. if it is composed of sub-frames
friend LogMessage & clear(LogMessage &)
others
void AddKnownFrame(const FactoryItem &item_key, const FactoryItem &item_frame, const Char_t opt= '+')
internal use to avoid adding a definition of a Frame that cannot be allocated
virtual Frame * GetSubFrameFrom(UInt_t which_input, UInt_t which_sub, SharedFP *utility, Bool_t do_scan=false)
to extract a sub frame from one event frame of the current trigger
virtual void FrameTransfert(Frame *from, Frame *to)
virtual UInt_t GetKeyLength() const
Unique number corresponding to a type of Key.
void TransferLinkAndProxy(GObject &to)
transfert proxy and link for one GObject to another one
Base class for version numbers.
virtual SharedFP * AddUtility(const FactoryItem &key_item, const FactoryItem &frame_item)
Add utilities, used to decode/encode composite frames.
virtual SharedFP * SetOutputFrame(Frame *frame)
Once a trigger has fired, the result of the algorithm is set through this.
const Char_t * GetAddress() const
Pointer to the current underlying array of bytes.
virtual void SetProcessMethod(const char *)
To set the current method.
virtual void Unlink()=0
UnLink a buffer to this Frame.
void Active(Bool_t b=true)
Active this trigger.
LogMessage & nline(LogMessage &)
virtual Bool_t Reconfigure(ConfAgent *)
Modify the Frame definitions respecting the new data flow definition and the acceptable Frame changes...
virtual const DFAgent * GetConstDFAgent() const =0
virtual Bool_t Check()
Check the content of the frame if the primary frame is a composite one.
virtual SharedFP * Add(const FactoryItem &key_item, const FactoryItem &frame_item, bool iscons=true, const Char_t *option="")
Add a frame to the list of required frames.
virtual SharedFP * NewSharedFrame(const FactoryItem &, const FactoryItem &)
Ask the main for a new Frame.
Bool_t SetAsCompatibleItems(FactoryItem &factory_key_item, FactoryItem &factory_frame_item) const
change both item as the same time
const std::string & GetName() const
To be used for Agata Data Flow.
Bool_t fIsFired
true if this has just been fired
FactoryItem WhichKnownKey(const FactoryItem &kit, const FactoryItem &fit, PF_FactoryItemChange kch=ChangeOfVersion, PF_FactoryItemChange fch=ChangeOfVersion) const
header file for DFAgent.cpp
A DFAgent contains all the information concerning the structure of the data flow. ...
virtual Short_t GetCheckLevel() const
virtual void Reset()=0
Reset the current frame.
virtual Bool_t LinkSubFrame(UInt_t, Frame *)
Attach the sub-frame corresponding to the given subkey # to the Frame given in the second argument...
Bool_t IsZombie() const
Check if this trigger is in fired state.
void Zombie(Bool_t b=true)
this trigger
virtual Frame * SetFrame(Frame *)
change the frame, returns the current one
Base class for a trigger on a data flow.
AgataFrameTrigger(const Char_t *trig_name)
virtual void SetCheckLevel(Short_t checklevel)
The number of tests (and the speed !) once writing/reading in Frame increase with this level...
virtual void SetKeyChangeFunction(PF_FactoryItemChange pf)
virtual UInt_t GetNbInputFrame() const
number of input frames that define this trigger
virtual SharedFP * AddAutoConf(const FactoryItem &key_item, const FactoryItem &frame_item, UInt_t which)
Add a configuration frame to the input frame #which.
LogMessage & dolog(LogMessage &)
virtual Bool_t IsASubFrame(const Frame &)
to check if a subframe could be added to the composite frame
virtual Frame * GetEmbeddedOutputFrame(ConfAgent::EModel model=ConfAgent::kStrict)
In case the output frame should be embedded.
virtual SharedFP * AddUtility(const FactoryItem &key_item, const FactoryItem &frame_item, const ConfAgent *agent)
Add utilities, used to decode/encode composite frames.
virtual UInt_t Scan()
Scan this Frame. If it is a composite frame, it looks for the keys of sub-frames. ...
virtual Bool_t AddSubFrame(const Frame &)
Add a subframe to that frame (only if composite)
virtual std::string & GetProcessName()
To get the Process name.
Base class for a DataInterface.
static MainKeyFactory & theMainFactory()
the main (global) keyfactory
header file for FrameFactory.cpp
virtual UInt_t GetNbSubFrame() const
Returns the number of sub-frames composing this frame. Scan have to be called first.
virtual Bool_t CheckConf()
Check if the currently read key fired this trigger. If yes, IsFired is true.
virtual Key * New(const FactoryItem &)
build a key using item.
FactoryItem WhichKnownFrame(const FactoryItem &kit, const FactoryItem &fit, PF_FactoryItemChange kch=ChangeOfVersion, PF_FactoryItemChange fch=ChangeOfVersion) const
To get the exact definition of a key and a Frame.
virtual Bool_t IsAKey(const Key *akey) const
Compares two keys.
const PF_FactoryItemChange & GetFrameChangeFunction() const
Base class that described an item in a Factory.
LogMessage & warning(LogMessage &)
const FactoryItem & GetSignature() const
Signature of that frame.
virtual GObject * Global()