The Gaudi Framework  master (594c33fa)
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 = implements< Interfaces... >
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 

Public Member Functions

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

Protected Member Functions

virtual ~EventSelectorDataStream ()=default
 Standard Destructor. More...
 

Protected Attributes

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

Friends

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

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 55 of file EventSelectorDataStream.h.

Member Typedef Documentation

◆ Properties

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 45 of file EventSelectorDataStream.cpp.

46  : m_name{ std::move( nam ) }, m_definition{ std::move( def ) }, m_pSvcLocator( svcloc ) {}

Member Function Documentation

◆ criteria()

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

Retrieve stream criteria.

Definition at line 104 of file EventSelectorDataStream.h.

104 { return m_criteria; }

◆ dbName()

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

Retrieve stream dbName.

Definition at line 106 of file EventSelectorDataStream.h.

106 { return m_dbName; }

◆ definition()

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

Retrieve definition string.

Definition at line 110 of file EventSelectorDataStream.h.

110 { return m_definition; }

◆ finalize()

StatusCode EventSelectorDataStream::finalize ( )
virtual

Finalize stream and release resources.

Definition at line 189 of file EventSelectorDataStream.cpp.

189  {
190  setSelector( nullptr );
192  m_initialized = false;
193  return StatusCode::SUCCESS;
194 }

◆ initialize()

StatusCode EventSelectorDataStream::initialize ( )
virtual

Parse input criteria.

Definition at line 66 of file EventSelectorDataStream.cpp.

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

◆ isInitialized()

bool EventSelectorDataStream::isInitialized ( ) const
inline

Check initialization status.

Definition at line 114 of file EventSelectorDataStream.h.

114 { return m_initialized; }

◆ name()

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

Retrieve stream name.

Definition at line 102 of file EventSelectorDataStream.h.

102 { return m_name; }

◆ properties()

const Properties& EventSelectorDataStream::properties ( )
inline

Access properties.

Definition at line 100 of file EventSelectorDataStream.h.

100 { 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 52 of file EventSelectorDataStream.cpp.

52  {
54  [&]( const Gaudi::Property<std::string>& j ) { return j.name() == nam; } );
55  return i != std::end( m_properties ) ? &( *i ) : nullptr;
56 }

◆ 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 59 of file EventSelectorDataStream.cpp.

59  {
61  [&]( const Gaudi::Property<std::string>& j ) { return j.name() == nam; } );
62  return i != std::end( m_properties ) ? &( *i ) : nullptr;
63 }

◆ selector()

IEvtSelector* EventSelectorDataStream::selector ( ) const
inline

Retrieve event selector object.

Definition at line 112 of file EventSelectorDataStream.h.

112 { return m_pSelector.get(); }

◆ selectorType()

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

Retrieve event selector type.

Definition at line 108 of file EventSelectorDataStream.h.

108 { return m_selectorType; }

◆ setSelector()

void EventSelectorDataStream::setSelector ( IEvtSelector pSelector)
virtual

Attach event selector object.

Definition at line 49 of file EventSelectorDataStream.cpp.

49 { m_pSelector = pSelector; }

Friends And Related Function Documentation

◆ operator<< [1/2]

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

Output friend for MsgStream.

Definition at line 35 of file EventSelectorDataStream.cpp.

35  {
36  return s << "Stream:" << obj.name() << " Def:" << obj.definition();
37 }

◆ operator<< [2/2]

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

Output friend for standard I/O.

Definition at line 40 of file EventSelectorDataStream.cpp.

40  {
41  return s << "Stream:" << obj.name() << " Def:" << obj.definition();
42 }

Member Data Documentation

◆ m_criteria

std::string EventSelectorDataStream::m_criteria
protected

Criteria.

Definition at line 70 of file EventSelectorDataStream.h.

◆ m_dbName

std::string EventSelectorDataStream::m_dbName
protected

String with name of the db as parsed.

Definition at line 72 of file EventSelectorDataStream.h.

◆ m_definition

std::string EventSelectorDataStream::m_definition
protected

Definition string.

Definition at line 68 of file EventSelectorDataStream.h.

◆ m_initialized

bool EventSelectorDataStream::m_initialized = false
protected

Initialization state.

Definition at line 82 of file EventSelectorDataStream.h.

◆ m_name

std::string EventSelectorDataStream::m_name
protected

Name.

Definition at line 66 of file EventSelectorDataStream.h.

◆ m_properties

Properties EventSelectorDataStream::m_properties
protected

Properties vector.

Definition at line 80 of file EventSelectorDataStream.h.

◆ m_pSelector

SmartIF<IEvtSelector> EventSelectorDataStream::m_pSelector
protected

Pointer to valid selector.

Definition at line 76 of file EventSelectorDataStream.h.

◆ m_pSvcLocator

ISvcLocator* EventSelectorDataStream::m_pSvcLocator
protected

Reference to service locator.

Definition at line 78 of file EventSelectorDataStream.h.

◆ m_selectorType

std::string EventSelectorDataStream::m_selectorType
protected

Event selector type.

Definition at line 74 of file EventSelectorDataStream.h.


The documentation for this class was generated from the following files:
EventSelectorDataStream::m_definition
std::string m_definition
Definition string.
Definition: EventSelectorDataStream.h:68
toupper
void toupper(std::string &s)
Definition: ExceptionSvc.cpp:36
std::string
STL class.
IDataManagerSvc
Definition: IDataManagerSvc.h:55
std::move
T move(T... args)
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
gaudirun.s
string s
Definition: gaudirun.py:346
std::string::find
T find(T... args)
EventSelectorDataStream::definition
const std::string & definition() const
Retrieve definition string.
Definition: EventSelectorDataStream.h:110
EventSelectorDataStream::m_name
std::string m_name
Name.
Definition: EventSelectorDataStream.h:66
EventSelectorDataStream::m_selectorType
std::string m_selectorType
Event selector type.
Definition: EventSelectorDataStream.h:74
EventSelectorDataStream::m_pSvcLocator
ISvcLocator * m_pSvcLocator
Reference to service locator.
Definition: EventSelectorDataStream.h:78
std::vector::clear
T clear(T... args)
EventSelectorDataStream::setSelector
virtual void setSelector(IEvtSelector *pSelector)
Attach event selector object.
Definition: EventSelectorDataStream.cpp:49
StatusCode
Definition: StatusCode.h:65
ProduceConsume.j
j
Definition: ProduceConsume.py:101
std::cout
std::string::compare
T compare(T... args)
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:97
SmartIF< INamedInterface >
IOTest.sel
sel
Definition: IOTest.py:106
EventSelectorDataStream::m_properties
Properties m_properties
Properties vector.
Definition: EventSelectorDataStream.h:80
EventSelectorDataStream::m_criteria
std::string m_criteria
Criteria.
Definition: EventSelectorDataStream.h:70
std::string::substr
T substr(T... args)
std::vector::emplace_back
T emplace_back(T... args)
IPersistencySvc
Definition: IPersistencySvc.h:29
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
std::endl
T endl(T... args)
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:86
EventSelectorDataStream::name
const std::string & name() const
Retrieve stream name.
Definition: EventSelectorDataStream.h:102
std::begin
T begin(T... args)
EventSelectorDataStream::m_dbName
std::string m_dbName
String with name of the db as parsed.
Definition: EventSelectorDataStream.h:72
std::string::empty
T empty(T... args)
EventSelectorDataStream::m_pSelector
SmartIF< IEvtSelector > m_pSelector
Pointer to valid selector.
Definition: EventSelectorDataStream.h:76
std::end
T end(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
Gaudi::Utils::AttribStringParser
Parse attribute strings allowing iteration over the various attributes.
Definition: AttribStringParser.h:40
Gaudi::Property< std::string >
EventSelectorDataStream::m_initialized
bool m_initialized
Initialization state.
Definition: EventSelectorDataStream.h:82
IConversionSvc
Definition: IConversionSvc.h:47