summaryrefslogtreecommitdiffstats
path: root/src/device.h
blob: e44c6951b89a2dbe26cb837e9743b85aa04f8e6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#pragma once

#include <json-c/json.h>
#include <libubox/avl.h>

extern struct avl_tree device_types;

typedef struct _device_type device_type_t;

typedef struct _device {
	struct avl_node node;
	const device_type_t *type;
} device_t;

struct _device_type {
	struct avl_node node;
	device_t * (*process_config)(const char *name, struct json_object *config);
	void (*free)(device_t *device);

	void (*init)(device_t *device);
	void (*update)(device_t *device);
	void (*release)(device_t *device);
};

void register_device_type(const char *name, device_type_t *device_type);
const device_type_t * get_device_type(const char *name);