random_events.utils#

Classes#

SubclassJSONSerializer

Class for automatic (de)serialization of subclasses.

CPPWrapper

Class for wrapping C++ objects.

Functions#

get_full_class_name(cls)

Returns the full name of a class, including the module name.

recursive_subclasses(cls)

Module Contents#

random_events.utils.get_full_class_name(cls)#

Returns the full name of a class, including the module name.

Parameters:

cls – The class.

Returns:

The full name of the class

random_events.utils.recursive_subclasses(cls)#
Parameters:

cls – The class.

Returns:

A list of the classes subclasses.

class random_events.utils.SubclassJSONSerializer#

Class for automatic (de)serialization of subclasses. Classes that inherit from this class can be serialized and deserialized automatically by calling this classes ‘from_json’ method.

to_json() typing_extensions.Dict[str, typing_extensions.Any]#
classmethod _from_json(data: typing_extensions.Dict[str, typing_extensions.Any]) typing_extensions.Self#
Abstractmethod:

Create a variable from a json dict. This method is called from the from_json method after the correct subclass is determined and should be overwritten by the respective subclass.

Parameters:

data – The json dict

Returns:

The deserialized object

classmethod from_json(data: typing_extensions.Dict[str, typing_extensions.Any]) typing_extensions.Self#

Create the correct instanceof the subclass from a json dict.

Parameters:

data – The json dict

Returns:

The correct instance of the subclass

class random_events.utils.CPPWrapper#

Class for wrapping C++ objects.

_cpp_object: typing_extensions.Any#

The C++ object that this class wraps.

abstract _from_cpp(cpp_object: typing_extensions.Any) typing_extensions.Self#

Create a new instance of this class from a C++ object.

This method should also add fields that are python only to the instance that is created. This cannot be a class method since the values of the python-only fields are instance-specific.