The Gaudi Framework  master (6507eef1)
Loading...
Searching...
No Matches
GaudiConfig2.semantics.MappingSemantics Class Reference
Inheritance diagram for GaudiConfig2.semantics.MappingSemantics:
Collaboration diagram for GaudiConfig2.semantics.MappingSemantics:

Public Member Functions

 __init__ (self, cpp_type)
 name (self)
 name (self, value)
 store (self, value)
 default (self, value)
 opt_value (self, value)
 merge (self, a, b)
Public Member Functions inherited from GaudiConfig2.semantics.PropertySemantics
 __init__ (self, cpp_type)
 cpp_type (self)
 cpp_type (self, value)
 load (self, value)
 is_set (self, value)

Public Attributes

 key_semantics = getSemanticsFor(template_args[0])
 value_semantics = getSemanticsFor(template_args[1])
Public Attributes inherited from GaudiConfig2.semantics.PropertySemantics
 cpp_type = cpp_type

Static Private Attributes

tuple __handled_types__ = (re.compile(r"(std::)?(unordered_)?map<.*>$"),)

Additional Inherited Members

Protected Attributes inherited from GaudiConfig2.semantics.PropertySemantics
 _name = None
 _cpp_type = value

Detailed Description

Definition at line 791 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

GaudiConfig2.semantics.MappingSemantics.__init__ ( self,
cpp_type )

Definition at line 794 of file semantics.py.

794 def __init__(self, cpp_type):
795 super().__init__(cpp_type)
796 template_args = list(extract_template_args(cpp_type))
797 self.key_semantics = getSemanticsFor(template_args[0])
798 self.value_semantics = getSemanticsFor(template_args[1])
799

Member Function Documentation

◆ default()

GaudiConfig2.semantics.MappingSemantics.default ( self,
value )

Definition at line 816 of file semantics.py.

816 def default(self, value):
817 new_value = _DictHelper(self.key_semantics, self.value_semantics)
818 new_value.default = value
819 return new_value
820

◆ merge()

GaudiConfig2.semantics.MappingSemantics.merge ( self,
a,
b )
Merge two maps. Throw ValueError if there are conflicting key/value pairs.

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 829 of file semantics.py.

829 def merge(self, a, b):
830 """Merge two maps. Throw ValueError if there are conflicting key/value pairs."""
831
832 # Optimization for most common case
833 if a == b:
834 return a
835
836 for k, v in b.items():
837 try:
838 va = a[k]
839 except KeyError:
840 a[k] = v
841 else:
842 if va != v:
843 raise ValueError(
844 f"conflicting values in map for key {k}: {v} and {va}"
845 )
846 return a
847
848
int merge(const char *target, const char *source, bool fixup=false, bool dbg=true)
Definition merge.C:417

◆ name() [1/2]

GaudiConfig2.semantics.MappingSemantics.name ( self)

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 801 of file semantics.py.

801 def name(self):
802 return self._name
803

◆ name() [2/2]

GaudiConfig2.semantics.MappingSemantics.name ( self,
value )

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 805 of file semantics.py.

805 def name(self, value):
806 self._name = value
807 self.key_semantics.name = f"{self._name} key"
808 self.value_semantics.name = f"{self._name} value"
809

◆ opt_value()

GaudiConfig2.semantics.MappingSemantics.opt_value ( self,
value )
Option string version of value.

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 821 of file semantics.py.

821 def opt_value(self, value):
822 """
823 Option string version of value.
824 """
825 if not isinstance(value, _DictHelper):
826 value = self.default(value)
827 return value.opt_value()
828

◆ store()

GaudiConfig2.semantics.MappingSemantics.store ( self,
value )
Validation/transformation of the data to be stored.

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 810 of file semantics.py.

810 def store(self, value):
811 # No explicit type checking as anything else than dict fails in update call
812 new_value = _DictHelper(self.key_semantics, self.value_semantics)
813 new_value.update(value)
814 return new_value
815

Member Data Documentation

◆ __handled_types__

tuple GaudiConfig2.semantics.MappingSemantics.__handled_types__ = (re.compile(r"(std::)?(unordered_)?map<.*>$"),)
staticprivate

Definition at line 792 of file semantics.py.

◆ key_semantics

GaudiConfig2.semantics.MappingSemantics.key_semantics = getSemanticsFor(template_args[0])

Definition at line 797 of file semantics.py.

◆ value_semantics

GaudiConfig2.semantics.MappingSemantics.value_semantics = getSemanticsFor(template_args[1])

Definition at line 798 of file semantics.py.


The documentation for this class was generated from the following file: