Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IProperty.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 
15 #include <GaudiKernel/IInterface.h>
17 #include <GaudiKernel/ToStream.h>
18 #include <iostream>
19 #include <string>
20 #include <string_view>
21 #include <vector>
22 
32 class GAUDI_API IProperty : virtual public IInterface {
33 public:
36 
40  virtual StatusCode setProperty( const std::string& name, const Gaudi::Details::PropertyBase& p ) = 0;
42  virtual StatusCode setProperty( const std::string& s ) = 0;
44  virtual StatusCode setPropertyRepr( const std::string& n, const std::string& r ) = 0;
46  StatusCode setProperty( const std::string& name, const char* v ) { return setProperty( name, std::string{ v } ); }
48  StatusCode setProperty( const std::string& name, const std::string& v ) {
49  if ( !hasProperty( name ) ) return StatusCode::FAILURE;
50  return setPropertyRepr( name, v );
51  }
52 
80  template <class TYPE>
81  requires( !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;
96  virtual const std::vector<Gaudi::Details::PropertyBase*>& getProperties() 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:34
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: PropertyBase.h:38
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:46
IProperty::DeclareInterfaceID
DeclareInterfaceID(IProperty, 3, 0)
InterfaceID.
setProperty
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:211
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
PropertyBase.h
IProperty::setProperty
virtual StatusCode setProperty(const std::string &s)=0
Set the property by string.
ToStream.h
IProperty
Definition: IProperty.h:32
IProperty::getProperty
virtual StatusCode getProperty(Gaudi::Details::PropertyBase *p) const =0
Get the property by property.
INamedInterface.h
StatusCode
Definition: StatusCode.h:64
IInterface.h
IProperty::hasProperty
virtual bool hasProperty(std::string_view name) const =0
Return true if we have a property with the given name.
IProperty::requires
requires(!std::is_base_of_v< Gaudi::Details::PropertyBase, TYPE >) StatusCode setProperty(const std
set the property form the value
Definition: IProperty.h:81
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:326
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:225
IProperty::setProperty
StatusCode setProperty(const std::string &name, const std::string &v)
Special case for std::string.
Definition: IProperty.h:48
Properties.v
v
Definition: Properties.py:122
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:100
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:49
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:87
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:38