/****************************************************************************
 * 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.
 ****************************************************************************/

#ifndef AQH_NODEDB_H
#define AQH_NODEDB_H


#include <aqhome/api.h>
#include <aqhome/nodes/nodeinfo.h>

#include <gwenhywfar/db.h>

#include <inttypes.h>


typedef struct AQH_NODE_DB AQH_NODE_DB;


AQHOME_API AQH_NODE_DB *AQH_NodeDb_new();
AQHOME_API void AQH_NodeDb_free(AQH_NODE_DB *ndb);

AQHOME_API AQH_NODE_INFO_LIST *AQH_NodeDb_GetAllNodeInfos(AQH_NODE_DB *ndb);
AQHOME_API int AQH_NodeDb_AddNodeInfo(AQH_NODE_DB *ndb, AQH_NODE_INFO *ni);

AQHOME_API AQH_NODE_INFO *AQH_NodeDb_GetNodeInfoByBusAddr(AQH_NODE_DB *ndb, uint8_t busAddr);
AQHOME_API AQH_NODE_INFO *AQH_NodeDb_GetNodeInfoByUid(AQH_NODE_DB *ndb, uint32_t uid);

AQHOME_API void AQH_NodeDb_toDb(AQH_NODE_DB *ndb, GWEN_DB_NODE *dbDatabase);
AQHOME_API void AQH_NodeDb_fromDb(AQH_NODE_DB *ndb, GWEN_DB_NODE *dbDatabase);

AQHOME_API void AQH_NodeDb_SetModified(AQH_NODE_DB *ndb);
AQHOME_API void AQH_NodeDb_ClearModified(AQH_NODE_DB *ndb);
AQHOME_API int AQH_NodeDb_IsModified(const AQH_NODE_DB *ndb);

#endif

