Started adding an event layer.
This commit is contained in:
93
aqhome/events/eventsubscription.c
Normal file
93
aqhome/events/eventsubscription.c
Normal file
@@ -0,0 +1,93 @@
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "./eventsubscription_p.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
|
||||
GWEN_INHERIT_FUNCTIONS(AQH_EVENT_SUBSCRIPTION)
|
||||
GWEN_LIST_FUNCTIONS(AQH_EVENT_SUBSCRIPTION, AQH_EventSubscription)
|
||||
|
||||
|
||||
|
||||
|
||||
AQH_EVENT_SUBSCRIPTION *AQH_EventSubscription_new()
|
||||
{
|
||||
AQH_EVENT_SUBSCRIPTION *evs;
|
||||
|
||||
GWEN_NEW_OBJECT(AQH_EVENT_SUBSCRIPTION, evs);
|
||||
GWEN_INHERIT_INIT(AQH_EVENT_SUBSCRIPTION, evs);
|
||||
GWEN_LIST_INIT(AQH_EVENT_SUBSCRIPTION, evs);
|
||||
|
||||
return evs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_EventSubscription_free(AQH_EVENT_SUBSCRIPTION *evs)
|
||||
{
|
||||
if (evs) {
|
||||
GWEN_LIST_FINI(AQH_EVENT_SUBSCRIPTION, evs);
|
||||
GWEN_INHERIT_FINI(AQH_EVENT_SUBSCRIPTION, evs);
|
||||
GWEN_FREE_OBJECT(evs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_EventSubscription_GetEventType(const AQH_EVENT_SUBSCRIPTION *evs)
|
||||
{
|
||||
return evs?evs->eventType:0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_EventSubscription_SetEventType(AQH_EVENT_SUBSCRIPTION *evs, int i)
|
||||
{
|
||||
if (evs)
|
||||
evs->eventType=i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint64_t AQH_EventSubscription_GetObjectId(const AQH_EVENT_SUBSCRIPTION *evs)
|
||||
{
|
||||
return evs?evs->objectId:0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_EventSubscription_SetObjectId(AQH_EVENT_SUBSCRIPTION *evs, uint64_t i)
|
||||
{
|
||||
if (evs)
|
||||
evs->objectId=i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_EventSubscription_CallHandler(AQH_EVENT_SUBSCRIPTION *evs, int eventType, uint64_t objectId)
|
||||
{
|
||||
if (evs && evs->handlerFn)
|
||||
return evs->handlerFn(evs, eventType, objectId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user