Idź do dokumentacji tego pliku.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __EKG_OBJECTS_H
00021 #define __EKG_OBJECTS_H
00022
00023 #include "xmalloc.h"
00024
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028
00029 #define PROPERTY_INT_GET(object,property,type) \
00030 \
00031 type object##_##property##_get(object##_t *o) \
00032 { \
00033 return (o) ? o->property : -1; \
00034 }
00035
00036 #define PROPERTY_INT_SET(object,property,type) \
00037 \
00038 int object##_##property##_set(object##_t *o, type v) \
00039 { \
00040 if (!o) \
00041 return -1; \
00042 \
00043 o->property = v; \
00044 \
00045 return 0; \
00046 }
00047
00048 #define PROPERTY_INT(object,property,type) \
00049 \
00050 PROPERTY_INT_GET(object,property,type) \
00051 PROPERTY_INT_SET(object,property,type)
00052
00053
00054
00055 #define PROPERTY_STRING_GET(object,property) \
00056 \
00057 const char *object##_##property##_get(object##_t *o) \
00058 { \
00059 return (o) ? o->property : NULL; \
00060 }
00061
00062
00063 #define PROPERTY_STRING_SET(object,property) \
00064 \
00065 int object##_##property##_set(object##_t *o, const char *v) \
00066 { \
00067 if (!o) \
00068 return -1; \
00069 \
00070 xfree(o->property); \
00071 o->property = xstrdup(v); \
00072 \
00073 return 0; \
00074 }
00075
00076 #define PROPERTY_STRING(object,property) \
00077 \
00078 PROPERTY_STRING_SET(object, property) \
00079 PROPERTY_STRING_GET(object, property)
00080
00081
00082 #define PROPERTY_PRIVATE_GET(object) \
00083 \
00084 void *object##_private_get(object##_t *o) \
00085 { \
00086 return (o) ? o->priv : NULL; \
00087 }
00088
00089 #define PROPERTY_PRIVATE_SET(object) \
00090 \
00091 int object##_private_set(object##_t *o, void *v) \
00092 { \
00093 if (!o) \
00094 return -1; \
00095 \
00096 o->priv = v; \
00097 \
00098 return 0; \
00099 }
00100
00101 #define PROPERTY_PRIVATE(object) \
00102 \
00103 PROPERTY_PRIVATE_GET(object) \
00104 PROPERTY_PRIVATE_SET(object)
00105
00106
00107 #define PROPERTY_MISC_GET(object,property,type,null) \
00108 \
00109 type object##_##property##_get(object##_t *o) \
00110 { \
00111 return (o) ? o->property : null; \
00112 }
00113
00114 #define PROPERTY_MISC_SET(object,property,type) \
00115 \
00116 int object##_##property##_set(object##_t *o, type v) \
00117 { \
00118 if (!o) \
00119 return -1; \
00120 \
00121 o->property = v; \
00122 \
00123 return 0; \
00124 }
00125
00126 #define PROPERTY_MISC(object,property,type,null) \
00127 \
00128 PROPERTY_MISC_GET(object,property,type,null) \
00129 PROPERTY_MISC_SET(object,property,type)
00130
00131 #ifdef __cplusplus
00132 }
00133 #endif
00134
00135 #endif
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145