2 #include "GaudiKernel/IRegistry.h"
3 #include "GaudiKernel/IAlgManager.h"
4 #include "GaudiKernel/ISvcLocator.h"
5 #include "GaudiKernel/IConversionSvc.h"
6 #include "GaudiKernel/IDataManagerSvc.h"
7 #include "GaudiKernel/IDataProviderSvc.h"
8 #include "GaudiKernel/IPersistencySvc.h"
9 #include "GaudiKernel/IOpaqueAddress.h"
10 #include "GaudiKernel/Incident.h"
11 #include "GaudiKernel/IIncidentSvc.h"
13 #include "GaudiKernel/MsgStream.h"
14 #include "GaudiKernel/strcasecmp.h"
15 #include "GaudiKernel/DataObject.h"
16 #include "GaudiKernel/DataStoreItem.h"
17 #include "GaudiKernel/AttribStringParser.h"
27 #define ON_DEBUG if (log.level() <= MSG::DEBUG)
150 for ( ItemNames::const_iterator
i = a->second.begin();
151 i != a->second.end(); ++
i )
237 if ( sel->begin() != sel->end() )
244 for ( IDataSelector::iterator j = sel->begin(); j != sel->end(); ++j )
257 catch (
const std::exception & excpt )
260 const std::string loc = ( (*j)->registry() ?
261 (*j)->registry()->identifier() :
"UnRegistered" );
263 <<
"std::exception during createRep for '" << loc <<
"' "
270 for ( IDataSelector::iterator j = sel->begin(); j != sel->end(); ++j )
281 catch (
const std::exception & excpt )
284 const std::string loc = ( (*j)->registry() ?
285 (*j)->registry()->identifier() :
"UnRegistered" );
287 <<
"std::exception during fillRepRefs for '" << loc <<
"'"
311 if ( level < m_currentItem->depth() ) {
312 if ( dir->
object() != 0 ) {
344 log <<
MSG::ERROR <<
"Cannot write mandatory object(s) (Not found) "
360 log <<
MSG::DEBUG <<
"Ignore request to write non-mandatory object(s) "
370 const Items& items = iAlgItems->second;
375 for ( Items::const_iterator
i = items.begin();
i != items.end(); ++
i )
383 if ( !iret.
isSuccess() ) { status = iret; }
387 log <<
MSG::ERROR <<
"Cannot write mandatory (algorithm dependent) object(s) (Not found) "
398 std::set<DataObject*> unique;
399 std::vector<DataObject*> tmp;
401 for (std::vector<DataObject*>::iterator o =
m_objects.begin(); o !=
m_objects.end(); ++o) {
402 if (!unique.count(*o)) {
421 for ( Items::iterator
i = itms.begin();
i != itms.end();
i++ ) {
424 itms.erase(itms.begin(), itms.end());
431 if ( (*i)->path() ==
path )
return (*
i);
434 if ( (*j)->path() ==
path )
return (*j);
443 size_t sep = descriptor.rfind(
"#");
444 std::string obj_path (descriptor,0,sep);
445 std::string slevel (descriptor,sep+1,descriptor.length());
446 if ( slevel ==
"*" ) {
450 level = atoi(slevel.c_str());
453 size_t idx = obj_path.find(
"/",1);
454 while(idx != std::string::npos) {
455 std::string sub_item = obj_path.substr(0,idx);
459 idx = obj_path.find(
"/",idx+1);
465 <<
" with " << item->
depth()
466 <<
" level(s)." <<
endmsg;
467 itms.push_back( item );
475 std::string dbType, svc, shr;
476 for(
auto attrib: Gaudi::Utils::AttribStringParser(
m_output)) {
477 const std::string& tag = attrib.tag;
478 const std::string& val = attrib.value;
488 case 'V': svc = val;
break;
489 case 'H': shr =
"YES";
break;
495 if ( ::strncasecmp(val.c_str(),
"RECREATE",3)==0 )
497 else if ( ::strncasecmp(val.c_str(),
"READ",3)==0 )
522 if ( dbType.length() > 0 || svc.length() > 0 ) {
523 std::string typ = dbType.length()>0 ? dbType : svc;
532 log <<
MSG::FATAL <<
"Unable to locate IConversionSvc interface of database type " << typ <<
endmsg;
541 <<
"Unable to locate IConversionSvc interface (Unknown technology) " <<
endmsg
542 <<
"You either have to specify a technology name or a service name!" <<
endmsg
543 <<
"Please correct the job option \"" <<
name() <<
".Output\" !" <<
endmsg;
560 "OutputStream::acceptAlgsHandler",sc);
575 "OutputStream::requireAlgsHandler",sc);
590 "OutputStream::vetoAlgsHandler",sc);
626 <<
"Failed to decode Algorithm name " << theName <<
endmsg;
633 std::vector<Algorithm*>* theAlgs )
641 const std::vector<std::string> nameList = theNames.
value( );
642 for ( std::vector<std::string>::const_iterator it = nameList.begin();
643 it != nameList.end(); ++it )
650 for ( std::vector<Algorithm*>::iterator ita = theAlgs->begin();
651 ita != theAlgs->end(); ++ita )
654 if ( theAlgorithm == existAlgorithm )
663 theAlgs->push_back( theAlgorithm );
679 typedef std::vector<Algorithm*>::iterator AlgIter;
689 if ( (*i)->isExecuted() && (*i)->filterPassed() ) {
702 if ( !(*i)->isExecuted() || !(*i)->filterPassed() ) {
715 if ( (*i)->isExecuted() && (*i)->filterPassed() ) {
StringArrayProperty m_acceptNames
Vector of names of Algorithms that this stream accepts.
StatusCode decodeAlgorithms(StringArrayProperty &theNames, std::vector< Algorithm * > *theAlgs)
Decode specified list of Algorithms.
bool isEventAccepted() const
Test whether this event should be output.
virtual SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
Definition of the MsgStream class used to transmit messages.
void clearItems(Items &itms)
Clear item list.
virtual bool hasInput() const
Tell if the instance has been configured with input items or not.
Small smart pointer class with automatic reference counting for IInterface.
Define general base for Gaudi exception.
StatusCode decodeRequireAlgs()
Decode list of Algorithms that this stream requires.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
IDataSelector m_objects
Collection of objects being selected.
int depth() const
Accessor: Retrieve load depth.
std::string m_storeName
Name of the service managing the data store.
SmartIF< ISvcLocator > & serviceLocator() const
The standard service locator.
int m_events
Number of events written to this output stream.
virtual StatusCode addPreLoadItem(const DataStoreItem &item)=0
Add an item to the preload list.
virtual bool filterPassed() const
Did this algorithm pass or fail its filter criterion for the last event?
std::string m_outputType
Output type: NEW(NEW,CREATE,WRITE,RECREATE), UPDATE)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
DataStoreItem * m_currentItem
Keep track of the current item.
bool isSuccess() const
Test for a status code of SUCCESS.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
StringArrayProperty m_vetoNames
Vector of names of Algorithms that this stream is vetoed by.
virtual bool isExecuted() const
Has this algorithm been executed since the last reset?
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
std::string m_outputName
Name of the output file.
void requireAlgsHandler(Property &theProp)
Handler for RequireAlgs Property.
std::string m_persName
Name of the persistency service capable to write data from the store.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
IDataSelector * selectedObjects()
Return the list of selected objects.
std::vector< DataObject * > IDataSelector
This is only a placeholder to allow me compiling until the responsible guy does his work! M...
virtual StatusCode execute()
Working entry point.
SmartIF< IDataProviderSvc > m_pDataProvider
Keep reference to the data provider service.
virtual StatusCode getService(long service_type, IConversionSvc *&refpSvc)=0
Retrieve conversion service identified by technology.
AlgDependentItemNames m_algDependentItemList
Mapping between algorithm names, and a list of items for which, if the algorithm in question accepted...
Description of the DataStoreItem class.
bool isFailure() const
Test for a status code of FAILURE.
const std::string & path() const
Accessor: Retrieve load path.
A small to stream Data I/O.
virtual bool collect(IRegistry *dir, int level)
Store agent's classback.
TYPE * get() const
Get interface pointer.
DataStoreItem * findItem(const std::string &path)
Find single item identified by its path (exact match)
virtual void declareUpdateHandler(PropertyCallbackFunctor *pf)
set new callback for update
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
virtual StatusCode writeObjects()
Select the different objects and write them to file.
SmartIF< IConversionSvc > m_pConversionSvc
Keep reference to the data conversion service.
virtual StatusCode connectOutput(const std::string &outputFile)=0
Connect the output file to the service.
const std::string EndOutputFile
an output file has been finished
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
virtual StatusCode connectConversionSvc()
AlgDependentItems m_algDependentItems
Items to be saved for specific algorithms.
virtual StatusCode commitOutput(const std::string &outputFile, bool do_commit)=0
Commit pending output.
bool m_verifyItems
Flag to indicate that item consistency should be checked.
std::vector< DataStoreItem * > Items
#define DECLARE_COMPONENT(type)
OutputStreamAgent * m_agent
Keep reference of agent.
This class is used for returning status codes from appropriate routines.
virtual StatusCode finalize()
Terminate OutputStream.
Items m_itemList
Vector of items to be saved to this stream.
bool m_doPreLoad
Flag indicating whether data pre-loading should be performed.
virtual const std::string & name() const
The identifying name of the algorithm object.
void addItem(Items &itms, const std::string &descriptor)
Add item to output streamer list.
bool m_doPreLoadOpt
Flag indicating whether optional items should be preloaded.
std::vector< Algorithm * > * m_requireAlgs
Vector of Algorithms that this stream requires.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
SmartIF< IDataManagerSvc > m_pDataManager
Keep reference to the data manager service.
std::vector< Algorithm * > * m_acceptAlgs
Vector of Algorithms that this stream accepts.
void clearSelection()
Clear list of selected objects.
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
const TYPE & value() const
explicit conversion
virtual DataObject * object() const =0
Retrieve object behind the link.
StatusCode decodeVetoAlgs()
Decode list of Algorithms that this stream is vetoed by.
void reset(TYPE *ptr=0)
Set the internal pointer to the passed one disposing of the old one.
virtual ~OutputStream()
Standard Destructor.
Base class from which all concrete algorithm classes should be derived.
ItemNames m_itemNames
Vector of item names.
Property base class allowing Property* collections to be "homogeneous".
ItemNames m_optItemNames
Vector of item names.
bool isValid() const
Allow for check if smart pointer is valid.
virtual void setAddress(IOpaqueAddress *pAddress)=0
Set/Update Opaque storage address.
Base class for all Incidents (computing events).
void acceptAlgsHandler(Property &theProp)
Handler for AcceptAlgs Property.
StringArrayProperty m_requireNames
Vector of names of Algorithms that this stream requires.
Algorithm * decodeAlgorithm(const std::string &theName)
Decode a single algorithm name.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
OutputStream(const std::string &name, ISvcLocator *pSvcLocator)
Standard algorithm Constructor.
const std::string WroteToOutputFile
the output file was written to in this event
const std::string FailOutputFile
could not create or write to this file
StatusCode service(const std::string &name, T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Opaque address interface definition.
std::string m_output
Name of the output file specification.
std::vector< Algorithm * > * m_vetoAlgs
Vector of Algorithms that this stream is vetoed by.
virtual StatusCode traverseSubTree(const std::string &sub_path, IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects below the sub tree identified by its full path name...
A DataObject is the base class of any identifiable object on any data store.
virtual StatusCode collectObjects()
Collect all objects to be written to the output stream.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
virtual StatusCode initialize()
Initialize OutputStream.
void toupper(std::string &s)
void vetoAlgsHandler(Property &theProp)
Handler for VetoAlgs Property.
StatusCode decodeAcceptAlgs()
Decode list of Algorithms that this stream accepts.
bool m_fireIncidents
should I fire incidents for writing opening/closing etc?
Items m_optItemList
Vector of optional items to be saved to this stream.
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.