The Gaudi Framework  master (37c0b60a)
IProperty.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #pragma once
12 
13 // Include Files
16 #include <GaudiKernel/IInterface.h>
18 #include <GaudiKernel/ToStream.h>
19 #include <iostream>
20 #include <string>
21 #include <string_view>
22 #include <vector>
23 
33 class GAUDI_API IProperty : virtual public IInterface {
34 public:
37 
43  virtual StatusCode setProperty( const std::string& s ) = 0;
45  virtual StatusCode setPropertyRepr( const std::string& n, const std::string& r ) = 0;
47  StatusCode setProperty( const std::string& name, const char* v ) { return setProperty( name, std::string{ v } ); }
50  if ( !hasProperty( name ) ) return StatusCode::FAILURE;
51  return setPropertyRepr( name, v );
52  }
53 
81  template <class TYPE, typename = std::enable_if_t<!std::is_base_of_v<Gaudi::Details::PropertyBase, TYPE>>>
82  StatusCode setProperty( const std::string& name, const TYPE& value ) {
84  if ( !hasProperty( name ) ) return StatusCode::FAILURE;
85  return setPropertyRepr( name, toString( value ) );
86  }
88  virtual StatusCode getProperty( Gaudi::Details::PropertyBase* p // Pointer to property to be set
89  ) const = 0;
91  virtual const Gaudi::Details::PropertyBase& getProperty( std::string_view name // Property name
92  ) const = 0;
94  virtual StatusCode getProperty( std::string_view n, std::string& v ) const = 0;
97 
99  virtual bool hasProperty( std::string_view name ) const = 0;
100 };
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: PropertyBase.h:39
IProperty::getProperty
virtual const Gaudi::Details::PropertyBase & getProperty(std::string_view name) const =0
Get the property by name.
IProperty::setProperty
StatusCode setProperty(const std::string &name, const char *v)
Special case for string literals.
Definition: IProperty.h:47
std::string
STL class.
IProperty::DeclareInterfaceID
DeclareInterfaceID(IProperty, 3, 0)
InterfaceID.
IProperty::setProperty
virtual StatusCode setProperty(const std::string &name, const Gaudi::Details::PropertyBase &p)=0
Set the property from a property with a different name.
GaudiException.h
gaudirun.s
string s
Definition: gaudirun.py:346
std::vector< Gaudi::Details::PropertyBase * >
PropertyBase.h
IProperty::setProperty
virtual StatusCode setProperty(const std::string &s)=0
Set the property by string.
ToStream.h
IProperty
Definition: IProperty.h:33
IProperty::getProperty
virtual StatusCode getProperty(Gaudi::Details::PropertyBase *p) const =0
Get the property by property.
INamedInterface.h
StatusCode
Definition: StatusCode.h:65
IInterface.h
IProperty::setProperty
StatusCode setProperty(const std::string &name, const TYPE &value)
set the property form the value
Definition: IProperty.h:82
IProperty::hasProperty
virtual bool hasProperty(std::string_view name) const =0
Return true if we have a property with the given name.
IProperty::getProperty
virtual StatusCode getProperty(std::string_view n, std::string &v) const =0
Get the property by std::string.
cpluginsvc.n
n
Definition: cpluginsvc.py:234
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:353
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
IProperty::getProperties
virtual const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const =0
Get list of properties.
IInterface
Definition: IInterface.h:239
IProperty::setProperty
StatusCode setProperty(const std::string &name, const std::string &v)
Special case for std::string.
Definition: IProperty.h:49
Properties.v
v
Definition: Properties.py:122
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
Gaudi::Utils::hasProperty
GAUDI_API bool hasProperty(const IProperty *p, std::string_view name)
simple function which check the existence of the property with the given name.
Definition: Property.cpp:106
IProperty::setPropertyRepr
virtual StatusCode setPropertyRepr(const std::string &n, const std::string &r)=0
Set the property by name and value representation.
IProperty::setProperty
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.
Definition: IProperty.h:39