3.10.1.3. opengate.base¶
3.10.1.3.1. Classes¶
This is the base class used for all objects that handle user input in GATE. |
|
This is the base class used for all objects that handle user input in GATE. |
|
NOT USED YET! |
3.10.1.3.2. Functions¶
|
The factory function is meant to process classes inheriting from GateObject. |
|
This is a factory function to process classes which inherit from GateObject. |
|
|
|
|
|
Add user_info defaults as properties to class if not yet present. |
|
Return a property that stores the user_info item in a |
|
|
|
|
|
|
Walk recursively across entries of user_info and convert to appropriate structure. |
|
|
|
|
|
|
|
|
Utility function to retrieve the options associated with a user info given the class name, |
Function to (re-)create an object derived from GateObject based on a dictionary. |
3.10.1.3.3. Module Contents¶
- opengate.base.process_cls(cls)[source]¶
The factory function is meant to process classes inheriting from GateObject. It digests the user info parametrisation from all classes in the inheritance tree and enhances the __init__ method, so it calls the __finalize_init__ method at the very end of the __init__ call, which is required to check for invalid attribute setting.
- opengate.base.wrap_init_method(cls)[source]¶
This is a factory function to process classes which inherit from GateObject. It is called from the main factory function process_cls(). This function wraps and reattaches the __init__ method of this class, if it implements one. The wrapped __init__ first calls the “original” __init__ and subsequently the method __finalize_init__, which has a base implementation in GateObject, in case the __init__ is the furthest down in the inheritance chain. The method __finalize_init__ is needed to allow GateObject.__setattr__ to check for invalid attribute setting.
- opengate.base.add_properties_to_class(cls, user_info_defaults)[source]¶
Add user_info defaults as properties to class if not yet present.
- opengate.base._make_property(property_name, default_value, options=None, container_dict=None)[source]¶
Return a property that stores the user_info item in a dictionary which is an attribute of the object (self).
- class opengate.base.GateObject(*args, simulation=None, **kwargs)[source]¶
This is the base class used for all objects that handle user input in GATE.
The class is assumed to be processed by process_cls(), either explicitly or via the metaclass MetaUserInfo, before any instances of the class are created. Some class attributes, e.g. inherited_user_info_defaults, are created as part of this processing.
- __reduce__()[source]¶
This method is called when the object is pickled. Usually, pickle works well without this custom __reduce__ method, but objects handling user_infos need a custom __reduce__ to make sure the properties linked to the user_infos are properly created
The return arguments are: 1) A callable used to create the instance when unpickling 2) A tuple of arguments to be passed to the callable in 1 3) The dictionary of the object’s properties to be passed to the __setstate__ method (if defined)
- __finalize_init__()[source]¶
This method should be called once all attributes have been defined, usually at the end of the __init__ method. It defines the set of known_attribues that will be used to detect errors when the user tries to use a new attribute or misspells an attribute, e.g. box.mohter instead of box.mother.
- __add_to_simulation__()[source]¶
Hook method which can be called by managers. Specific classes can use this to implement actions to be taken when an object is being added to the simulation, e.g. adding a certain actor implies switching on certain physics options.
- class opengate.base.DynamicGateObject(*args, simulation=None, **kwargs)[source]¶
Bases:
GateObjectThis is the base class used for all objects that handle user input in GATE.
The class is assumed to be processed by process_cls(), either explicitly or via the metaclass MetaUserInfo, before any instances of the class are created. Some class attributes, e.g. inherited_user_info_defaults, are created as part of this processing.
- _add_dynamic_parametrisation_to_userinfo(params, name)[source]¶
This base class implementation only acts as a setter. Classes inheriting from this class should implement an add_dynamic_parametrisation() method which actually does something with the parameters and then call super().add_dynamic_parametrisation(). Inheriting classes should avoid calling this method directly.
- class opengate.base.GateUserInputSwitchDict(default_switches, *args, **kwargs)[source]¶
Bases:
box.BoxNOT USED YET!
Specialized version of a Box (dict) to represent a dictionary with boolean switches.
The switches handled by the object need to be defined when the object is created via a dictionary passed as argument ‘default_switches’. No switches can be added later, nor can switches be removed. Switch values are automatically converted to Bool if possible.
- opengate.base.recursive_userinfo_to_dict(obj)[source]¶
Walk recursively across entries of user_info and convert to appropriate structure. Dictionary-like structures are mapped to dictionary and walked across recursively. List-like structures are mapped to lists and walked across recursively. GateObject-like objects are converted through their to_dictionary() method. All other input (presumably common data types including numpy structures) is left untouched.