Search code examples
tinyosnesc

Module to wrap generic Timer


I am trying to write a module to wrap a generic Timer, but I would like to use this module to be able to wrap timers with arbitrary precision, without writing duplicated code.

I wrote the module like that, but it complains that precision_tag is missing a type, but also giving it a type it won't compile.

generic module TimerLoggerP(precision_tag) {
    provides {
        interface Timer<precision_tag> as Timer;
        interface LoggerComponent;
    }

    uses {
        interface Timer<precision_tag> as RTimer;
    }
}

Does anyone know how to make it work in the generic way I am trying to achieve?


Solution

  • Just needs the special typedef type.

    generic module TimerLoggerP(typedef precision_tag) {
        provides {
            interface Timer<precision_tag> as Timer;
            interface LoggerComponent;
        }
    
        uses {
            interface Timer<precision_tag> as RTimer;
        }
    }