💾 Archived View for gmi.noulin.net › gitRepositories › signalTimer › file › signalTimer.h.gmi captured on 2023-01-29 at 13:18:00. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

signalTimer

Log

Files

Refs

LICENSE

signalTimer.h (3680B)

     1 #pragma once
     2 
     3 /* Add class methods and class data where there are the TODOs (TODO)*/
     4 #define startTimerG(obj, interval, callback, args) (obj)->f->start(obj, interval, callback, args)
     5 #define stopG(obj) (obj)->f->stop(obj)
     6 #define pauseG(obj) (obj)->f->pause(obj)
     7 #define pauseProcessG(obj) (obj)->f->pauseProcess(obj)
     8 #define restartG(obj) (obj)->f->restart(obj)
     9 #define setIntervalG(obj, interval) (obj)->f->setInterval(obj, interval)
    10 
    11 /* Class signalTimer */
    12 typedef struct signalTimer signalTimert;
    13 
    14 /* for object inheriting signalTimer, cast to signalTimer to be able to use this class functions and generics*/
    15 #define cSignalTimer(self) ( (signalTimert*) self )
    16 
    17 typedef void            (*freeSignalTimerFt)      (signalTimert *self);
    18 typedef void            (*terminateSignalTimerFt) (signalTimert **self);
    19 typedef char*           (*toStringSignalTimerFt)  (signalTimert *self);
    20 typedef signalTimert*   (*duplicateSignalTimerFt) (signalTimert *self);
    21 typedef void            (*smashSignalTimerFt)     (signalTimert **self);
    22 
    23 /**
    24  * free signalTimer
    25  */
    26 typedef void            (*finishSignalTimerFt)    (signalTimert **self);
    27 
    28 typedef bool            (*startSignalTimerFt)     (signalTimert *self, u64 interval, void (*callback)(void *), void *args);
    29 typedef void            (*stopSignalTimerFt)      (signalTimert *self);
    30 typedef void            (*pauseSignalTimerFt)     (signalTimert *self);
    31 typedef void            (*pauseProcessSignalTimerFt)(signalTimert *self);
    32 typedef void            (*restartSignalTimerFt)     (signalTimert *self);
    33 typedef void            (*setIntervalSignalTimerFt) (signalTimert *self, u64 interval);
    34 /* TODO add function typedef with pattern: functionNameClassTempleFt */
    35 
    36 /**
    37  * class functions
    38  * allocated once for all objects
    39  *
    40  * freed with finalizeSignalTimer
    41  */
    42 
    43 /**
    44  * use this define in child classes and add the new function after this class functions
    45  *
    46  * in this define, add the methods after <finishSignalTimerFt    finish;>
    47  *
    48  * Example:
    49  * #define RINGFUNCTIONST \n *   SIGNALTIMERFUNCTIONST; \n *   setSizeRingFt           setSize
    50  */
    51 #define SIGNALTIMERFUNCTIONST \
    52   startSignalTimerFt        start;\
    53   stopSignalTimerFt         stop;\
    54   pauseSignalTimerFt        pause;\
    55   pauseProcessSignalTimerFt pauseProcess;\
    56   restartSignalTimerFt      restart;\
    57   setIntervalSignalTimerFt  setInterval;
    58   /* TODO ADD METHODS AFTER <finishSignalTimerFt    finish;> HERE */
    59 
    60 typedef struct {
    61   freeSignalTimerFt      free;
    62   terminateSignalTimerFt terminate;
    63   toStringSignalTimerFt  toString;
    64   duplicateSignalTimerFt duplicate;
    65   smashSignalTimerFt     smash;
    66   finishSignalTimerFt    finish;
    67   SIGNALTIMERFUNCTIONST;
    68 } signalTimerFunctionst;
    69 
    70 /**
    71  * class
    72  */
    73 struct signalTimer {
    74   const char            *type;
    75   signalTimerFunctionst *f;
    76 
    77   u64                   interval;
    78   void                  (*callback)(void *);
    79   void                  *args;
    80   /* TODO add class data */
    81 };
    82 
    83 /* signalTimer */
    84 
    85 #define createSignalTimer(obj) signalTimert obj; initiateSignalTimer(&obj)
    86 #define createAllocateSignalTimer(obj) signalTimert *obj; initiateAllocateSignalTimer(&obj)
    87 
    88 void initiateSignalTimer(signalTimert *self);
    89 void initiateAllocateSignalTimer(signalTimert **self);
    90 void finalizeSignalTimer(void);
    91 
    92 /* initialize class methods, call registerMethodsSignalTimer from classes inheriting this class */
    93 void registerMethodsSignalTimer(signalTimerFunctionst *f);
    94 
    95 signalTimert* allocSignalTimer(/*TODO INIT DATA */);
    96 
    97 /* end class signalTimer*/
    98 
    99 #define isSignalTimerCompiledWithCurrentLisheepyVersion checkLibsheepyVersionSignalTimer(LIBSHEEPY_VERSION)
   100 bool checkLibsheepyVersionSignalTimer(const char *currentLibsheepyVersion);