Libmacro  0.2
Libmacro is an extensible macro and hotkey library.
interface.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 
23 #ifndef MCR_BASE_INTERFACE_H_
24 #define MCR_BASE_INTERFACE_H_
25 
26 #include "mcr/base/data_member.h"
27 #include "mcr/base/types.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
34 struct mcr_Interface {
37  size_t id;
40  size_t data_size;
45 
47  void *(*allocate)();
49  void (*deallocate)(void *);
59 };
60 
61 /* Interface */
66 MCR_API void mcr_Interface_init(struct mcr_Interface *interfacePt);
79 MCR_API void mcr_Interface_ctor(struct mcr_Interface *interfacePt,
80  struct mcr_context *context,
81  size_t dataSize, void *(*allocate)(), void (*deallocate)(void *),
89 MCR_API void mcr_Interface_deinit(struct mcr_Interface *interfacePt);
90 
101 MCR_API void mcr_Interface_set_all(struct mcr_Interface *interfacePt,
102  struct mcr_context *context, size_t dataSize,
103  void *(*allocate)(), void (*deallocate)(void *),
106 
112 MCR_API size_t mcr_Interface_id(struct mcr_Interface *interfacePt);
113 
114 /* Interface functions on data */
125 MCR_API int mcr_Interface_allocate(const struct mcr_Interface *interfacePt,
126  struct mcr_DataMember *dataMemberPt);
127 
137 MCR_API int mcr_Interface_deallocate(const struct mcr_Interface *interfacePt,
138  struct mcr_DataMember *dataMemberPt);
139 
148 MCR_API int mcr_Interface_compare(const struct mcr_Interface *interfacePt,
149  const struct mcr_DataMember *lhs, const struct mcr_DataMember *rhs);
150 
160 MCR_API int mcr_Interface_copy(const struct mcr_Interface *interfacePt,
161  struct mcr_DataMember *dstPt,
162  const struct mcr_DataMember *srcPt);
163 
175 MCR_API int mcr_Interface_set_data(const struct mcr_Interface *interfacePt,
176  struct mcr_DataMember *dataMemberPt, void *data, bool heapFlag);
177 
186 MCR_API int mcr_Interface_reset(const struct mcr_Interface *interfacePt,
187  struct mcr_DataMember *dataMemberPt);
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #endif
int(* mcr_compare_fnc)(const void *lhsPt, const void *rhsPt)
Definition: comparison.h:53
struct mcr_context * context
Definition: interface.h:42
mcr_compare_fnc compare
Definition: interface.h:55
void *(* allocate)()
Definition: interface.h:47
MCR_API int mcr_Interface_allocate(const struct mcr_Interface *interfacePt, struct mcr_DataMember *dataMemberPt)
Forward declaration of types.
MCR_API void mcr_Interface_set_all(struct mcr_Interface *interfacePt, struct mcr_context *context, size_t dataSize, void *(*allocate)(), void(*deallocate)(void *), mcr_data_fnc init, mcr_data_fnc deinit, mcr_compare_fnc compare, mcr_copy_fnc copy)
size_t data_size
Definition: interface.h:40
MCR_API int mcr_Interface_reset(const struct mcr_Interface *interfacePt, struct mcr_DataMember *dataMemberPt)
MCR_API int mcr_Interface_deallocate(const struct mcr_Interface *interfacePt, struct mcr_DataMember *dataMemberPt)
int(* mcr_data_fnc)(void *dataPt)
Definition: comparison.h:39
mcr_copy_fnc copy
Definition: interface.h:58
struct mcr_IRegistry * registry
Definition: interface.h:44
mcr_data_fnc deinit
Definition: interface.h:53
void(* deallocate)(void *)
Definition: interface.h:49
int(* mcr_copy_fnc)(void *destinationPt, const void *sourcePt)
Definition: comparison.h:46
MCR_API int mcr_Interface_compare(const struct mcr_Interface *interfacePt, const struct mcr_DataMember *lhs, const struct mcr_DataMember *rhs)
MCR_API void mcr_Interface_ctor(struct mcr_Interface *interfacePt, struct mcr_context *context, size_t dataSize, void *(*allocate)(), void(*deallocate)(void *), mcr_data_fnc init, mcr_data_fnc deinit, mcr_compare_fnc compare, mcr_copy_fnc copy)
MCR_API int mcr_Interface_copy(const struct mcr_Interface *interfacePt, struct mcr_DataMember *dstPt, const struct mcr_DataMember *srcPt)
MCR_API int mcr_Interface_set_data(const struct mcr_Interface *interfacePt, struct mcr_DataMember *dataMemberPt, void *data, bool heapFlag)
mcr_DataMember
mcr_data_fnc init
Definition: interface.h:51
MCR_API size_t mcr_Interface_id(struct mcr_Interface *interfacePt)
MCR_API void mcr_Interface_init(struct mcr_Interface *interfacePt)
MCR_API void mcr_Interface_deinit(struct mcr_Interface *interfacePt)
size_t id
Definition: interface.h:37