The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
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
18#include <iostream>
19#include <string>
20#include <string_view>
21#include <vector>
22
32class GAUDI_API IProperty : virtual public IInterface {
33public:
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 }
87
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};
#define GAUDI_API
Definition Kernel.h:49
implementation of various functions for streaming.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
const std::string name() const
property name
Definition of the basic interface.
Definition IInterface.h:225
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition IProperty.h:32
DeclareInterfaceID(IProperty, 3, 0)
InterfaceID.
virtual StatusCode setProperty(const std::string &name, const Gaudi::Details::PropertyBase &p)=0
Set the property from a property with a different name.
StatusCode setProperty(const std::string &name, const TYPE &value)
set the property form the value
Definition IProperty.h:82
virtual const Gaudi::Details::PropertyBase & getProperty(std::string_view name) const =0
Get the property by name.
virtual StatusCode setProperty(const std::string &s)=0
Set the property by string.
virtual StatusCode setPropertyRepr(const std::string &n, const std::string &r)=0
Set the property by name and value representation.
virtual bool hasProperty(std::string_view name) const =0
Return true if we have a property with the given name.
virtual StatusCode getProperty(std::string_view n, std::string &v) const =0
Get the property by std::string.
StatusCode setProperty(const std::string &name, const char *v)
Special case for string literals.
Definition IProperty.h:46
StatusCode setProperty(const std::string &name, const std::string &v)
Special case for std::string.
Definition IProperty.h:48
virtual const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const =0
Get list of properties.
virtual StatusCode getProperty(Gaudi::Details::PropertyBase *p) const =0
Get the property by property.
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.
Definition IProperty.h:38
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto FAILURE
Definition StatusCode.h:100
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition ToStream.h:326