Skip to content

Global context

GlobalContext

Source code in june/global_context.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
class GlobalContext:
    """ """
    _disease_config = None
    _simulator = None
    _tt_event_recorder = None

    @classmethod
    def set_disease_config(cls, disease_config):
        """Sets the global disease configuration.

        Args:
            disease_config: 

        """
        cls._disease_config = disease_config

    @classmethod
    def get_disease_config(cls):
        """Returns the global disease configuration."""
        if cls._disease_config is None:
            raise ValueError("DiseaseConfig has not been set.")
        return cls._disease_config

    @classmethod
    def set_simulator(cls, simulator):
        """

        Args:
            simulator: 

        """
        cls._simulator = simulator

    @classmethod
    def get_simulator(cls):
        """ """
        if cls._simulator is None:
            raise ValueError("Simulator has not been set.")
        return cls._simulator

    @classmethod
    def set_tt_event_recorder(cls, recorder):
        """Register a Test and Trace event recorder.
        Pass None to clear the registered recorder.

        Args:
            recorder: 

        """
        cls._tt_event_recorder = recorder
        return recorder

    @classmethod
    def get_tt_event_recorder(cls):
        """Get the registered Test and Trace event recorder.
        Returns None if no recorder is registered.

        """
        return getattr(cls, '_tt_event_recorder', None)

    @classmethod
    def set_config_manager(cls, config_manager):
        """Sets the config manager"""
        cls.config_manager = config_manager

    @classmethod
    def get_config_manager(cls):
        """Return the configuration manager object that holds defaults in one place"""
        return cls.config_manager

get_config_manager() classmethod

Return the configuration manager object that holds defaults in one place

Source code in june/global_context.py
69
70
71
72
@classmethod
def get_config_manager(cls):
    """Return the configuration manager object that holds defaults in one place"""
    return cls.config_manager

get_disease_config() classmethod

Returns the global disease configuration.

Source code in june/global_context.py
20
21
22
23
24
25
@classmethod
def get_disease_config(cls):
    """Returns the global disease configuration."""
    if cls._disease_config is None:
        raise ValueError("DiseaseConfig has not been set.")
    return cls._disease_config

get_simulator() classmethod

Source code in june/global_context.py
37
38
39
40
41
42
@classmethod
def get_simulator(cls):
    """ """
    if cls._simulator is None:
        raise ValueError("Simulator has not been set.")
    return cls._simulator

get_tt_event_recorder() classmethod

Get the registered Test and Trace event recorder. Returns None if no recorder is registered.

Source code in june/global_context.py
56
57
58
59
60
61
62
@classmethod
def get_tt_event_recorder(cls):
    """Get the registered Test and Trace event recorder.
    Returns None if no recorder is registered.

    """
    return getattr(cls, '_tt_event_recorder', None)

set_config_manager(config_manager) classmethod

Sets the config manager

Source code in june/global_context.py
64
65
66
67
@classmethod
def set_config_manager(cls, config_manager):
    """Sets the config manager"""
    cls.config_manager = config_manager

set_disease_config(disease_config) classmethod

Sets the global disease configuration.

Parameters:

Name Type Description Default
disease_config
required
Source code in june/global_context.py
10
11
12
13
14
15
16
17
18
@classmethod
def set_disease_config(cls, disease_config):
    """Sets the global disease configuration.

    Args:
        disease_config: 

    """
    cls._disease_config = disease_config

set_simulator(simulator) classmethod

Parameters:

Name Type Description Default
simulator
required
Source code in june/global_context.py
27
28
29
30
31
32
33
34
35
@classmethod
def set_simulator(cls, simulator):
    """

    Args:
        simulator: 

    """
    cls._simulator = simulator

set_tt_event_recorder(recorder) classmethod

Register a Test and Trace event recorder. Pass None to clear the registered recorder.

Parameters:

Name Type Description Default
recorder
required
Source code in june/global_context.py
44
45
46
47
48
49
50
51
52
53
54
@classmethod
def set_tt_event_recorder(cls, recorder):
    """Register a Test and Trace event recorder.
    Pass None to clear the registered recorder.

    Args:
        recorder: 

    """
    cls._tt_event_recorder = recorder
    return recorder