/****************************************************************************
 * This file is part of the project Gwenhywfar.
 * Gwenhywfar (c) by 2023 Martin Preuss, all rights reserved.
 *
 * The license for this file can be found in the file COPYING which you
 * should have received along with this file.
 ****************************************************************************/

#ifndef AQH_EVENT_TIMER_H
#define AQH_EVENT_TIMER_H


#include "aqhome/api.h"

#include <gwenhywfar/inherit.h>
#include <gwenhywfar/list.h>


enum {
  AQH_EventTimerType_CountDown=0,
  AQH_EventTimerType_Alarm
};


#define AQH_EVENT_TIMER_FLAGS_RUNNING                0x0001
#define AQH_EVENT_TIMER_FLAGS_RESTART                0x0002
#define AQH_EVENT_TIMER_FLAGS_DELETE_IF_TRIGGERED    0x0004



typedef struct AQH_EVENT_TIMER AQH_EVENT_TIMER;
GWEN_INHERIT_FUNCTION_LIB_DEFS(AQH_EVENT_TIMER, AQHOME_API)
GWEN_LIST_FUNCTION_LIB_DEFS(AQH_EVENT_TIMER, AQH_EventTimer, AQHOME_API)


AQHOME_API AQH_EVENT_TIMER *AQH_EventTimer_new();
AQHOME_API void AQH_EventTimer_free(AQH_EVENT_TIMER *evt);

AQHOME_API uint32_t AQH_EventTimer_GetFlags(const AQH_EVENT_TIMER *evt);
AQHOME_API void AQH_EventTimer_SetFlags(AQH_EVENT_TIMER *evt, uint32_t f);
AQHOME_API void AQH_EventTimer_AddFlags(AQH_EVENT_TIMER *evt, uint32_t f);
AQHOME_API void AQH_EventTimer_SubFlags(AQH_EVENT_TIMER *evt, uint32_t f);

AQHOME_API int AQH_EventTimer_GetTimerType(const AQH_EVENT_TIMER *evt);
AQHOME_API void AQH_EventTimer_SetTimerType(AQH_EVENT_TIMER *evt, int i);

AQHOME_API uint64_t AQH_EventTimer_GetId(const AQH_EVENT_TIMER *evt);
AQHOME_API void AQH_EventTimer_SetId(AQH_EVENT_TIMER *evt, uint64_t i);

AQHOME_API uint64_t AQH_EventTimer_GetCurrentValue(const AQH_EVENT_TIMER *evt);
AQHOME_API void AQH_EventTimer_SetCurrentValue(AQH_EVENT_TIMER *evt, uint64_t i);

AQHOME_API uint64_t AQH_EventTimer_GetReloadOrAlarmValue(const AQH_EVENT_TIMER *evt);
AQHOME_API void AQH_EventTimer_SetReloadOrAlarmValue(AQH_EVENT_TIMER *evt, uint64_t i);

AQHOME_API int AQH_EventTimer_GetEventType(const AQH_EVENT_TIMER *evt);
AQHOME_API void AQH_EventTimer_SetEventType(AQH_EVENT_TIMER *evt, int i);


AQHOME_API int AQH_EventTimer_CheckWhetherTickTriggers(AQH_EVENT_TIMER *evt, uint64_t t);


#endif


