orx  1.10
Portable Game Engine
orxEvent.h
Go to the documentation of this file.
1 /* Orx - Portable Game Engine
2  *
3  * Copyright (c) 2008-2019 Orx-Project
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  *
18  * 2. Altered source versions must be plainly marked as such, and must not be
19  * misrepresented as being the original software.
20  *
21  * 3. This notice may not be removed or altered from any source
22  * distribution.
23  */
24 
42 #ifndef _orxEVENT_H_
43 #define _orxEVENT_H_
44 
45 #include "orxInclude.h"
46 
47 
50 #define orxEVENT_INIT(EVENT, TYPE, ID, SENDER, RECIPIENT, PAYLOAD) \
51 do \
52 { \
53  EVENT.eType = (orxEVENT_TYPE)(TYPE); \
54  EVENT.eID = (orxENUM)(ID); \
55  EVENT.hSender = (orxHANDLE)(SENDER); \
56  EVENT.hRecipient = (orxHANDLE)(RECIPIENT); \
57  EVENT.pstPayload = (void *)(PAYLOAD); \
58 } while(orxFALSE)
59 
60 #define orxEVENT_SEND(TYPE, ID, SENDER, RECIPIENT, PAYLOAD) \
61 do \
62 { \
63  orxEVENT stEvent; \
64  orxEVENT_INIT(stEvent, TYPE, ID, SENDER, RECIPIENT, PAYLOAD); \
65  orxEvent_Send(&stEvent); \
66 } while(orxFALSE)
67 
68 #define orxEVENT_GET_FLAG(ID) ((orxU32)(1U << (orxU32)(ID)))
69 #define orxEVENT_KU32_FLAG_ID_NONE 0x00000000
70 #define orxEVENT_KU32_MASK_ID_ALL 0xFFFFFFFF
71 
72 
75 typedef enum __orxEVENT_TYPE_t
76 {
95 
97 
99 
101 
103 
104  orxEVENT_TYPE_NONE = orxENUM_NONE,
105 
106 } orxEVENT_TYPE;
107 
110 typedef struct __orxEVENT_t
111 {
113  orxENUM eID;
114  orxHANDLE hSender;
115  orxHANDLE hRecipient;
116  void *pstPayload;
117  void *pContext;
119 } orxEVENT;
120 
121 
125 typedef orxSTATUS (orxFASTCALL *orxEVENT_HANDLER)(const orxEVENT *_pstEvent);
126 
127 
130 extern orxDLLAPI void orxFASTCALL orxEvent_Setup();
131 
135 extern orxDLLAPI orxSTATUS orxFASTCALL orxEvent_Init();
136 
139 extern orxDLLAPI void orxFASTCALL orxEvent_Exit();
140 
146 extern orxDLLAPI orxSTATUS orxFASTCALL orxEvent_AddHandler(orxEVENT_TYPE _eEventType, orxEVENT_HANDLER _pfnEventHandler);
147 
154 extern orxDLLAPI orxSTATUS orxFASTCALL orxEvent_AddHandlerWithContext(orxEVENT_TYPE _eEventType, orxEVENT_HANDLER _pfnEventHandler, void *_pContext);
155 
161 extern orxDLLAPI orxSTATUS orxFASTCALL orxEvent_RemoveHandler(orxEVENT_TYPE _eEventType, orxEVENT_HANDLER _pfnEventHandler);
162 
169 extern orxDLLAPI orxSTATUS orxFASTCALL orxEvent_RemoveHandlerWithContext(orxEVENT_TYPE _eEventType, orxEVENT_HANDLER _pfnEventHandler, void *_pContext);
170 
179 extern orxDLLAPI orxSTATUS orxFASTCALL orxEvent_SetHandlerIDFlags(orxEVENT_HANDLER _pfnEventHandler, orxEVENT_TYPE _eEventType, void *_pContext, orxU32 _u32AddIDFlags, orxU32 _u32RemoveIDFlags);
180 
185 extern orxDLLAPI orxSTATUS orxFASTCALL orxEvent_Send(orxEVENT *_pstEvent);
186 
192 extern orxDLLAPI orxSTATUS orxFASTCALL orxEvent_SendShort(orxEVENT_TYPE _eEventType, orxENUM _eEventID);
193 
197 extern orxDLLAPI orxBOOL orxFASTCALL orxEvent_IsSending();
198 
199 #endif /*_orxEVENT_H_*/
200 
orxDLLAPI void orxFASTCALL orxEvent_Setup()
orxDLLAPI orxSTATUS orxFASTCALL orxEvent_RemoveHandler(orxEVENT_TYPE _eEventType, orxEVENT_HANDLER _pfnEventHandler)
void * pContext
Definition: orxEvent.h:117
orxDLLAPI orxBOOL orxFASTCALL orxEvent_IsSending()
orxDLLAPI void orxFASTCALL orxEvent_Exit()
orxDLLAPI orxSTATUS orxFASTCALL orxEvent_Send(orxEVENT *_pstEvent)
orxEVENT_TYPE eType
Definition: orxEvent.h:112
orxDLLAPI orxSTATUS orxFASTCALL orxEvent_AddHandler(orxEVENT_TYPE _eEventType, orxEVENT_HANDLER _pfnEventHandler)
orxDLLAPI orxSTATUS orxFASTCALL orxEvent_SendShort(orxEVENT_TYPE _eEventType, orxENUM _eEventID)
orxDLLAPI orxSTATUS orxFASTCALL orxEvent_RemoveHandlerWithContext(orxEVENT_TYPE _eEventType, orxEVENT_HANDLER _pfnEventHandler, void *_pContext)
orxDLLAPI orxSTATUS orxFASTCALL orxEvent_SetHandlerIDFlags(orxEVENT_HANDLER _pfnEventHandler, orxEVENT_TYPE _eEventType, void *_pContext, orxU32 _u32AddIDFlags, orxU32 _u32RemoveIDFlags)
orxDLLAPI orxSTATUS orxFASTCALL orxEvent_Init()
orxDLLAPI orxSTATUS orxFASTCALL orxEvent_AddHandlerWithContext(orxEVENT_TYPE _eEventType, orxEVENT_HANDLER _pfnEventHandler, void *_pContext)
orxSTATUS(orxFASTCALL * orxEVENT_HANDLER)(const orxEVENT *_pstEvent)
Definition: orxEvent.h:125
orxSTATUS
Definition: orxType.h:246
orxENUM eID
Definition: orxEvent.h:113
#define orxDLLAPI
Definition: orxDecl.h:381
orxHANDLE hRecipient
Definition: orxEvent.h:115
void * pstPayload
Definition: orxEvent.h:116
orxHANDLE hSender
Definition: orxEvent.h:114
orxEVENT_TYPE
Definition: orxEvent.h:75

Generated for orx by doxygen 1.8.11