#!/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. class Callback: """ Callback root class used by Python """ def __init__(self, param_s): """ :param param_s: parameter string for initialisation """ pass def begin(self, kwds=None): """ Begin measurement. """ pass def end(self, kwds=None): """ End measurement. """ pass def report(self): """ Report data to file. """ pass def get_callback(cb_name): """ 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 from callback.cb_time import TimeCallback from callback.cb_clock import ClockCallback name_dic = { 'print': PrintCallback, 'time': TimeCallback, 'clock': ClockCallback, } cb_cls = name_dic[cb_name] return cb_cls