| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

TypeNameString.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_TYPENAMESTRING_H
2 #define GAUDIKERNEL_TYPENAMESTRING_H
3 #include "GaudiKernel/Property.h"
4 #include <ostream>
5 #include <string>
6
7 namespace Gaudi
8 {
9 namespace Utils
10 {
12 class TypeNameString
13 {
14 std::string m_type, m_name;
15 bool m_haveType;
16
17 public:
18 TypeNameString( const char tn[] ) : TypeNameString( std::string{tn} ) {}
19 TypeNameString( const std::string& tn ) : m_type{tn}
20 {
21 const auto slash_pos = m_type.find_first_of( "/" );
22 m_haveType = slash_pos != std::string::npos;
23 if ( m_haveType ) {
24 m_name = m_type.substr( slash_pos + 1 );
25 m_type = m_type.substr( 0, slash_pos );
26 } else
27 m_name = m_type;
28 }
29 TypeNameString( const std::string& tn, const std::string& deftyp ) : TypeNameString( tn )
30 {
31 if ( !m_haveType ) {
32 m_type = deftyp;
33 }
34 }
35 template <class T, class V, class H>
36 TypeNameString( const Gaudi::Property<T, V, H>& prop ) : TypeNameString( prop.value() )
37 {
38 }
39 const std::string& type() const { return m_type; }
40 const std::string& name() const { return m_name; }
41 bool haveType() const { return m_haveType; }
42 };
43
45 inline std::ostream& operator<<( std::ostream& s, const TypeNameString& tn )
46 {
47 return s << tn.type() << '/' << tn.name();
48 }
49 }
50 }
51
52 #endif // GAUDIKERNEL_TYPENAMESTRING_H
Gaudi::Utils::TypeNameString::TypeNameString
TypeNameString(const Gaudi::Property< T, V, H > &prop)
Definition: TypeNameString.h:36
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:314
Gaudi::Utils::operator<<
std::ostream & operator<<(std::ostream &s, const TypeNameString &tn)
Output stream operator for TypeNameString instances.
Definition: TypeNameString.h:45
std
STL namespace.
Gaudi::Utils::TypeNameString::m_haveType
bool m_haveType
Definition: TypeNameString.h:15
std::string
STL class.
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:12
Gaudi::Utils::TypeNameString::TypeNameString
TypeNameString(const char tn[])
Definition: TypeNameString.h:18
std::string::find_first_of
T find_first_of(T...args)
Gaudi::Utils::TypeNameString::TypeNameString
TypeNameString(const std::string &tn, const std::string &deftyp)
Definition: TypeNameString.h:29
Gaudi::Utils::TypeNameString::type
const std::string & type() const
Definition: TypeNameString.h:39
Property.h
gaudirun.s
string s
Definition: gaudirun.py:245
std::string::substr
T substr(T...args)
Gaudi::Utils::TypeNameString::haveType
bool haveType() const
Definition: TypeNameString.h:41
Gaudi::Utils::TypeNameString::m_name
std::string m_name
Definition: TypeNameString.h:14
Gaudi::Utils::TypeNameString::TypeNameString
TypeNameString(const std::string &tn)
Definition: TypeNameString.h:19
Gaudi::Utils::TypeNameString::name
const std::string & name() const
Definition: TypeNameString.h:40
std::ostream
STL class.
Gaudi
Helper functions to set/get the application return code.
Definition: __init__.py:1
Gaudi::Utils::TypeNameString::m_type
std::string m_type
Definition: TypeNameString.h:14