ATLAS Offline Software
Loading...
Searching...
No Matches
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.
typedef std::vector< float > FloatVector
 Convenience type declaration for a float vector.
typedef std::vector< std::string > StringVector
 Convenience type declaration for a string vector.

Public Member Functions

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

Static Public Member Functions

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

Private Attributes

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

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,
39 }; // enum Type
@ FLOATVECTOR
Definition Property.h:35
@ INTVECTOR
Definition Property.h:34
@ TOOLHANDLEARRAY
Definition Property.h:38
@ UNKNOWNTYPE
Definition Property.h:28
@ TOOLHANDLE
Definition Property.h:37
@ STRINGVECTOR
Definition Property.h:36

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}
Type m_type
The type of the property.
Definition Property.h:106

◆ 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}
#define DECLARE_TYPE(TYPE, NAME)
Macro used in implementing the type->name translation function.
Definition Property.cxx:13
Type type() const
Return the type index.
Definition Property.cxx:58

◆ 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
576 if (rhs.getCastString (asString).isFailure())
577 return 1;
578 return this->setString (asString).isFailure();
579}
Templated wrapper around user properties.
Definition TProperty.h:28
virtual StatusCode setString(const std::string &value)
set the property from a string
virtual StatusCode getCastString(std::string &result) const
get the property as a string I can pas to setString
const T * pointer() const
Return the address of the property variable.

◆ 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}
static const std::string & name(Type type)
Function returning a user-readable name for a property type.
Definition Property.cxx:21

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: