The Gaudi Framework  master (69a68366)
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 707 of file semantics.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 710 of file semantics.py.

710 def __init__(self, cpp_type):
711 super(MappingSemantics, self).__init__(cpp_type)
712 template_args = list(extract_template_args(cpp_type))
713 self.key_semantics = getSemanticsFor(template_args[0])
714 self.value_semantics = getSemanticsFor(template_args[1])
715

Member Function Documentation

◆ default()

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

Definition at line 732 of file semantics.py.

732 def default(self, value):
733 new_value = _DictHelper(self.key_semantics, self.value_semantics)
734 new_value.default = value
735 return new_value
736

◆ 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 745 of file semantics.py.

745 def merge(self, a, b):
746 """Merge two maps. Throw ValueError if there are conflicting key/value pairs."""
747
748 # Optimization for most common case
749 if a == b:
750 return a
751
752 for k, v in b.items():
753 try:
754 va = a[k]
755 except KeyError:
756 a[k] = v
757 else:
758 if va != v:
759 raise ValueError(
760 f"conflicting values in map for key {k}: {v} and {va}"
761 )
762 return a
763
764
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 717 of file semantics.py.

717 def name(self):
718 return self._name
719

◆ name() [2/2]

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 721 of file semantics.py.

721 def name(self, value):
722 self._name = value
723 self.key_semantics.name = "{} key".format(self._name)
724 self.value_semantics.name = "{} value".format(self._name)
725
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition MsgStream.cpp:93

◆ opt_value()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 737 of file semantics.py.

737 def opt_value(self, value):
738 """
739 Option string version of value.
740 """
741 if not isinstance(value, _DictHelper):
742 value = self.default(value)
743 return value.opt_value()
744

◆ store()

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

Reimplemented from GaudiConfig2.semantics.PropertySemantics.

Definition at line 726 of file semantics.py.

726 def store(self, value):
727 # No explicit type checking as anything else than dict fails in update call
728 new_value = _DictHelper(self.key_semantics, self.value_semantics)
729 new_value.update(value)
730 return new_value
731

Member Data Documentation

◆ __handled_types__

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

Definition at line 708 of file semantics.py.

◆ key_semantics

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

Definition at line 713 of file semantics.py.

◆ value_semantics

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

Definition at line 714 of file semantics.py.


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