Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/message_bus/wm_message_bus.h
- This file was added.
| /* | |||||
| * ***** BEGIN GPL LICENSE BLOCK ***** | |||||
| * | |||||
| * This program is free software; you can redistribute it and/or | |||||
| * modify it under the terms of the GNU General Public License | |||||
| * as published by the Free Software Foundation; either version 2 | |||||
| * of the License, or (at your option) any later version. | |||||
| * | |||||
| * This program is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| * GNU General Public License for more details. | |||||
| * | |||||
| * You should have received a copy of the GNU General Public License | |||||
| * along with this program; if not, write to the Free Software Foundation, | |||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||||
| * | |||||
| * ***** END GPL LICENSE BLOCK ***** | |||||
| */ | |||||
| /** \file blender/windowmanager/wm_message_bus.h | |||||
| * \ingroup wm | |||||
| */ | |||||
| #ifndef __WM_MESSAGE_TYPES_H__ | |||||
| #define __WM_MESSAGE_TYPES_H__ | |||||
| struct wmMsg; | |||||
| struct bContext; | |||||
| struct GSet; | |||||
| /* opaque (don't expose outside wm_message_bus.c) */ | |||||
| struct wmMsgBus; | |||||
| struct wmMsgSubscribeKey; | |||||
| struct wmMsgSubscribeValue; | |||||
| typedef void (*wmMsgNotifyFn)( | |||||
| struct bContext *C, struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val); | |||||
| #define WM_MSG_TYPE_NUM 1 | |||||
| enum { | |||||
| WM_MSG_TYPE_RNA = 0, | |||||
| }; | |||||
| #ifdef WM_MESSAGE_BUS_INTERN | |||||
| struct wmMsgBus { | |||||
| struct GSet *messages_gset[WM_MSG_TYPE_NUM]; | |||||
| /* Messages in order of being added. */ | |||||
| ListBase messages; | |||||
| }; | |||||
| #endif | |||||
| // struct wmWindowManager { | |||||
| // struct wmMessageBus *msg_bus; | |||||
| // } | |||||
| typedef struct wmMsgTypeInfo { | |||||
| struct { | |||||
| unsigned int (*hash_fn)(const void *msg); | |||||
| bool (*cmp_fn)(const void *a, const void *b); | |||||
| void (*key_free_fn)(void *key); | |||||
| } gset; | |||||
| } wmMsgTypeInfo; | |||||
| typedef struct wmMsg { | |||||
| unsigned int type; | |||||
| // #ifdef DEBUG | |||||
| /* For debugging: '__func__:__LINE__'. */ | |||||
| const char *id; | |||||
| // #endif | |||||
| } wmMsg; | |||||
| typedef struct wmMsgSubscribeKey { | |||||
| /** Single linked list for predicable ordering, otherwise we would depend on ghash bucketing. */ | |||||
| struct wmMsgSubscribeKey *next, *prev; | |||||
| ListBase values; | |||||
mont29: That’s rather double linked list imho? Or did you mean 'simple linked list'? ;) | |||||
| /* over-alloc, eg: wmMsgSubscribeKey_RNA */ | |||||
| wmMsg msg[0]; | |||||
| } wmMsgSubscribeKey; | |||||
| /** One of many in #wmMsgSubscribeKey.values */ | |||||
| typedef struct wmMsgSubscribeValue { | |||||
| /** Single linked list for predicable ordering, otherwise we would depend on ghash bucketing. */ | |||||
| struct wmMsgSubscribe *next, *prev; | |||||
Done Inline ActionsThat’s rather double linked list imho? Or did you mean 'simple linked list'? ;) mont29: That’s rather double linked list imho? Or did you mean 'simple linked list'? ;) | |||||
| /** handle, used to iterate and clear. */ | |||||
| void *owner; | |||||
| void *user_data; | |||||
| wmMsgNotifyFn notify; | |||||
| /* tag to run when handling events, | |||||
| * we may want option for immediate execution. */ | |||||
| uint tag : 1; | |||||
| } wmMsgSubscribeValue; | |||||
| /** One of many in #wmMsgSubscribeKey.values */ | |||||
| typedef struct wmMsgSubscribeValueLink { | |||||
| /** Single linked list for predicable ordering, otherwise we would depend on ghash bucketing. */ | |||||
| struct wmMsgSubscribeValueLink *next, *prev; | |||||
| wmMsgSubscribeValue params; | |||||
Done Inline ActionsThat’s rather double linked list imho? Or did you mean 'simple linked list'? ;) mont29: That’s rather double linked list imho? Or did you mean 'simple linked list'? ;) | |||||
| } wmMsgSubscribeValueLink; | |||||
| void WM_msgbus_types_init(void); | |||||
| struct wmMsgBus *WM_msgbus_create(void); | |||||
| void WM_msgbus_destroy(struct wmMsgBus *mbus); | |||||
| void WM_msgbus_clear_by_owner(struct wmMsgBus *mbus, void *owner); | |||||
| void WM_msgbus_handle(struct wmMsgBus *mbus, struct bContext *C); | |||||
| void WM_msg_publish_with_key(struct wmMsgBus *mbus, wmMsgSubscribeKey *key); | |||||
| /* wm_message_bus_rna.c */ | |||||
| typedef struct wmMsgParams_RNA { | |||||
| /** when #PointerRNA.data & id.data are NULL. match against all. */ | |||||
| PointerRNA ptr; | |||||
| /** when NULL, match against any property. */ | |||||
| PropertyRNA *prop; | |||||
| } wmMsgParams_RNA; | |||||
| typedef struct wmMsg_RNA { | |||||
| wmMsg head; /* keep first */ | |||||
| wmMsgParams_RNA params; | |||||
| } wmMsg_RNA; | |||||
| typedef struct wmMsgSubscribeKey_RNA { | |||||
| wmMsgSubscribeKey head; | |||||
| wmMsg_RNA msg; | |||||
| } wmMsgSubscribeKey_RNA; | |||||
| void WM_msgtypeinfo_init_rna(wmMsgTypeInfo *msg_type); | |||||
| wmMsgSubscribeKey_RNA *WM_msg_lookup_rna( | |||||
| struct wmMsgBus *mbus, const wmMsgParams_RNA *msg_key_params); | |||||
| void WM_msg_subscribe_rna( | |||||
| struct wmMsgBus *mbus, | |||||
| const wmMsgParams_RNA *msg_key_params, | |||||
| const wmMsgSubscribeValue *msg_val_params); | |||||
| void WM_msg_publish_rna( | |||||
| struct wmMsgBus *mbus, const wmMsgParams_RNA *msg_key_params); | |||||
| #endif /* __WM_MESSAGE_TYPES_H__ */ | |||||
That’s rather double linked list imho? Or did you mean 'simple linked list'? ;)