Add datamodel

This commit is contained in:
NADAL Jean-Baptiste
2019-12-24 16:59:55 +01:00
parent ab13a62d0a
commit a0a3c90e3c
13 changed files with 1183 additions and 1 deletions

View File

@@ -0,0 +1,74 @@
/*!
* devices_manager.h
*
* Copyright (c) 2015-2019, NADAL Jean-Baptiste. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*
* @Author: NADAL Jean-Baptiste
* @Date: 24/12/2019
*
*/
#ifndef _DEVICES_MANAGER_H
#define _DEVICES_MANAGER_H
/*------------------------------- INCLUDES ----------------------------------*/
#include <stdint.h>
#include <stdbool.h>
#include <qlibc/qlibc.h>
/*--------------------------------- DEPS ------------------------------------*/
struct json_object;
/*------------------------------- TYPEDEFS ----------------------------------*/
typedef struct devices_manager_s devices_manager_t;
/**
* Device Manager Container.
*/
struct devices_manager_s
{
char *file_path;
qhashtbl_t *outlets;
qhashtbl_t *shutters;
qhashtbl_t *sprinklers;
};
/*--------------------------- PUBLIC FUNCTIONS -------------------------------*/
extern devices_manager_t *devices_manager_new(void);
extern void devices_manager_free(devices_manager_t *devices_manager);
extern int devices_manager_load(devices_manager_t *dm);
extern int devices_manager_save(devices_manager_t *dm);
extern char *devices_manager_get(devices_manager_t *dm, const char *capability);
extern char *devices_manager_get_by_id(devices_manager_t *dm, const char *capability, uint32_t id);
extern int devices_manager_set(devices_manager_t *dm, const char *capability, struct json_object *node);
extern int devices_manager_set_state(devices_manager_t *dm, const char *capability, int id, bool state);
extern int devices_manager_create(devices_manager_t *dm, const char *a_capability, struct json_object *node);
extern int devices_manager_update(devices_manager_t *dm, const char *a_capability, struct json_object *node);
extern int devices_manager_delete(devices_manager_t *dm, const char *a_capability, struct json_object *node);
#endif /*_DEVICES_MANAGER_H */