Update copyright dates
[src/app-framework-binder.git] / src / afb-apiset.h
1 /*
2  * Copyright (C) 2015-2020 "IoT.bzh"
3  * Author: José Bollo <jose.bollo@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #pragma once
19
20 struct afb_api_item;
21 struct afb_apiset;
22 struct json_object;
23
24 extern struct afb_apiset *afb_apiset_create(const char *name, int timeout);
25 extern struct afb_apiset *afb_apiset_create_subset_last(struct afb_apiset *set, const char *name, int timeout);
26 extern struct afb_apiset *afb_apiset_create_subset_first(struct afb_apiset *set, const char *name, int timeout);
27 extern struct afb_apiset *afb_apiset_addref(struct afb_apiset *set);
28 extern void afb_apiset_unref(struct afb_apiset *set);
29
30 extern const char *afb_apiset_name(struct afb_apiset *set);
31
32 extern int afb_apiset_timeout_get(struct afb_apiset *set);
33 extern void afb_apiset_timeout_set(struct afb_apiset *set, int to);
34
35 extern void afb_apiset_onlack_set(
36                 struct afb_apiset *set,
37                 int (*callback)(void *closure, struct afb_apiset *set, const char *name),
38                 void *closure,
39                 void (*cleanup)(void*closure));
40
41 extern int afb_apiset_subset_set(struct afb_apiset *set, struct afb_apiset *subset);
42 extern struct afb_apiset *afb_apiset_subset_get(struct afb_apiset *set);
43
44 extern int afb_apiset_add(struct afb_apiset *set, const char *name, struct afb_api_item api);
45 extern int afb_apiset_del(struct afb_apiset *set, const char *name);
46
47 extern int afb_apiset_add_alias(struct afb_apiset *set, const char *name, const char *alias);
48 extern int afb_apiset_is_alias(struct afb_apiset *set, const char *name);
49 extern const char *afb_apiset_unalias(struct afb_apiset *set, const char *name);
50
51 extern const struct afb_api_item *afb_apiset_lookup(struct afb_apiset *set, const char *name, int rec);
52 extern const struct afb_api_item *afb_apiset_lookup_started(struct afb_apiset *set, const char *name, int rec);
53
54 extern int afb_apiset_start_service(struct afb_apiset *set, const char *name);
55 extern int afb_apiset_start_all_services(struct afb_apiset *set);
56
57 #if WITH_AFB_HOOK
58 extern void afb_apiset_update_hooks(struct afb_apiset *set, const char *name);
59 #endif
60 extern void afb_apiset_set_logmask(struct afb_apiset *set, const char *name, int mask);
61 extern int afb_apiset_get_logmask(struct afb_apiset *set, const char *name);
62
63 extern void afb_apiset_describe(struct afb_apiset *set, const char *name, void (*describecb)(void *, struct json_object *), void *closure);
64
65 extern const char **afb_apiset_get_names(struct afb_apiset *set, int rec, int type);
66 extern void afb_apiset_enum(
67                         struct afb_apiset *set,
68                         int rec,
69                         void (*callback)(void *closure, struct afb_apiset *set, const char *name, int isalias),
70                         void *closure);
71
72 extern int afb_apiset_require(struct afb_apiset *set, const char *name, const char *required);
73 extern int afb_apiset_require_class(struct afb_apiset *set, const char *apiname, const char *classname);
74 extern int afb_apiset_provide_class(struct afb_apiset *set, const char *apiname, const char *classname);
75 extern int afb_apiset_class_start(const char *classname);