28 #ifndef ADF_KeyFactory
31 #ifndef ADF_ConfigurationFrame
42 DFAgent::DFAgent(
const Char_t *rid,
const Char_t *srid, Bool_t is_record, Bool_t global) :
46 fPrimaryKey(
"Default",
"FS",
Version(0,1)) ,
49 fListOfRequiredKeyFactories(),
50 fListOfRequiredFrameFactories(),
51 fListOfKeyFactories(),
52 fListOfFrameFactories()
58 LinkFactories(global);
67 fListOfFrames.clear(); fListOfRequiredKeyFactories.clear(); fListOfRequiredFrameFactories.clear(); fListOfKeyFactories.clear(); fListOfFrameFactories.clear();
70 void DFAgent::LinkFactories(Bool_t global)
82 std::list< KeyFactory * >::iterator
84 for ( key_listed_item = fListOfKeyFactories.begin() ; key_listed_item != fListOfKeyFactories.end() ; key_listed_item++ ) {
98 std::list< FrameFactory * >::iterator
100 for ( frame_listed_item = fListOfFrameFactories.begin() ; frame_listed_item != fListOfFrameFactories.end() ; frame_listed_item++ ) {
110 std::list< KeyFactory * >::iterator
112 for ( listed_item = fListOfKeyFactories.begin(); listed_item != fListOfKeyFactories.end() ; listed_item++ ) {
114 fact = (*listed_item);
124 std::list< FrameFactory * >::iterator
126 for ( listed_item = fListOfFrameFactories.begin(); listed_item != fListOfFrameFactories.end() ; listed_item++ ) {
128 fact = (*listed_item);
138 if ( factory == 0x0 )
145 std::list< FactoryItem >::iterator
147 for ( listed_item = fListOfRequiredKeyFactories.begin() ; listed_item != fListOfRequiredKeyFactories.end() ; listed_item++ ) {
148 if ( (*listed_item).GetFactoryName() == factory_item.
GetFactoryName() ) {
152 (*listed_item).SetFactoryPtr(factory);
157 fListOfRequiredKeyFactories.remove((*listed_item));
169 fListOfRequiredKeyFactories.push_back(l_item);
179 if ( factory == 0x0 )
186 std::list< FactoryItem >::iterator
188 for ( listed_item = fListOfRequiredFrameFactories.begin() ; listed_item != fListOfRequiredFrameFactories.end() ; listed_item++ ) {
189 if ( (*listed_item).GetFactoryName() == factory_item.
GetFactoryName() ) {
193 (*listed_item).SetFactoryPtr(factory);
198 fListOfRequiredFrameFactories.remove((*listed_item));
210 fListOfRequiredFrameFactories.push_back(l_item);
220 std::list< FactoryItem >::iterator
222 for ( listed_item = fListOfRequiredKeyFactories.begin() ; listed_item != fListOfRequiredKeyFactories.end() ; listed_item++ ) {
223 if ( (*listed_item).GetFactoryName() == factory_item.
GetFactoryName() ) {
240 std::list< FactoryItem >::iterator
242 for ( listed_item = fListOfRequiredFrameFactories.begin() ; listed_item != fListOfRequiredFrameFactories.end() ; listed_item++ ) {
243 if ( (*listed_item).GetFactoryName() == factory_item.
GetFactoryName() ) {
270 fListOfFrames.clear();
274 std::list< std::pair<FactoryItem,FactoryItem> >::iterator
276 for ( listed_item = fListOfFrames.begin() ; listed_item != fListOfFrames.end() ; listed_item++ ) {
277 if ( (*listed_item).first.IsAVersion(item_key) && (*listed_item).second.IsAVersion(item_frame) ) {
279 fListOfFrames.remove((*listed_item));
281 (*listed_item).first.SetVersion(item_key.
GetVersion());
282 (*listed_item).second.SetVersion(item_frame.
GetVersion());
289 pair <FactoryItem,FactoryItem> p;
291 p.second = item_frame;
293 fListOfFrames.push_back(p);
306 std::string option = opt;
316 fListOfFrames.clear(); fListOfRequiredKeyFactories.clear(); fListOfRequiredFrameFactories.clear();
327 std::list< KeyFactory * >::iterator
329 for ( listed_item = fListOfKeyFactories.begin(); listed_item != fListOfKeyFactories.end() ; listed_item++ ) {
330 (*listed_item)->SetEndian(e);
336 UShort_t ok; Bool_t ok_key, ok_frame;
FactoryItem l_to_key(to_key), l_to_frame(to_frame);
342 std::list< std::pair<FactoryItem,FactoryItem> >::iterator
344 for ( listed_item = fListOfFrames.begin() ; listed_item != fListOfFrames.end() ; listed_item++ ) {
345 ok_key = pfk ( (*listed_item).first , l_to_key );
346 ok_frame = pff ( (*listed_item).second , l_to_frame );
347 if ( ok_key && ok_frame )
357 std::list< pair<FactoryItem,FactoryItem> >::iterator
359 for ( listed_item = fListOfFrames.begin() ; listed_item != fListOfFrames.end() ; listed_item++ ) {
360 ok_key = pfk ( (*listed_item).first , to_key );
361 ok_frame = pff ( (*listed_item).second , to_frame );
362 if ( ok_key && ok_frame ) {
363 ok = (*listed_item).first;
374 std::list< pair<FactoryItem,FactoryItem> >::iterator
376 for ( listed_item = fListOfFrames.begin() ; listed_item != fListOfFrames.end() ; listed_item++ ) {
377 ok_key = pfk ( (*listed_item).first , to_key );
378 ok_frame = pff ( (*listed_item).second , to_frame );
379 if ( ok_key && ok_frame ){
380 ok = (*listed_item).second;
389 string tmp1, tmp2, tmp3, tmp4, tmp5; UInt_t ui1, ui2, ui3, ui4, ui5;
FactoryItem factory_item;
392 Bool_t ok_decode =
true;
395 if ( aline.find(
"Endian:") == 0 ) {
397 istringstream decode(aline);
400 decode >> tmp1 >> tmp2;
401 if ( decode.good() ) {
402 if ( tmp2 ==
"kLittle" ) {
405 if ( tmp2 ==
"kBig" ) {
410 else ok_decode =
false;
414 if ( aline.find(
"KeyFactory:") == 0 ) {
416 istringstream decode(aline);
419 decode >> tmp1 >> tmp2 ;
420 if ( decode.good() ) {
422 Short_t factory_version; decode >> factory_version;
424 if ( ! decode.good() )
425 factory_version = -1;
427 factory_item.
SetItem(tmp2.data(),factory_version,
"",
Version(0,0));
430 <<
"The KeyFactory " << factory_item <<
" is not registered !! \n";
433 else ok_decode =
false;
437 if ( aline.find(
"FrameFactory:") == 0 ) {
438 istringstream decode(aline);
441 decode >> tmp1 >> tmp2 ;
442 if ( decode.good() ) {
444 Short_t factory_version; decode >> factory_version;
446 if ( ! decode.good() )
447 factory_version = -1;
449 factory_item.
SetItem(tmp2.data(),factory_version,
"",
Version(0,0));
452 <<
"The Frame Factory " << factory_item <<
" is not registered !! \n";
455 else ok_decode =
false;
458 if ( aline.find(
"PrimaryKey:") == 0 ) {
460 istringstream decode(aline);
463 decode >> tmp1 >> tmp2 >> tmp3 >> ui1 >> ui2;
465 if ( decode.good() ) {
476 fPrimaryKey = factory_item;
481 <<
"PrimaryKey " << factory_item <<
" is not known \n";
484 else ok_decode =
false;
487 if ( aline.find(
"AutoConf:") == 0 ) {
492 istringstream decode(aline);
495 decode >> tmp1 >> tmp2 >> tmp3 >> ui2 >> ui3 >> tmp4 >> tmp5 >> ui4 >> ui5 ;
497 if ( decode.good() ) {
506 fAutoConf.first = itemkey;
507 fAutoConf.second = itemframe;
511 <<
"AutoConf " << itemkey << itemframe <<
" is not known by the system @ this level " <<
nline;
517 else ok_decode =
false;
520 if ( aline.find(
"Frame:") == 0 ) {
525 std::istringstream decode(aline);
528 decode >> tmp1 >> tmp2 >> tmp3 >> ui2 >> ui3 >> tmp4 >> tmp5 >> ui4 >> ui5 ;
533 if ( decode.good() ) {
539 <<
" Frame " << itemkey << itemframe <<
" is not known by the system, so not added to the DFAgent " <<
nline;
557 out <<
"# Endian type \n";
563 out <<
"# Factories (and version) for Frames & Keys \n" ;
565 std::list< FactoryItem >::iterator
567 for (listed_item = fListOfRequiredKeyFactories.begin(); listed_item != fListOfRequiredKeyFactories.end() ; listed_item++ ){
568 out <<
"KeyFactory: " << (*listed_item).GetFactoryName() <<
" " << (*listed_item).GetFactoryVersion() <<
" \n";
570 for (listed_item = fListOfRequiredFrameFactories.begin(); listed_item != fListOfRequiredFrameFactories.end() ; listed_item++ ){
571 out <<
"FrameFactory: " << (*listed_item).GetFactoryName() <<
" " << (*listed_item).GetFactoryVersion() <<
" \n";
573 out <<
"# Version of the primary keys that structure the data flow \n";
575 out <<
"AutoConf: " << fAutoConf.first.GetFactoryName() <<
" " << fAutoConf.first.GetItemName() <<
" " << fAutoConf.first.GetVersion().GetMajor() <<
" " << fAutoConf.first.GetVersion().GetMinor() <<
" "
576 << fAutoConf.second.GetFactoryName() <<
" " << fAutoConf.second.GetItemName() <<
" " << fAutoConf.second.GetVersion().GetMajor() <<
" " << fAutoConf.second.GetVersion().GetMinor() <<
" \n";
577 out <<
"# Current Frames going through the data flow \n";
579 std::list< pair<FactoryItem,FactoryItem> >::iterator
581 for (listed_fitem = fListOfFrames.begin(); listed_fitem != fListOfFrames.end(); listed_fitem++ ){
582 out <<
"Frame: " << (*listed_fitem).first.GetFactoryName() <<
" " << (*listed_fitem).first.GetItemName() <<
" " << (*listed_fitem).first.GetVersion().GetMajor() <<
" " << (*listed_fitem).first.GetVersion().GetMinor() <<
" "
583 << (*listed_fitem).second.GetFactoryName() <<
" " << (*listed_fitem).second.GetItemName() <<
" " << (*listed_fitem).second.GetVersion().GetMajor() <<
" " << (*listed_fitem).second.GetVersion().GetMinor() <<
" " <<
std::endl;
void SetEndian(BaseBuffer::EEndian)
const FactoryItem & GetPrimaryKey() const
Just to know if the size of the frame is coded on 2 bytes, 4 bytes ... or 8 bytes.
virtual Key * GetKey()=0
To get the Key associated to this frame.
virtual Bool_t ProcessLine(const std::string &)
decode an input line to configure/reconfigure this DFAgent
static MainFrameFactory & theMainFactory()
the main (global) keyfactory
Base class for a FrameFactory.
header file for FactoryItem.cpp
header file for KeyFactory.cpp
DotConf : Utility for class configuration from ascii file or Configuration frames.
const FactoryItem & GetSignature() const
Bool_t SetKnownFrameFactory(const FactoryItem &factory_item)
check if the factory is referenced by the agent.
void SetFactoryVersion(Short_t v)
Change the factory version.
void SetLastModif()
set in last modif string the current date.
Bool_t SetAsCompatibleKeyItem(FactoryItem &factory_item) const
Take the item and prepare it to be an item related to the is agent i.e. set the factory version # and...
LogMessage & error(LogMessage &)
KeyFactory * GetKeyFactory(const FactoryItem &item)
look in the DFAgent list if this factory exist and with a version # greater that the given one ...
virtual Bool_t DoConfigure(std::istream &in, Bool_t allow_init)
configure this from an input stream
DFAgent(const Char_t *rid, const Char_t *srid, Bool_t is_record=true, Bool_t global=true)
in case global is true, it keeps a list of pointers to the global factories otherwise asked for Clone...
Bool_t(* PF_FactoryItemChange)(const FactoryItem &, const FactoryItem &)
prototype function to control the evolution of a factory item.
virtual void Reset(const Char_t *opt="")
Reset : all values are set to default.
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.
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
void SetPrimaryKey(const FactoryItem &item)
to set the definition of the Keys for input
Short_t GetFactoryVersion() const
Ask the factory version.
Base class for version numbers.
LogMessage & nline(LogMessage &)
LogMessage fLog
the log messenger ... to know the object hae been properly intitialised/modified
virtual Bool_t DoConfigure(std::istream &, Bool_t allow_init)
configure this from an input stream
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
FrameFactory * GetFrameFactory(const FactoryItem &item)
look in the DFAgent list if this factory exist and with a version # greater that the given one ...
const std::string & GetFactoryName() const
void SetItem(const Char_t *whichfactory, const Char_t *whichitem, Version itemversion, Short_t factversion=-1, void *ptr=0x0)
to change an item
const std::vector< KeyFactory * > & ListOfFactories() const
direct access to the list of factories
FactoryItem WhichKnownKey(const FactoryItem &kit, const FactoryItem &fit, PF_FactoryItemChange kch=ChangeOfVersion, PF_FactoryItemChange fch=ChangeOfVersion) const
header file for DFAgent.cpp
Bool_t SetKnownKeyFactory(const FactoryItem &factory_item)
check if the factory is referenced by the agent.
UShort_t GetMinor() const
Version GetVersion() const
ADF::LogMessage & endl(ADF::LogMessage &log)
void SetMaxVersion(Short_t v)
void SetFactoryPtr(void *ptr)
change
virtual void AddConf(DotConf *)
add a conf object to this. The added objects are not owned by this so not deleted.
virtual std::string & GetProcessName()
To get the Process name.
static MainKeyFactory & theMainFactory()
the main (global) keyfactory
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.
Bool_t SetAsCompatibleFrameItem(FactoryItem &factory_item) const
Take the item and prepare it to be an item related to the is agent i.e. set the factory version # and...
const std::string & GetItemName() const
Bool_t AddRecord(std::ostream &, char t= 'b')
Add a begin or end of record, return true if done.
Base class that described an item in a Factory.
LogMessage & warning(LogMessage &)
const FactoryItem & GetSignature() const
Signature of that frame.
UShort_t GetMajor() const
const std::vector< FrameFactory * > & ListOfFactories() const
direct access to the list of factories