Commit 2915c617 authored by Alex Pearce's avatar Alex Pearce
Browse files

Extend GaudiConfig2 configurable to match Configurables API.

parent 46f979b2
Pipeline #2760217 passed with stages
in 25 minutes and 39 seconds
...@@ -237,8 +237,13 @@ class Configurable(ConfigMetaHelper): ...@@ -237,8 +237,13 @@ class Configurable(ConfigMetaHelper):
def is_property_set(self, propname): def is_property_set(self, propname):
return self._descriptors[propname].__is_set__(self, type(self)) return self._descriptors[propname].__is_set__(self, type(self))
def getGaudiType(self): @classmethod
return self.__component_type__ def getGaudiType(cls):
return cls.__component_type__
@classmethod
def getType(cls):
return cls.__cpp_type__
def getName(self): def getName(self):
return self.name return self.name
...@@ -249,6 +254,14 @@ class Configurable(ConfigMetaHelper): ...@@ -249,6 +254,14 @@ class Configurable(ConfigMetaHelper):
def toStringProperty(self): def toStringProperty(self):
return "{}/{}".format(self.__cpp_type__, self.name) return "{}/{}".format(self.__cpp_type__, self.name)
@classmethod
def getDefaultProperties(cls):
return {k: v.default for k, v in cls._descriptors.items()}
@classmethod
def getDefaultProperty(cls, name):
return cls._descriptors[name].default
def merge(self, other): def merge(self, other):
''' '''
Merge the properties of the other instance into the current one. Merge the properties of the other instance into the current one.
......
...@@ -75,6 +75,14 @@ def test_configurable(): ...@@ -75,6 +75,14 @@ def test_configurable():
assert a.toStringProperty() == MyAlg.__cpp_type__ + '/abc' assert a.toStringProperty() == MyAlg.__cpp_type__ + '/abc'
assert MyAlg.getGaudiType() == 'Algorithm'
assert MyAlg.getType() == 'TestConf::MyAlg'
assert MyAlg.getDefaultProperty("AStringProp") == 'text'
assert MyAlg.getDefaultProperties()['ABoolProp'] == False
def test_properties(): def test_properties():
p = MyAlg() p = MyAlg()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment