![]() |
|
|
Generated: 18 Jul 2008 |
#include <EventSelectorDataStream.h>
Inheritance diagram for 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 | +---------+----------------------------------------------+---------+
Definition at line 41 of file EventSelectorDataStream.h.
Public Types | |
| typedef std::vector< StringProperty > | Properties |
Public Member Functions | |
| EventSelectorDataStream (const std::string &nam, const std::string &def, ISvcLocator *svcloc) | |
| Standard Constructor. | |
| virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvUnknown) |
| Query interfaces of Interface. | |
| virtual unsigned long | addRef () |
| Reference Interface instance. | |
| virtual unsigned long | release () |
| Release Interface instance. | |
| virtual void | setSelector (IEvtSelector *pSelector) |
| Attach event selector object. | |
| virtual StatusCode | initialize () |
| Parse input criteria. | |
| virtual StatusCode | finalize () |
| Finalize stream and release resources. | |
| StringProperty * | property (const std::string &nam) |
| Allow access to individual properties by name. | |
| const StringProperty * | property (const std::string &nam) const |
| Allow access to individual properties by name (CONST). | |
| const Properties & | properties () |
| Access properties. | |
| const std::string & | name () const |
| Retrieve stream name. | |
| const std::string & | criteria () const |
| Retrieve stream criteria. | |
| const std::string & | selectorType () const |
| Retrieve event selector type. | |
| const std::string & | definition () const |
| Retrieve definition string. | |
| IEvtSelector * | selector () const |
| Retrieve event selector object. | |
| bool | isInitialized () const |
| Check initialisation status. | |
Protected Member Functions | |
| virtual | ~EventSelectorDataStream () |
| Standard Destructor. | |
Protected Attributes | |
| long | m_refCount |
| Reference count. | |
| std::string | m_name |
| Name. | |
| std::string | m_definition |
| Definition string. | |
| std::string | m_criteria |
| Criteria. | |
| std::string | m_selectorType |
| Event selector type. | |
| IEvtSelector * | m_pSelector |
| Pointer to valid selector. | |
| ISvcLocator * | m_pSvcLocator |
| Reference to service locator. | |
| Properties * | m_properties |
| Properties vector. | |
| bool | m_initialized |
| Initialization state. | |
Friends | |
| MsgStream & | operator<< (MsgStream &s, const EventSelectorDataStream &obj) |
| Output friend for MsgStream. | |
| std::ostream & | operator<< (std::ostream &s, const EventSelectorDataStream &obj) |
| Output friend for standard I/O. | |
Definition at line 47 of file EventSelectorDataStream.h.
| EventSelectorDataStream::~EventSelectorDataStream | ( | ) | [protected, virtual] |
Standard Destructor.
Definition at line 51 of file EventSelectorDataStream.cpp.
References m_properties, and setSelector().
00051 { 00052 setSelector(0); 00053 delete m_properties; 00054 }
| EventSelectorDataStream::EventSelectorDataStream | ( | const std::string & | nam, | |
| const std::string & | def, | |||
| ISvcLocator * | svcloc | |||
| ) |
Standard Constructor.
Definition at line 39 of file EventSelectorDataStream.cpp.
References m_definition, m_initialized, m_name, and m_properties.
00040 : m_refCount(0), 00041 m_pSelector(0), 00042 m_pSvcLocator(svcloc) 00043 { 00044 m_name = nam; 00045 m_definition = def; 00046 m_initialized = false; 00047 m_properties = new Properties(); 00048 }
| StatusCode EventSelectorDataStream::queryInterface | ( | const InterfaceID & | riid, | |
| void ** | ppvUnknown | |||
| ) | [virtual] |
Query interfaces of Interface.
| riid | ID of Interface to be retrieved | |
| ppvUnknown | Pointer to Location for interface pointer |
Implements IInterface.
Definition at line 72 of file EventSelectorDataStream.cpp.
References addRef(), IID_IInterface, IInterface::NO_INTERFACE, and IInterface::SUCCESS.
00072 { 00073 if ( riid == IID_IInterface ) { 00074 *ppvInterface = (IInterface*)this; 00075 } 00076 else { 00077 return NO_INTERFACE; 00078 } 00079 addRef(); 00080 return SUCCESS; 00081 }
| unsigned long EventSelectorDataStream::addRef | ( | ) | [virtual] |
Reference Interface instance.
Implements IInterface.
Definition at line 57 of file EventSelectorDataStream.cpp.
References m_refCount.
Referenced by queryInterface().
00057 { 00058 m_refCount++; 00059 return m_refCount; 00060 }
| unsigned long EventSelectorDataStream::release | ( | ) | [virtual] |
Release Interface instance.
Implements IInterface.
Definition at line 63 of file EventSelectorDataStream.cpp.
References count(), and m_refCount.
00063 { 00064 unsigned long count = --m_refCount; 00065 if( count <= 0) { 00066 delete this; 00067 } 00068 return count; 00069 }
| void EventSelectorDataStream::setSelector | ( | IEvtSelector * | pSelector | ) | [virtual] |
Attach event selector object.
Definition at line 84 of file EventSelectorDataStream.cpp.
References IInterface::addRef(), m_pSelector, and IInterface::release().
Referenced by finalize(), and ~EventSelectorDataStream().
00084 { 00085 if ( 0 != pSelector ) pSelector->addRef(); 00086 if ( 0 != m_pSelector ) m_pSelector->release(); 00087 m_pSelector = pSelector; 00088 }
| StatusCode EventSelectorDataStream::initialize | ( | ) | [virtual] |
Parse input criteria.
Definition at line 111 of file EventSelectorDataStream.cpp.
References Tokenizer::analyse(), std::vector< _Tp, _Alloc >::begin(), std::cout, std::basic_string< _CharT, _Traits, _Alloc >::empty(), std::vector< _Tp, _Alloc >::end(), std::endl(), std::vector< _Tp, _Alloc >::erase(), std::basic_string< _CharT, _Traits, _Alloc >::find(), ISvcLocator::getService(), IID_IPersistencySvc, IID_IService, StatusCode::isSuccess(), Tokenizer::items(), std::basic_string< _CharT, _Traits, _Alloc >::length(), m_criteria, m_definition, m_initialized, m_properties, m_pSvcLocator, m_selectorType, std::vector< _Tp, _Alloc >::push_back(), IInterface::release(), IDataManagerSvc::rootName(), ISvcLocator::service(), std::basic_string< _CharT, _Traits, _Alloc >::substr(), StatusCode::SUCCESS, and toupper().
00111 { 00112 bool isData = true; 00113 std::string auth, dbtyp, item, crit, sel, svc, stmt; 00114 std::string cnt = "/Event"; 00115 std::string db = "<Unknown>"; 00116 Tokenizer tok(true); 00117 00118 IDataManagerSvc* eds; 00119 StatusCode sc = m_pSvcLocator->service("EventDataSvc", eds); 00120 if( !sc.isSuccess() ) { 00121 std::cout << "ERROR: Unable to localize interface IID_IDataManagerSvc from service EventDataSvc" 00122 << std::endl; 00123 return sc; 00124 } 00125 else { 00126 cnt = eds->rootName(); 00127 } 00128 eds->release(); 00129 m_selectorType = m_criteria = ""; 00130 m_properties->erase(m_properties->begin(), m_properties->end()); 00131 00132 tok.analyse(m_definition, " ", "", "", "=", "'", "'"); 00133 for ( Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); i++ ) { 00134 long hash = -1; 00135 const std::string& tag = (*i).tag(); 00136 const std::string& val = (*i).value(); 00137 switch( ::toupper(tag[0]) ) { 00138 case 'A': 00139 auth = val; 00140 break; 00141 case 'C': 00142 svc = "EvtTupleSvc"; 00143 isData = false; 00144 case 'E': 00145 hash = val.find('#'); 00146 if ( hash > 0 ) { 00147 cnt = val.substr(0,hash); 00148 item = val.substr(hash+1, val.length()-hash-1); 00149 } 00150 else { 00151 cnt = val; 00152 item = "Address"; 00153 } 00154 break; 00155 case 'D': 00156 m_criteria = "FILE " + val; 00157 break; 00158 case 'F': 00159 switch( ::toupper(tag[1]) ) { 00160 case 'I': 00161 dbtyp = "SICB"; 00162 m_criteria = "FILE " + val; 00163 break; 00164 case 'U': 00165 stmt = val; 00166 break; 00167 default: 00168 break; 00169 } 00170 break; 00171 case 'J': 00172 m_criteria = "JOBID " + val; 00173 dbtyp = "SICB"; 00174 break; 00175 case 'T': 00176 switch( ::toupper(tag[1]) ) { 00177 case 'Y': 00178 dbtyp = val; 00179 break; 00180 case 'A': 00181 m_criteria = "TAPE " + val; 00182 dbtyp = "SICB"; 00183 break; 00184 default: 00185 break; 00186 } 00187 break; 00188 case 'S': 00189 switch( ::toupper(tag[1]) ) { 00190 case 'E': 00191 sel = val; 00192 break; 00193 case 'V': 00194 svc = val; 00195 break; 00196 default: 00197 break; 00198 } 00199 break; 00200 default: 00201 m_properties->push_back(StringProperty(tag,val)); 00202 break; 00203 } 00204 } 00205 if ( !isData ) { // Unfortunaltely options do not come in order... 00206 m_selectorType = "EventCollectionSelector"; 00207 } 00208 else if ( dbtyp == "SICB" ) { 00209 m_selectorType = "SicbEventSelector"; 00210 } 00211 else if ( dbtyp.substr(0,4) == "POOL" ) { 00212 m_selectorType = "PoolDbEvtSelector"; 00213 } 00214 else if ( svc.empty() ) { 00215 m_selectorType = "DbEvtSelector"; 00216 } 00217 else { 00218 m_selectorType = svc; 00219 } 00220 StatusCode status = StatusCode::SUCCESS; 00221 if ( svc.length() == 0 && dbtyp.length() != 0 ) { 00222 IPersistencySvc* ipers = 0; 00223 status = m_pSvcLocator->getService("EventPersistencySvc", IID_IPersistencySvc, *pp_cast<IInterface>(&ipers)); 00224 if ( status.isSuccess() ) { 00225 IConversionSvc* icnvSvc = 0; 00226 status = ipers->getService(dbtyp, icnvSvc); 00227 if ( status.isSuccess() ) { 00228 IService* isvc = 0; 00229 status = icnvSvc->queryInterface(IID_IService, pp_cast<void>(&isvc)); 00230 if ( status.isSuccess() ) { 00231 svc = isvc->name(); 00232 isvc->release(); 00233 } 00234 } 00235 } 00236 } 00237 m_properties->push_back( StringProperty("Function", stmt)); 00238 m_properties->push_back( StringProperty("CnvService", svc)); 00239 m_properties->push_back( StringProperty("Authentication",auth)); 00240 m_properties->push_back( StringProperty("Container", cnt)); 00241 m_properties->push_back( StringProperty("Item", item)); 00242 m_properties->push_back( StringProperty("Criteria", sel)); 00243 m_properties->push_back( StringProperty("DbType", dbtyp)); 00244 m_properties->push_back( StringProperty("DB", m_criteria)); 00245 m_initialized = status.isSuccess(); 00246 return status; 00247 }
| StatusCode EventSelectorDataStream::finalize | ( | ) | [virtual] |
Finalize stream and release resources.
Definition at line 250 of file EventSelectorDataStream.cpp.
References std::vector< _Tp, _Alloc >::clear(), m_initialized, m_properties, setSelector(), and StatusCode::SUCCESS.
00250 { 00251 setSelector(0); 00252 if ( m_properties ) { 00253 m_properties->clear(); 00254 } 00255 m_initialized = false; 00256 return StatusCode::SUCCESS; 00257 }
| StringProperty * EventSelectorDataStream::property | ( | const std::string & | nam | ) |
Allow access to individual properties by name.
Definition at line 91 of file EventSelectorDataStream.cpp.
References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), and m_properties.
00091 { 00092 for ( Properties::iterator i = m_properties->begin(); i != m_properties->end(); i++ ) { 00093 if ( (*i).name() == nam ) { 00094 return &(*i); 00095 } 00096 } 00097 return 0; 00098 }
| const StringProperty * EventSelectorDataStream::property | ( | const std::string & | nam | ) | const |
Allow access to individual properties by name (CONST).
Definition at line 101 of file EventSelectorDataStream.cpp.
References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), and m_properties.
00101 { 00102 for ( Properties::const_iterator i = m_properties->begin(); i != m_properties->end(); i++ ) { 00103 if ( (*i).name() == nam ) { 00104 return &(*i); 00105 } 00106 } 00107 return 0; 00108 }
| const Properties& EventSelectorDataStream::properties | ( | ) | [inline] |
Access properties.
Definition at line 92 of file EventSelectorDataStream.h.
References m_properties.
00092 { 00093 return *m_properties; 00094 }
| const std::string& EventSelectorDataStream::name | ( | ) | const [inline] |
Retrieve stream name.
Definition at line 96 of file EventSelectorDataStream.h.
References m_name.
Referenced by operator<<().
00096 { 00097 return m_name; 00098 }
| const std::string& EventSelectorDataStream::criteria | ( | ) | const [inline] |
Retrieve stream criteria.
Definition at line 100 of file EventSelectorDataStream.h.
References m_criteria.
00100 { 00101 return m_criteria; 00102 }
| const std::string& EventSelectorDataStream::selectorType | ( | ) | const [inline] |
Retrieve event selector type.
Definition at line 104 of file EventSelectorDataStream.h.
References m_selectorType.
00104 { 00105 return m_selectorType; 00106 }
| const std::string& EventSelectorDataStream::definition | ( | ) | const [inline] |
Retrieve definition string.
Definition at line 108 of file EventSelectorDataStream.h.
References m_definition.
Referenced by operator<<().
00108 { 00109 return m_definition; 00110 }
| IEvtSelector* EventSelectorDataStream::selector | ( | ) | const [inline] |
Retrieve event selector object.
Definition at line 112 of file EventSelectorDataStream.h.
References m_pSelector.
00112 { 00113 return m_pSelector; 00114 }
| bool EventSelectorDataStream::isInitialized | ( | ) | const [inline] |
Check initialisation status.
Definition at line 116 of file EventSelectorDataStream.h.
References m_initialized.
00116 { 00117 return m_initialized; 00118 }
| MsgStream& operator<< | ( | MsgStream & | s, | |
| const EventSelectorDataStream & | obj | |||
| ) | [friend] |
Output friend for MsgStream.
Definition at line 27 of file EventSelectorDataStream.cpp.
00027 { 00028 s << "Stream:" << obj.name() << " Def:" << obj.definition(); 00029 return s; 00030 }
| std::ostream& operator<< | ( | std::ostream & | s, | |
| const EventSelectorDataStream & | obj | |||
| ) | [friend] |
Output friend for standard I/O.
Definition at line 33 of file EventSelectorDataStream.cpp.
00033 { 00034 s << "Stream:" << obj.name() << " Def:" << obj.definition(); 00035 return s; 00036 }
long EventSelectorDataStream::m_refCount [protected] |
std::string EventSelectorDataStream::m_name [protected] |
Name.
Definition at line 52 of file EventSelectorDataStream.h.
Referenced by EventSelectorDataStream(), and name().
std::string EventSelectorDataStream::m_definition [protected] |
Definition string.
Definition at line 54 of file EventSelectorDataStream.h.
Referenced by definition(), EventSelectorDataStream(), and initialize().
std::string EventSelectorDataStream::m_criteria [protected] |
Criteria.
Definition at line 56 of file EventSelectorDataStream.h.
Referenced by criteria(), and initialize().
std::string EventSelectorDataStream::m_selectorType [protected] |
Event selector type.
Definition at line 58 of file EventSelectorDataStream.h.
Referenced by initialize(), and selectorType().
IEvtSelector* EventSelectorDataStream::m_pSelector [protected] |
Pointer to valid selector.
Definition at line 60 of file EventSelectorDataStream.h.
Referenced by selector(), and setSelector().
ISvcLocator* EventSelectorDataStream::m_pSvcLocator [protected] |
Reference to service locator.
Definition at line 62 of file EventSelectorDataStream.h.
Referenced by initialize().
Properties* EventSelectorDataStream::m_properties [protected] |
Properties vector.
Definition at line 64 of file EventSelectorDataStream.h.
Referenced by EventSelectorDataStream(), finalize(), initialize(), properties(), property(), and ~EventSelectorDataStream().
bool EventSelectorDataStream::m_initialized [protected] |
Initialization state.
Definition at line 66 of file EventSelectorDataStream.h.
Referenced by EventSelectorDataStream(), finalize(), initialize(), and isInitialized().