Line data Source code
1 : /* File: observer.inl; Copyright and License: see below */
2 :
3 : #include "u8/u8_log.h"
4 : #include <assert.h>
5 :
6 0 : static inline void observer_init( observer_t *this_,
7 : void *observer_instance,
8 : void (*observer_callback)(void *observer_instance, void *call_param),
9 : const char* callback_name )
10 : {
11 0 : assert( NULL != observer_instance );
12 0 : assert( NULL != observer_callback );
13 0 : assert( NULL != callback_name );
14 0 : (*this_).observer_instance = observer_instance;
15 0 : (*this_).observer_callback = observer_callback;
16 0 : (*this_).callback_name = callback_name;
17 0 : }
18 :
19 0 : static inline void observer_destroy( observer_t *this_ )
20 : {
21 0 : (*this_).observer_instance = NULL;
22 0 : (*this_).observer_callback = NULL;
23 0 : }
24 :
25 0 : static inline void observer_notify( observer_t *this_, void *call_param )
26 : {
27 0 : assert( (*this_).observer_instance != NULL );
28 0 : assert( (*this_).observer_callback != NULL );
29 0 : U8_LOG_EVENT_STR("observer_notify() -->", (*this_).callback_name);
30 0 : ((*this_).observer_callback)( (*this_).observer_instance, call_param );
31 0 : }
32 :
33 :
34 : /*
35 : Copyright 2016-2025 Andreas Warnke
36 :
37 : Licensed under the Apache License, Version 2.0 (the "License");
38 : you may not use this file except in compliance with the License.
39 : You may obtain a copy of the License at
40 :
41 : http://www.apache.org/licenses/LICENSE-2.0
42 :
43 : Unless required by applicable law or agreed to in writing, software
44 : distributed under the License is distributed on an "AS IS" BASIS,
45 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 : See the License for the specific language governing permissions and
47 : limitations under the License.
48 : */
|