Papageno
An Advanced Pattern Matching Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
ppg_action.h
Go to the documentation of this file.
1 /* Copyright 2017 noseglasses <shinynoseglasses@gmail.com>
2  *
3  * This program is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef PPG_ACTION_H
18 #define PPG_ACTION_H
19 
22 #include "ppg_signals.h"
23 
24 #include <stddef.h>
25 #include <stdbool.h>
26 
32 typedef void (*PPG_Action_Callback_Fun)(bool activation, void *user_data);
33 
37 typedef struct {
39  void * user_data;
41 
46 inline
48 {
49  cb->func = NULL;
50  cb->user_data = NULL;
51 }
52 
55 typedef struct {
57 } PPG_Action;
58 
63 #define PPG_ACTION_USER_CALLBACK(FUNC, USER_DATA) \
64  (PPG_Action) { \
65  .callback = (PPG_Action_Callback) { \
66  .func = (PPG_Action_Callback_Fun)FUNC, \
67  .user_data = USER_DATA \
68  } \
69  }
70 
73 #define PPG_ACTION_NOOP \
74  (PPG_Action) { \
75  .callback = (PPG_Action_Callback) { \
76  .func = NULL, \
77  .user_data = NULL \
78  } \
79  }
80 
81 #endif
Action information.
Definition: ppg_action.h:55
void * user_data
Optional user data that is passed to the callback when called.
Definition: ppg_action.h:39
The PPG_Action_Callback struct groups use callback information in an object oriented fashion (functor...
Definition: ppg_action.h:37
void(* PPG_Action_Callback_Fun)(bool activation, void *user_data)
Function type of user callback functions.
Definition: ppg_action.h:32
PPG_Action_Callback_Fun func
The callback function.
Definition: ppg_action.h:38
PPG_Action_Callback callback
The user callback that represents that action.
Definition: ppg_action.h:56
void ppg_action_callback_init(PPG_Action_Callback *cb)
This function initializes an action callback.
Definition: ppg_action.h:47