23 #ifndef ADF_DefaultKeyFactory
62 #include "AgataKeyFactory.icpp"
68 AgataKeyFactory::AgataKeyFactory () :
71 fHardcodedMessageTable(),
75 fLog.GetProcessName() =
"ADF::AgataKeyFactory";
78 SetRID(
"ADF::AgataKeyFactory");
83 fHardcodedMessageTable[
"agata"] = std::pair<UInt_t,UInt_t>(0x0A000000,0x0F000000);
84 fHardcodedMessageTable[
"data"] = std::pair<UInt_t,UInt_t>(0x0A000100,0x0F000F00);
85 fHardcodedMessageTable[
"meta"] = std::pair<UInt_t,UInt_t>(0x0A001100,0x0F00FF00);
86 fHardcodedMessageTable[
"conf"] = std::pair<UInt_t,UInt_t>(0x0A000200,0x0F000F00);
87 fHardcodedMessageTable[
"algo"] = std::pair<UInt_t,UInt_t>(0x0A000300,0x0F000F00);
88 fHardcodedMessageTable[
"info"] = std::pair<UInt_t,UInt_t>(0x0A000400,0x0F000F00);
89 fHardcodedMessageTable[
"rmess"] = std::pair<UInt_t,UInt_t>(0x0A000500,0x0F000F00);
90 fHardcodedMessageTable[
"cmess"] = std::pair<UInt_t,UInt_t>(0x0A000600,0x0F000F00);
91 fHardcodedMessageTable[
"event"] = std::pair<UInt_t,UInt_t>(0xCA000000,0xFF000000);
97 fIsPatchEvent =
false;
100 fMessageTable.clear();
128 UInt_t message = fHardcodedMessageTable[
"agata"].first, mask = fHardcodedMessageTable[
"agata"].second ;
131 if ( fIsPatchEvent && keytype ==
"event:data:psa" )
133 if ( fIsPatchEvent && keytype ==
"event:data" )
134 keytype =
"data:merger";
137 std::map<std::string,std::pair<UInt_t,UInt_t> >::iterator im;
141 for (im = fMessageTable.begin() ; im != fMessageTable.end() ; im++ ) {
142 if ( im->first == keytype ) { isin = 1;
break; }
144 for (im = fHardcodedMessageTable.begin() ; im != fHardcodedMessageTable.end() ; im++ ) {
145 if ( im->first == keytype ) { isin = 2;
break; }
149 delete key; key = 0x0;
152 message = fMessageTable[keytype].first;
153 mask = fMessageTable[keytype].second;
156 message = fHardcodedMessageTable[keytype].first;
157 mask = fHardcodedMessageTable[keytype].second;
163 fLog <<
error <<
" Key type " << item <<
" has not been found in the Agata key factory, version " <<
GetVersion() <<
nline;
172 fLog <<
error <<
" Key " << item <<
" is not known by the Agata key factory, version " <<
nline;
185 UInt_t ui1, ui2; std::pair<UInt_t,UInt_t> tmpp; std::string
tmp, keytype, stream_option =
GetStreamOption(); Bool_t ok =
true;
188 std::istringstream decode(aline);
191 decode >> tmp >> std::hex >> ui1 >> ui2 ;
193 if ( !decode.good() ) {
202 if (
GetVersion() == -1 && stream_option.find(
"Init") == std::string::npos ) {
213 if ( fMessageTable.count(tmp) == 1 )
215 if ( fHardcodedMessageTable.count(tmp) == 1 )
221 if (
GetVersion() == -1 && keytype ==
"data:eb" && ui1 == 0xFA010103 ) {
223 fLog <<
info <<
" Switch to patch == true for version - 1 " << keytype <<
nline;
224 fIsPatchEvent =
true;
226 if (
GetVersion() == -1 && keytype ==
"event:data:psa" && ui1 == 0xCA010102 ) {
228 fLog <<
info <<
" Switch to patch == true for version - 1 " << keytype <<
nline;
229 fIsPatchEvent =
true;
233 if ( fHardcodedMessageTable.count(tmp) == 1 ) {
235 fLog <<
info <<
" Attemp to modify an hard coded key " << tmp <<
" ... ignored "<<
nline;
239 if ( fMessageTable.count(keytype) == 1 ) {
240 if ( stream_option.find(
"==") != std::string::npos || stream_option.find(
"Init") != std::string::npos )
241 fMessageTable[keytype] = tmpp;
245 if ( fMessageTable.count(keytype) == 0 ) {
246 if ( stream_option.find(
"+") != std::string::npos || stream_option.find(
"Init") != std::string::npos )
247 fMessageTable[keytype] = tmpp;
258 Bool_t found =
false;
261 std::map<std::string,std::pair<UInt_t,UInt_t> >::iterator im;
263 for (im = fMessageTable.begin() ; im != fMessageTable.end() ; im++ ) {
264 if ( im->first == keyName ) {
265 message = im->second.first; mask = im->second.second;
272 for (im = fHardcodedMessageTable.begin() ; im != fHardcodedMessageTable.end() ; im++ ) {
273 if ( im->first == keyName ) {
274 message = im->second.first; mask = im->second.second;
286 const char *st = 0x0;
289 std::map<std::string,std::pair<UInt_t,UInt_t> >::iterator im;
291 for (im = fMessageTable.begin() ; im != fMessageTable.end() ; im++ ) {
292 if ( im->second.first == message ) {
293 st = im->first.c_str();
295 if ( fIsPatchEvent && im->first ==
"data:eb" )
296 st =
"event:data:psa";
297 if ( fIsPatchEvent && im->first ==
"data:merger" )
303 for (im = fHardcodedMessageTable.begin() ; im != fHardcodedMessageTable.end() ; im++ ) {
304 if ( im->second.first == message ) {
305 st = im->first.c_str();
310 return st ? st :
"UnknownKey";
318 if ( fMessageTable.size() > 0 ) {
320 std::map<std::string,std::pair<UInt_t,UInt_t> >::iterator im;
321 for (im = fMessageTable.begin() ; im != fMessageTable.end() ; im++ ) {
322 out << im->first <<
"\t\t"
323 << std::hex << im->second.first <<
"\t" << im->second.second << std::dec <<
" \n" ;
virtual void SetLevel(ELevel lev, unsigned short verbosity=0u)
To get the current level of the message.
virtual void Reset(const Char_t *="")
Reset the table.
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
virtual Short_t GetVersion() const
to get the curent version of this object
virtual BaseBuffer::EEndian GetEndian() const
Endian type for the keys delivered by this factory.
Short_t GetMaxVersion() const
this class could managed moddification of the versionned part up to MaxVersion : should be set in the...
virtual Bool_t DoConfigure(std::ostream &)
write the message table
LogMessage & error(LogMessage &)
virtual Bool_t ProcessLine(const std::string &)
During configuration, process a single line.
virtual void Print(std::ostream &out=std::cout) const
Print the content of the key.
virtual Bool_t Convert(const Key *akey)
convert a key to another key ... not an easy task ... use it carefully
virtual ULong64_t GetTimeStamp() const =0
To set the timestamp.
virtual Key * DoNew(const FactoryItem &)
Ask this factory for a new AgataKey.
virtual UInt_t GetEventNumber() const =0
To get the event number encoded.
Short_t GetFactoryVersion() const
Ask the factory version.
Base class for version numbers.
virtual UInt_t GetDataLength() const
bool IsDebug(short debug_to_test) const
to test if the required debug level is lower that the global one
LogMessage & nline(LogMessage &)
LogMessage fLog
the log messenger ... to know the object hae been properly intitialised/modified
header file for AgataKeyFactory.cpp
virtual void ChangeType(UInt_t messtype, UInt_t messmask)
to modify the Agata type for this key
UShort_t GetMinor() const
Version GetVersion() const
Version GetVersion() const
virtual Bool_t Convert(const Key *akey)
convert a key to another key ... not an easy task ... use it carefully
virtual const Char_t * GetStreamOption() const
get/set option
virtual UInt_t GetFrameLength() const
virtual void SetMessage(UInt_t)=0
To set the message type.
const std::string & GetItemName() const
Bool_t AddRecord(std::ostream &, char t= 'b')
Add a begin or end of record, return true if done.
Bool_t GetMessage(std::string keyName, UInt_t &message, UInt_t &mask)
to check if a given keyname is in the list of known keys (return true in this case, false otherwise) and to access the corresponding message type, mask
Base class for a AgataKeyFactory.
Base class for any KeyFactory implementation.
Base class that described an item in a Factory.
virtual UInt_t GetMessage() const =0
To get the message type encoded.
UShort_t GetMajor() const