ATLAS Offline Software
Property.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // System include(s):
6 #include <iostream>
7 
8 // Local include(s):
9 #include "AsgTools/Property.h"
11 
13 #define DECLARE_TYPE( TYPE, NAME ) \
14  case TYPE: \
15  { \
16  static const std::string n( NAME ); \
17  return n; \
18  } \
19  break
20 
21 const std::string& Property::name( Type type ) {
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 }
42 
44  : m_type( UNKNOWNTYPE ) {
45 
46 }
47 
49  : m_type( type ) {
50 
51 }
52 
53 bool Property::isValid() const {
54 
55  return ( m_type != UNKNOWNTYPE );
56 }
57 
59 
60  return m_type;
61 }
62 
63 const std::string& Property::typeName() const {
64 
65  return name( m_type );
66 }
67 
68 int Property::setFrom( const Property& ) {
69 
70  std::cout << "Property::setFrom: Property not set!" << std::endl;
71  return -1;
72 }
73 
74 
75 
76 StatusCode Property::getString (std::string& /*result*/) const {
77  std::cout << "Property::getString: method not implemented" << std::endl;
78  return StatusCode::FAILURE;
79 }
80 
81 StatusCode Property::getCastString (std::string& /*result*/) const {
82  std::cout << "Property::getCastString: method not implemented" << std::endl;
83  return StatusCode::FAILURE;
84 }
85 
86 StatusCode Property::setString (const std::string& /*value*/) {
87  std::cout << "Property::setString: method not implemented" << std::endl;
88  return StatusCode::FAILURE;
89 }
Property::BOOL
@ BOOL
Definition: Property.h:29
Property::Type
Type
Property type enumeration.
Definition: Property.h:27
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
Property::Property
Property()
Default constructor.
Definition: Property.cxx:43
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::setFrom
virtual int setFrom(const Property &rhs)
Definition: Property.cxx:68
Property::getString
virtual StatusCode getString(std::string &result) const
get the property as a string
Definition: Property.cxx:76
Property
Support class for PropertyMgr.
Definition: Property.h:23
Property::typeName
const std::string & typeName() const
Return the type name.
Definition: Property.cxx:63
Property::DOUBLE
@ DOUBLE
Definition: Property.h:32
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
Property::UNKNOWNTYPE
@ UNKNOWNTYPE
Definition: Property.h:28
Property.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
python.xAODType.dummy
dummy
Definition: xAODType.py:4
xAODType
Definition: ObjectType.h:13
StatusCode.h
Property::TOOLHANDLE
@ TOOLHANDLE
Definition: Property.h:37
Property::INT
@ INT
Definition: Property.h:30
Property::FLOAT
@ FLOAT
Definition: Property.h:31
Property::isValid
bool isValid() const
Return if this is a valid property.
Definition: Property.cxx:53
Property::FLOATVECTOR
@ FLOATVECTOR
Definition: Property.h:35
Property::type
Type type() const
Return the type index.
Definition: Property.cxx:58
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Property::setString
virtual StatusCode setString(const std::string &value)
set the property from a string
Definition: Property.cxx:86
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