The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
EventSelectorDataStream Class Reference

Definition of class EventSelectorDataStream. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/EventSelectorDataStream.h>

Inheritance diagram for EventSelectorDataStream:
Collaboration diagram for EventSelectorDataStream:

Public Types

typedef std::vector< Gaudi::Property< std::string > > Properties
 
- Public Types inherited from implements< IInterface >
using base_class
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
using iids
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 

Public Member Functions

 EventSelectorDataStream (std::string nam, std::string def, ISvcLocator *svcloc)
 Standard Constructor.
 
virtual void setSelector (IEvtSelector *pSelector)
 Attach event selector object.
 
virtual StatusCode initialize ()
 Parse input criteria.
 
virtual StatusCode finalize ()
 Finalize stream and release resources.
 
Gaudi::Property< std::string > * property (const std::string &nam)
 Allow access to individual properties by name.
 
const Gaudi::Property< std::string > * property (const std::string &nam) const
 Allow access to individual properties by name (CONST)
 
const Propertiesproperties ()
 Access properties.
 
const std::string & name () const
 Retrieve stream name.
 
const std::string & criteria () const
 Retrieve stream criteria.
 
const std::string & dbName () const
 Retrieve stream dbName.
 
const std::string & selectorType () const
 Retrieve event selector type.
 
const std::string & definition () const
 Retrieve definition string.
 
IEvtSelectorselector () const
 Retrieve event selector object.
 
bool isInitialized () const
 Check initialization status.
 
- Public Member Functions inherited from implements< IInterface >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
 implements ()=default
 Default constructor.
 
 implements (const implements &)
 Copy constructor (zero the reference count)
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count).
 
unsigned long addRef () const override
 Reference Interface instance.
 
unsigned long release () const override
 Release Interface instance.
 
unsigned long refCount () const override
 Current reference count.
 

Protected Member Functions

virtual ~EventSelectorDataStream ()=default
 Standard Destructor.
 
- Protected Member Functions inherited from implements< IInterface >
unsigned long decRef () const override
 

Protected Attributes

std::string m_name
 Name.
 
std::string m_definition
 Definition string.
 
std::string m_criteria
 Criteria.
 
std::string m_dbName
 String with name of the db as parsed.
 
std::string m_selectorType
 Event selector type.
 
SmartIF< IEvtSelectorm_pSelector
 Pointer to valid selector.
 
ISvcLocatorm_pSvcLocator
 Reference to service locator.
 
Properties m_properties
 Properties vector.
 
bool m_initialized = false
 Initialization state.
 
- Protected Attributes inherited from implements< IInterface >
std::atomic_ulong m_refCount
 Reference counter.
 

Friends

MsgStreamoperator<< (MsgStream &s, const EventSelectorDataStream &obj)
 Output friend for MsgStream.
 
std::ostream & operator<< (std::ostream &s, const EventSelectorDataStream &obj)
 Output friend for standard I/O.
 

Detailed Description

Definition of class EventSelectorDataStream.

Small class which eases the management of multiple input streams for the event selector.

History: +------—+-------------------------------------------—+---------—+ | Date | Comment | Who | +------—+-------------------------------------------—+---------—+ | 3/10/00 | Initial version | M.Frank | +------—+-------------------------------------------—+---------—+ | 4/09/09 | Added m_dbName and dbName() | R. Lambert | +------—+-------------------------------------------—+---------—+

Author
Markus Frank
R. Lambert
Version
1.0

Definition at line 39 of file EventSelectorDataStream.h.

Member Typedef Documentation

◆ Properties

typedef std::vector<Gaudi::Property<std::string> > EventSelectorDataStream::Properties

Definition at line 46 of file EventSelectorDataStream.h.

Constructor & Destructor Documentation

◆ ~EventSelectorDataStream()

virtual EventSelectorDataStream::~EventSelectorDataStream ( )
protectedvirtualdefault

Standard Destructor.

◆ EventSelectorDataStream()

EventSelectorDataStream::EventSelectorDataStream ( std::string nam,
std::string def,
ISvcLocator * svcloc )

Standard Constructor.

Definition at line 31 of file EventSelectorDataStream.cpp.

32 : m_name{ std::move( nam ) }, m_definition{ std::move( def ) }, m_pSvcLocator( svcloc ) {}
std::string m_definition
Definition string.
ISvcLocator * m_pSvcLocator
Reference to service locator.

Member Function Documentation

◆ criteria()

const std::string & EventSelectorDataStream::criteria ( ) const
inline

Retrieve stream criteria.

Definition at line 88 of file EventSelectorDataStream.h.

88{ return m_criteria; }
std::string m_criteria
Criteria.

◆ dbName()

const std::string & EventSelectorDataStream::dbName ( ) const
inline

Retrieve stream dbName.

Definition at line 90 of file EventSelectorDataStream.h.

90{ return m_dbName; }
std::string m_dbName
String with name of the db as parsed.

◆ definition()

const std::string & EventSelectorDataStream::definition ( ) const
inline

Retrieve definition string.

Definition at line 94 of file EventSelectorDataStream.h.

94{ return m_definition; }

◆ finalize()

StatusCode EventSelectorDataStream::finalize ( )
virtual

Finalize stream and release resources.

Definition at line 175 of file EventSelectorDataStream.cpp.

175 {
176 setSelector( nullptr );
177 m_properties.clear();
178 m_initialized = false;
179 return StatusCode::SUCCESS;
180}
Properties m_properties
Properties vector.
virtual void setSelector(IEvtSelector *pSelector)
Attach event selector object.
bool m_initialized
Initialization state.
constexpr static const auto SUCCESS
Definition StatusCode.h:99

◆ initialize()

StatusCode EventSelectorDataStream::initialize ( )
virtual

Parse input criteria.

Definition at line 52 of file EventSelectorDataStream.cpp.

52 {
53 bool isData = true;
54 std::string auth, dbtyp, collsvc, item, crit, sel, svc, stmt;
55 std::string cnt = "/Event";
56 std::string db = "<Unknown>";
57
58 auto eds = m_pSvcLocator->service<IDataManagerSvc>( "EventDataSvc" );
59 if ( !eds ) {
60 std::cout << "ERROR: Unable to localize interface IDataManagerSvc from service EventDataSvc" << std::endl;
62 } else {
63 cnt = eds->rootName();
64 }
66 m_properties.clear();
67
68 using Parser = Gaudi::Utils::AttribStringParser;
69 for ( auto attrib : Parser( m_definition ) ) {
70 long hash = -1;
71 switch ( ::toupper( attrib.tag[0] ) ) {
72 case 'A':
73 auth = std::move( attrib.value );
74 break;
75 case 'C':
76 svc = "EvtTupleSvc";
77 isData = false;
78 [[fallthrough]];
79 case 'E':
80 hash = attrib.value.find( '#' );
81 if ( hash > 0 ) {
82 cnt = attrib.value.substr( 0, hash );
83 item = attrib.value.substr( hash + 1 );
84 } else {
85 cnt = std::move( attrib.value );
86 item = "Address";
87 }
88 break;
89 case 'D':
90 m_criteria = "FILE " + attrib.value;
91 m_dbName = std::move( attrib.value );
92 break;
93 case 'F':
94 switch ( ::toupper( attrib.tag[1] ) ) {
95 case 'I':
96 m_criteria = "FILE " + attrib.value;
97 m_dbName = std::move( attrib.value );
98 break;
99 case 'U':
100 stmt = std::move( attrib.value );
101 break;
102 default:
103 break;
104 }
105 break;
106 case 'J':
107 m_criteria = "JOBID " + attrib.value;
108 m_dbName = std::move( attrib.value );
109 dbtyp = "SICB";
110 break;
111 case 'T':
112 switch ( ::toupper( attrib.tag[1] ) ) {
113 case 'Y':
114 dbtyp = std::move( attrib.value );
115 break;
116 default:
117 break;
118 }
119 break;
120 case 'S':
121 switch ( ::toupper( attrib.tag[1] ) ) {
122 case 'E':
123 sel = std::move( attrib.value );
124 break;
125 case 'V':
126 svc = std::move( attrib.value );
127 collsvc = svc;
128 break;
129 default:
130 break;
131 }
132 break;
133 default:
134 m_properties.emplace_back( attrib.tag, attrib.value );
135 break;
136 }
137 }
138 if ( !isData ) { // Unfortunately options do not come in order...
139 m_selectorType = "EventCollectionSelector";
140 svc = "EvtTupleSvc";
141 } else if ( dbtyp.compare( 0, 4, "POOL" ) == 0 ) {
142 m_selectorType = "PoolDbEvtSelector";
143 } else if ( svc.empty() ) {
144 m_selectorType = "DbEvtSelector";
145 } else {
146 m_selectorType = svc;
147 }
148 StatusCode status = StatusCode::SUCCESS;
149 if ( svc.empty() && !dbtyp.empty() ) {
150 auto ipers = m_pSvcLocator->service<IPersistencySvc>( "EventPersistencySvc" );
151 if ( ipers ) {
152 IConversionSvc* icnvSvc = nullptr;
153 status = ipers->getService( dbtyp, icnvSvc );
154 if ( status.isSuccess() ) {
155 auto isvc = SmartIF<INamedInterface>{ icnvSvc };
156 if ( isvc ) svc = isvc->name();
157 }
158 }
159 }
160 m_properties.emplace_back( "Function", stmt );
161 m_properties.emplace_back( "CnvService", svc );
162 m_properties.emplace_back( "Authentication", auth );
163 m_properties.emplace_back( "Container", cnt );
164 m_properties.emplace_back( "Item", item );
165 m_properties.emplace_back( "Criteria", sel );
166 m_properties.emplace_back( "DbType", dbtyp );
167 m_properties.emplace_back( "DB", m_criteria );
168 if ( !isData && !collsvc.empty() ) { m_properties.emplace_back( "DbService", collsvc ); }
169
170 m_initialized = status.isSuccess();
171 return status;
172}
void toupper(std::string &s)
std::string m_selectorType
Event selector type.
bool isSuccess() const
Definition StatusCode.h:314
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ isInitialized()

bool EventSelectorDataStream::isInitialized ( ) const
inline

Check initialization status.

Definition at line 98 of file EventSelectorDataStream.h.

98{ return m_initialized; }

◆ name()

const std::string & EventSelectorDataStream::name ( ) const
inline

Retrieve stream name.

Definition at line 86 of file EventSelectorDataStream.h.

86{ return m_name; }

◆ properties()

const Properties & EventSelectorDataStream::properties ( )
inline

Access properties.

Definition at line 84 of file EventSelectorDataStream.h.

84{ return m_properties; }

◆ property() [1/2]

Gaudi::Property< std::string > * EventSelectorDataStream::property ( const std::string & nam)

Allow access to individual properties by name.

Definition at line 38 of file EventSelectorDataStream.cpp.

38 {
39 auto i = std::find_if( std::begin( m_properties ), std::end( m_properties ),
40 [&]( const Gaudi::Property<std::string>& j ) { return j.name() == nam; } );
41 return i != std::end( m_properties ) ? &( *i ) : nullptr;
42}
const std::string name() const
property name

◆ property() [2/2]

const Gaudi::Property< std::string > * EventSelectorDataStream::property ( const std::string & nam) const

Allow access to individual properties by name (CONST)

Definition at line 45 of file EventSelectorDataStream.cpp.

45 {
46 auto i = std::find_if( std::begin( m_properties ), std::end( m_properties ),
47 [&]( const Gaudi::Property<std::string>& j ) { return j.name() == nam; } );
48 return i != std::end( m_properties ) ? &( *i ) : nullptr;
49}

◆ selector()

IEvtSelector * EventSelectorDataStream::selector ( ) const
inline

Retrieve event selector object.

Definition at line 96 of file EventSelectorDataStream.h.

96{ return m_pSelector.get(); }
SmartIF< IEvtSelector > m_pSelector
Pointer to valid selector.

◆ selectorType()

const std::string & EventSelectorDataStream::selectorType ( ) const
inline

Retrieve event selector type.

Definition at line 92 of file EventSelectorDataStream.h.

92{ return m_selectorType; }

◆ setSelector()

void EventSelectorDataStream::setSelector ( IEvtSelector * pSelector)
virtual

Attach event selector object.

Definition at line 35 of file EventSelectorDataStream.cpp.

35{ m_pSelector = pSelector; }

Friends And Related Symbol Documentation

◆ operator<< [1/2]

MsgStream & operator<< ( MsgStream & s,
const EventSelectorDataStream & obj )
friend

Output friend for MsgStream.

Definition at line 21 of file EventSelectorDataStream.cpp.

21 {
22 return s << "Stream:" << obj.name() << " Def:" << obj.definition();
23}
const std::string & name() const
Retrieve stream name.
const std::string & definition() const
Retrieve definition string.

◆ operator<< [2/2]

std::ostream & operator<< ( std::ostream & s,
const EventSelectorDataStream & obj )
friend

Output friend for standard I/O.

Definition at line 26 of file EventSelectorDataStream.cpp.

26 {
27 return s << "Stream:" << obj.name() << " Def:" << obj.definition();
28}

Member Data Documentation

◆ m_criteria

std::string EventSelectorDataStream::m_criteria
protected

Criteria.

Definition at line 54 of file EventSelectorDataStream.h.

◆ m_dbName

std::string EventSelectorDataStream::m_dbName
protected

String with name of the db as parsed.

Definition at line 56 of file EventSelectorDataStream.h.

◆ m_definition

std::string EventSelectorDataStream::m_definition
protected

Definition string.

Definition at line 52 of file EventSelectorDataStream.h.

◆ m_initialized

bool EventSelectorDataStream::m_initialized = false
protected

Initialization state.

Definition at line 66 of file EventSelectorDataStream.h.

◆ m_name

std::string EventSelectorDataStream::m_name
protected

Name.

Definition at line 50 of file EventSelectorDataStream.h.

◆ m_properties

Properties EventSelectorDataStream::m_properties
protected

Properties vector.

Definition at line 64 of file EventSelectorDataStream.h.

◆ m_pSelector

SmartIF<IEvtSelector> EventSelectorDataStream::m_pSelector
protected

Pointer to valid selector.

Definition at line 60 of file EventSelectorDataStream.h.

◆ m_pSvcLocator

ISvcLocator* EventSelectorDataStream::m_pSvcLocator
protected

Reference to service locator.

Definition at line 62 of file EventSelectorDataStream.h.

◆ m_selectorType

std::string EventSelectorDataStream::m_selectorType
protected

Event selector type.

Definition at line 58 of file EventSelectorDataStream.h.


The documentation for this class was generated from the following files: