GitLab will be upgraded on 31 Jan 2023 from 2.00 pm (AEDT) to 3.00 pm (AEDT). During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

__init__.py 1.58 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env python3
# Copyright 2017 The Australian National University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


John Zhang's avatar
John Zhang committed
17
18
19
20
class Callback:
    """
    Callback root class used by Python
    """
Zixian Cai's avatar
PEP 8    
Zixian Cai committed
21

John Zhang's avatar
John Zhang committed
22
23
24
25
26
27
    def __init__(self, param_s):
        """
        :param param_s: parameter string for initialisation
        """
        pass

28
    def begin(self, kwds=None):
John Zhang's avatar
John Zhang committed
29
30
31
32
33
        """
        Begin measurement.
        """
        pass

34
    def end(self, kwds=None):
John Zhang's avatar
John Zhang committed
35
36
37
38
39
        """
        End measurement.
        """
        pass

40
    def report(self):
John Zhang's avatar
John Zhang committed
41
42
43
44
45
46
        """
        Report data to file.
        """
        pass


47
def get_callback(cb_name):
John Zhang's avatar
John Zhang committed
48
49
50
51
52
53
    """
    Import callback classes from submodule files,
    and dynamically select which class to return.
    NOTE: new Callback class implementations should be added here
    """
    from callback.cb_print import PrintCallback
54
    from callback.cb_time import TimeCallback
55
    from callback.cb_clock import ClockCallback
56
57
58
59
60
61
    name_dic = {
        'print': PrintCallback,
        'time': TimeCallback,
        'clock': ClockCallback,
    }
    cb_cls = name_dic[cb_name]
John Zhang's avatar
John Zhang committed
62
    return cb_cls