ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
TProperty< T > Class Template Reference

Templated wrapper around user properties. More...

#include <TProperty.h>

Inheritance diagram for TProperty< T >:
Collaboration diagram for TProperty< T >:

Public Types

enum  Type {
  UNKNOWNTYPE, BOOL, INT, FLOAT,
  DOUBLE, STRING, INTVECTOR, FLOATVECTOR,
  STRINGVECTOR, TOOLHANDLE, TOOLHANDLEARRAY
}
 Property type enumeration. More...
 
typedef std::vector< int > IntVector
 Convenience type declaration for an integer vector. More...
 
typedef std::vector< float > FloatVector
 Convenience type declaration for a float vector. More...
 
typedef std::vector< std::string > StringVector
 Convenience type declaration for a string vector. More...
 

Public Member Functions

 TProperty (T &val, Type type)
 Constructor from a reference and a type. More...
 
const T * pointer () const
 Return the address of the property variable. More...
 
virtual int setFrom (const Property &rhs)
 Set value using that from another property. More...
 
virtual StatusCode getString (std::string &result) const
 get the property as a string More...
 
virtual StatusCode getCastString (std::string &result) const
 get the property as a string I can pas to setString More...
 
virtual StatusCode setString (const std::string &value)
 set the property from a string More...
 
int setFrom (const Property &rhs)
 
bool isValid () const
 Return if this is a valid property. More...
 
Type type () const
 Return the type index. More...
 
const std::string & typeName () const
 Return the type name. More...
 
Declare specialization(s) for TProperty::setFrom
int setFrom (const Property &rhs)
 Special handling for strings to interpret the user supplied string. More...
 

Static Public Member Functions

static const std::string & name (Type type)
 Function returning a user-readable name for a property type. More...
 

Private Attributes

T * m_ptr
 The address of the wrapped variable. More...
 
Type m_type
 The type of the property. More...
 

Detailed Description

template<typename T>
class TProperty< T >

Templated wrapper around user properties.

This class is used to wrap user-defined tool properties, to be able to set them through the PropertyMgr.

Author
David Adams dlada.nosp@m.ms@b.nosp@m.nl.go.nosp@m.v
Revision
802972
Date
2017-04-15 20:13:17 +0200 (Sat, 15 Apr 2017)

Definition at line 28 of file TProperty.h.

Member Typedef Documentation

◆ FloatVector

typedef std::vector< float > Property::FloatVector
inherited

Convenience type declaration for a float vector.

Definition at line 44 of file Property.h.

◆ IntVector

typedef std::vector< int > Property::IntVector
inherited

Convenience type declaration for an integer vector.

Definition at line 42 of file Property.h.

◆ StringVector

typedef std::vector< std::string > Property::StringVector
inherited

Convenience type declaration for a string vector.

Definition at line 46 of file Property.h.

Member Enumeration Documentation

◆ Type

enum Property::Type
inherited

Property type enumeration.

Enumerator
UNKNOWNTYPE 
BOOL 
INT 
FLOAT 
DOUBLE 
STRING 
INTVECTOR 
FLOATVECTOR 
STRINGVECTOR 
TOOLHANDLE 
TOOLHANDLEARRAY 

Definition at line 27 of file Property.h.

27  {
29  BOOL,
30  INT,
31  FLOAT,
32  DOUBLE,
33  STRING,
34  INTVECTOR,
37  TOOLHANDLE,
39  }; // enum Type

Constructor & Destructor Documentation

◆ TProperty()

template<typename T >
TProperty< T >::TProperty ( T &  val,
Type  type 
)

Constructor from a reference and a type.

Member Function Documentation

◆ getCastString()

template<typename T >
virtual StatusCode TProperty< T >::getCastString ( std::string &  result) const
virtual

get the property as a string I can pas to setString

the main difference to getString is that this will not quote strings, i.e. it will assume strings are already properly quoted if they need to be and won't be otherwise. otherwise there will be an issue when setting non-strings from strings the user provided

Guarantee
strong
Failures
no string conversion available

Reimplemented from Property.

◆ getString()

template<typename T >
virtual StatusCode TProperty< T >::getString ( std::string &  result) const
virtual

get the property as a string

Guarantee
strong
Failures
no string conversion available

Reimplemented from Property.

◆ isValid()

bool Property::isValid ( ) const
inherited

Return if this is a valid property.

Must have a known type.

Definition at line 53 of file Property.cxx.

53  {
54 
55  return ( m_type != UNKNOWNTYPE );
56 }

◆ name()

const std::string & Property::name ( Type  type)
staticinherited

Function returning a user-readable name for a property type.

Definition at line 21 of file Property.cxx.

21  {
22 
23  switch( type ) {
24  DECLARE_TYPE( UNKNOWNTYPE, "unknown" );
25  DECLARE_TYPE( BOOL, "bool" );
26  DECLARE_TYPE( INT, "int" );
27  DECLARE_TYPE( FLOAT, "float" );
28  DECLARE_TYPE( DOUBLE, "double" );
29  DECLARE_TYPE( STRING, "string" );
30  DECLARE_TYPE( INTVECTOR, "vector<int>" );
31  DECLARE_TYPE( FLOATVECTOR, "vector<float>" );
32  DECLARE_TYPE( STRINGVECTOR, "vector<string>" );
33  DECLARE_TYPE( TOOLHANDLE, "ToolHandle" );
34  DECLARE_TYPE( TOOLHANDLEARRAY, "ToolHandleArray" );
35  default:
36  break;
37  }
38 
39  static const std::string dummy( "<error>" );
40  return dummy;
41 }

◆ pointer()

template<typename T >
const T* TProperty< T >::pointer ( ) const

Return the address of the property variable.

◆ setFrom() [1/3]

template<typename T >
virtual int TProperty< T >::setFrom ( const Property rhs)
virtual

Set value using that from another property.

Reimplemented from Property.

◆ setFrom() [2/3]

int TProperty< std::string >::setFrom ( const Property rhs)
virtual

Special handling for strings to interpret the user supplied string.

Reimplemented from Property.

◆ setFrom() [3/3]

int TProperty< std::string >::setFrom ( const Property rhs)
virtual

Reimplemented from Property.

Definition at line 569 of file TProperty.cxx.

569  {
570  // Check that we have a valid pointer:
571  if( ! this->pointer() ) {
572  return 1;
573  }
574 
575  std::string asString;
576  if (rhs.getCastString (asString).isFailure())
577  return 1;
578  return this->setString (asString).isFailure();
579 }

◆ setString()

template<typename T >
virtual StatusCode TProperty< T >::setString ( const std::string &  value)
virtual

set the property from a string

Guarantee
basic
Failures
no string conversion available
format errors

Reimplemented from Property.

◆ type()

Property::Type Property::type ( ) const
inherited

Return the type index.

Definition at line 58 of file Property.cxx.

58  {
59 
60  return m_type;
61 }

◆ typeName()

const std::string & Property::typeName ( ) const
inherited

Return the type name.

Definition at line 63 of file Property.cxx.

63  {
64 
65  return name( m_type );
66 }

Member Data Documentation

◆ m_ptr

template<typename T >
T* TProperty< T >::m_ptr
private

The address of the wrapped variable.

Definition at line 48 of file TProperty.h.

◆ m_type

Type Property::m_type
privateinherited

The type of the property.

Definition at line 106 of file Property.h.


The documentation for this class was generated from the following file:
Property::BOOL
@ BOOL
Definition: Property.h:29
Property::getCastString
virtual StatusCode getCastString(std::string &result) const
get the property as a string I can pas to setString
Definition: Property.cxx:81
Property::STRING
@ STRING
Definition: Property.h:33
DECLARE_TYPE
#define DECLARE_TYPE(TYPE, NAME)
Macro used in implementing the type->name translation function.
Definition: Property.cxx:13
Property::INTVECTOR
@ INTVECTOR
Definition: Property.h:34
Property::STRINGVECTOR
@ STRINGVECTOR
Definition: Property.h:36
Property::DOUBLE
@ DOUBLE
Definition: Property.h:32
TProperty::setString
virtual StatusCode setString(const std::string &value)
set the property from a string
Property::UNKNOWNTYPE
@ UNKNOWNTYPE
Definition: Property.h:28
python.xAODType.dummy
dummy
Definition: xAODType.py:4
TProperty::pointer
const T * pointer() const
Return the address of the property variable.
Property::TOOLHANDLE
@ TOOLHANDLE
Definition: Property.h:37
Property::INT
@ INT
Definition: Property.h:30
Property::FLOAT
@ FLOAT
Definition: Property.h:31
Property::FLOATVECTOR
@ FLOATVECTOR
Definition: Property.h:35
Property::type
Type type() const
Return the type index.
Definition: Property.cxx:58
Property::name
static const std::string & name(Type type)
Function returning a user-readable name for a property type.
Definition: Property.cxx:21
Property::TOOLHANDLEARRAY
@ TOOLHANDLEARRAY
Definition: Property.h:38
Property::m_type
Type m_type
The type of the property.
Definition: Property.h:106