Files
aqhomecontrol/aqhome/msg/endpoint_node.c
2023-03-30 00:41:06 +02:00

119 lines
2.3 KiB
C

/****************************************************************************
* This file is part of the project AqHome.
* AqHome (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 "aqhome/msg/endpoint_node_p.h"
#include "aqhome/msg/msg_node.h"
#include <gwenhywfar/inherit.h>
#include <gwenhywfar/debug.h>
#include <gwenhywfar/text.h>
#define AQH_MSG_ENDPOINT_NODE_NAME "node"
GWEN_INHERIT(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_NODE)
static void GWENHYWFAR_CB _freeData(void *bp, void *p);
GWEN_MSG_ENDPOINT *AQH_NodeEndpoint_new(const char *name, int groupId)
{
GWEN_MSG_ENDPOINT *ep;
ep=GWEN_MsgEndpoint_new(name?name:AQH_MSG_ENDPOINT_NODE_NAME, groupId);
AQH_NodeEndpoint_Extend(ep);
return ep;
}
void AQH_NodeEndpoint_Extend(GWEN_MSG_ENDPOINT *ep)
{
AQH_MSG_ENDPOINT_NODE *xep;
GWEN_NEW_OBJECT(AQH_MSG_ENDPOINT_NODE, xep);
GWEN_INHERIT_SETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_NODE, ep, xep, _freeData);
}
void _freeData(void *bp, void *p)
{
AQH_MSG_ENDPOINT_NODE *xep;
xep=(AQH_MSG_ENDPOINT_NODE*) p;
GWEN_FREE_OBJECT(xep);
}
uint32_t AQH_NodeEndpoint_GetAcceptedMsgGroups(const GWEN_MSG_ENDPOINT *ep)
{
const AQH_MSG_ENDPOINT_NODE *xep;
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_NODE, ep);
assert(xep);
if (xep)
return xep->acceptedMsgGroups;
return 0;
}
void AQH_NodeEndpoint_SetAcceptedMsgGroups(GWEN_MSG_ENDPOINT *ep, uint32_t f)
{
AQH_MSG_ENDPOINT_NODE *xep;
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_NODE, ep);
assert(xep);
if (xep)
xep->acceptedMsgGroups=f;
}
void AQH_NodeEndpoint_AddAcceptedMsgGroups(GWEN_MSG_ENDPOINT *ep, uint32_t f)
{
AQH_MSG_ENDPOINT_NODE *xep;
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_NODE, ep);
assert(xep);
if (xep)
xep->acceptedMsgGroups|=f;
}
void AQH_NodeEndpoint_DelAcceptedMsgGroups(GWEN_MSG_ENDPOINT *ep, uint32_t f)
{
AQH_MSG_ENDPOINT_NODE *xep;
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_MSG_ENDPOINT_NODE, ep);
assert(xep);
if (xep)
xep->acceptedMsgGroups&=~f;
}