Libmacro  0.2
Libmacro is an extensible macro and hotkey library.
iregistry.h
Go to the documentation of this file.
1 /* Libmacro - A multi-platform, extendable macro and hotkey C library
2  Copyright (C) 2013 Jonathan Pelletier, New Paradigm Software
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
24 #ifndef MCR_BASE_IREGISTRY_H_
25 #define MCR_BASE_IREGISTRY_H_
26 
27 #include "mcr/base/interface.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
36 struct mcr_IRegistry {
38  void (*deinit)(struct mcr_IRegistry *);
39 
40  size_t (*id)(const struct mcr_IRegistry *, struct mcr_Interface *);
41  struct mcr_Interface *(*from_id)(const struct mcr_IRegistry *, size_t id);
42  const char *(*name)(const struct mcr_IRegistry *, struct mcr_Interface *);
43  struct mcr_Interface *(*from_name)(const struct mcr_IRegistry *,
44  const char *name);
51  size_t (*set_name)(struct mcr_IRegistry *, struct mcr_Interface *,
52  const char *name);
54  int (*add_names)(struct mcr_IRegistry *, struct mcr_Interface *,
55  const char * const*addNames, size_t addNamesCount);
57  void (*remove)(struct mcr_IRegistry *, struct mcr_Interface *);
59  void (*remove_name)(struct mcr_IRegistry *, const char *removeName);
61  size_t (*count)(const struct mcr_IRegistry *);
63  void (*trim)(struct mcr_IRegistry *);
65  void (*clear)(struct mcr_IRegistry *);
66 };
67 
79 MCR_API int mcr_register(struct mcr_IRegistry *iRegPt,
80  struct mcr_Interface *interfacePt, const char *name, const char * const*addNames,
81  size_t addNamesCount);
86 MCR_API void mcr_unregister(struct mcr_IRegistry *iRegPt,
87  struct mcr_Interface *interfacePt);
88 
93 MCR_API void mcr_IRegistry_init(struct mcr_IRegistry *iRegPt);
99 MCR_API void mcr_IRegistry_deinit(struct mcr_IRegistry *iRegPt);
100 MCR_API size_t mcr_IRegistry_id(const struct mcr_IRegistry *iRegPt,
101  struct mcr_Interface *interfacePt);
108 MCR_API struct mcr_Interface *mcr_IRegistry_from_id(const struct mcr_IRegistry
109  *iRegPt, size_t typeId);
110 MCR_API const char *mcr_IRegistry_name(const struct mcr_IRegistry *iRegPt,
111  struct mcr_Interface *interfacePt);
118 MCR_API struct mcr_Interface *mcr_IRegistry_from_name(const struct mcr_IRegistry
119  *iRegPt, const char *name);
127 MCR_API const char *mcr_IRegistry_id_name(const struct mcr_IRegistry *iRegPt,
128  size_t id);
135 MCR_API size_t mcr_IRegistry_name_id(const struct mcr_IRegistry *iRegPt,
136  const char *name);
143 MCR_API int mcr_IRegistry_set_name(struct mcr_IRegistry *iRegPt,
144  struct mcr_Interface *interfacePt, const char *name);
151 MCR_API int mcr_IRegistry_add_name(struct mcr_IRegistry *iRegPt,
152  struct mcr_Interface *interfacePt, const char *name);
160 MCR_API int mcr_IRegistry_add_names(struct mcr_IRegistry *iRegPt,
161  struct mcr_Interface *interfacePt, const char * const*addNames, size_t addNamesCount);
167 MCR_API size_t mcr_IRegistry_count(const struct mcr_IRegistry *iRegPt);
169 MCR_API void mcr_IRegistry_trim(struct mcr_IRegistry *iRegPt);
171 MCR_API void mcr_IRegistry_clear(struct mcr_IRegistry *iRegPt);
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 
177 #endif
MCR_API void mcr_IRegistry_init(struct mcr_IRegistry *iRegPt)
MCR_API void mcr_unregister(struct mcr_IRegistry *iRegPt, struct mcr_Interface *interfacePt)
void(* clear)(struct mcr_IRegistry *)
Definition: iregistry.h:65
MCR_API size_t mcr_IRegistry_name_id(const struct mcr_IRegistry *iRegPt, const char *name)
MCR_API size_t mcr_IRegistry_count(const struct mcr_IRegistry *iRegPt)
void(* remove_name)(struct mcr_IRegistry *, const char *removeName)
Remove the name without removing the interface.
Definition: iregistry.h:59
void(* trim)(struct mcr_IRegistry *)
Minimize allocation.
Definition: iregistry.h:63
MCR_API int mcr_register(struct mcr_IRegistry *iRegPt, struct mcr_Interface *interfacePt, const char *name, const char *const *addNames, size_t addNamesCount)
mcr_Interface
size_t(* set_name)(struct mcr_IRegistry *, struct mcr_Interface *, const char *name)
Definition: iregistry.h:51
MCR_API struct mcr_Interface * mcr_IRegistry_from_id(const struct mcr_IRegistry *iRegPt, size_t typeId)
MCR_API const char * mcr_IRegistry_id_name(const struct mcr_IRegistry *iRegPt, size_t id)
MCR_API int mcr_IRegistry_set_name(struct mcr_IRegistry *iRegPt, struct mcr_Interface *interfacePt, const char *name)
void(* deinit)(struct mcr_IRegistry *)
Notify this object is to be destroyed.
Definition: iregistry.h:38
MCR_API int mcr_IRegistry_add_names(struct mcr_IRegistry *iRegPt, struct mcr_Interface *interfacePt, const char *const *addNames, size_t addNamesCount)
size_t(* count)(const struct mcr_IRegistry *)
Get the total number of interfaces registered.
Definition: iregistry.h:61
MCR_API struct mcr_Interface * mcr_IRegistry_from_name(const struct mcr_IRegistry *iRegPt, const char *name)
MCR_API int mcr_IRegistry_add_name(struct mcr_IRegistry *iRegPt, struct mcr_Interface *interfacePt, const char *name)
MCR_API void mcr_IRegistry_clear(struct mcr_IRegistry *iRegPt)
int(* add_names)(struct mcr_IRegistry *, struct mcr_Interface *, const char *const *addNames, size_t addNamesCount)
Add names that will map to an interface.
Definition: iregistry.h:54
MCR_API void mcr_IRegistry_trim(struct mcr_IRegistry *iRegPt)
MCR_API void mcr_IRegistry_deinit(struct mcr_IRegistry *iRegPt)