2 * Copyright (C) 2016, 2017 "IoT.bzh"
3 * Author: José Bollo <jose.bollo@iot.bzh>
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include "afb-eventid-itf.h"
23 * Broadcasts widely an event of 'eventid' with the data 'object'.
24 * 'object' can be NULL.
26 * For convenience, the function calls 'json_object_put' for 'object'.
27 * Thus, in the case where 'object' should remain available after
28 * the function returns, the function 'json_object_get' shall be used.
30 * Returns the count of clients that received the event.
32 static inline int afb_eventid_broadcast(struct afb_eventid *eventid, struct json_object *object)
34 return eventid->itf->broadcast(eventid, object);
38 * Pushes an event of 'eventid' with the data 'object' to its observers.
39 * 'object' can be NULL.
41 * For convenience, the function calls 'json_object_put' for 'object'.
42 * Thus, in the case where 'object' should remain available after
43 * the function returns, the function 'json_object_get' shall be used.
45 * Returns the count of clients that received the event.
47 static inline int afb_eventid_push(struct afb_eventid *eventid, struct json_object *object)
49 return eventid->itf->push(eventid, object);
53 * Gets the name associated to 'eventid'.
55 static inline const char *afb_eventid_name(struct afb_eventid *eventid)
57 return eventid->itf->name(eventid);
61 * Decrease the count of reference to 'eventid' and
62 * destroys the eventid when the reference count falls to zero.
64 static inline void afb_eventid_unref(struct afb_eventid *eventid)
66 eventid->itf->unref(eventid);
70 * Increases the count of reference to 'eventid'
72 static inline struct afb_eventid *afb_eventid_addref(struct afb_eventid *eventid)
74 return eventid->itf->addref(eventid);