00001
00002
00003
00004
00005
00006
00007
00008
00013 #ifndef _ATX_PROPERTIES_H_
00014 #define _ATX_PROPERTIES_H_
00015
00016
00017
00018
00019 #include "AtxInterfaces.h"
00020 #include "AtxTypes.h"
00021 #include "AtxIterator.h"
00022
00023
00024
00025
00026 #define ATX_ERROR_NO_SUCH_PROPERTY (ATX_ERROR_BASE_PROPERTIES - 0)
00027 #define ATX_ERROR_NO_SUCH_LISTENER (ATX_ERROR_BASE_PROPERTIES - 1)
00028 #define ATX_ERROR_PROPERTY_TYPE_MISMATCH (ATX_ERROR_BASE_PROPERTIES - 2)
00029
00030
00031
00032
00036 typedef enum {
00037 ATX_PROPERTY_TYPE_NONE,
00038 ATX_PROPERTY_TYPE_INTEGER,
00039 ATX_PROPERTY_TYPE_FLOAT,
00040 ATX_PROPERTY_TYPE_STRING,
00041 ATX_PROPERTY_TYPE_BOOLEAN,
00042 ATX_PROPERTY_TYPE_RAW_DATA
00043 } ATX_PropertyType;
00044
00045 typedef struct {
00046 ATX_Size size;
00047 ATX_Any data;
00048 } ATX_PropertyRawData;
00049
00054 typedef union {
00055 void* any;
00056 ATX_CString string;
00057 ATX_Int32 integer;
00058 ATX_Float fp;
00059 ATX_Boolean boolean;
00060 ATX_PropertyRawData raw_data;
00061 } ATX_PropertyValue;
00062
00063 typedef const void* ATX_PropertyListenerHandle;
00064
00069 typedef struct {
00070 ATX_CString name;
00071 ATX_PropertyType type;
00072 ATX_PropertyValue value;
00073 } ATX_Property;
00074
00075
00076
00077
00078 ATX_DECLARE_INTERFACE(ATX_PropertyListener)
00079 ATX_BEGIN_INTERFACE_DEFINITION(ATX_PropertyListener)
00080 void (*OnPropertyChanged)(ATX_PropertyListener* self,
00081 ATX_CString name,
00082 ATX_PropertyType type,
00083 const ATX_PropertyValue* value);
00084 ATX_END_INTERFACE_DEFINITION
00085
00086
00087
00088
00089 ATX_DECLARE_INTERFACE(ATX_Properties)
00098 ATX_BEGIN_INTERFACE_DEFINITION(ATX_Properties)
00110 ATX_Result (*GetProperty)(ATX_Properties* self,
00111 ATX_CString name,
00112 ATX_Property* property);
00113
00123 ATX_Result (*SetProperty)(ATX_Properties* self,
00124 ATX_CString name,
00125 ATX_PropertyType type,
00126 const ATX_PropertyValue* value);
00127
00134 ATX_Result (*UnsetProperty)(ATX_Properties* self,
00135 ATX_CString name);
00136
00142 ATX_Result (*Clear)(ATX_Properties* self);
00143
00144 ATX_Result (*GetIterator)(ATX_Properties* self,
00145 ATX_Iterator** iterator);
00146 #if 0
00147 ATX_Result (*AddAlias)(ATX_PropertiesInstance* instance,
00148 ATX_CString alias,
00149 ATX_CString name);
00150
00151 ATX_Result (*RemoveAlias)(ATX_PropertiesInstance* instance,
00152 ATX_CString alias);
00153
00163 ATX_Result (*GetAliases)(ATX_PropertiesInstance* instance,
00164 ATX_CString name,
00165 ATX_Iterator* iterator);
00166 #endif
00167 ATX_Result (*AddListener)(ATX_Properties* self,
00168 ATX_CString name,
00169 ATX_PropertyListener* listener,
00170 ATX_PropertyListenerHandle* handle);
00171
00172 ATX_Result (*RemoveListener)(ATX_Properties* self,
00173 ATX_PropertyListenerHandle handle);
00174
00175 ATX_END_INTERFACE_DEFINITION
00176
00177
00178
00179
00184 #define ATX_Properties_GetProperty(object, name, property) \
00185 ATX_INTERFACE(object)->GetProperty(object, \
00186 name, \
00187 property)
00188
00193 #define ATX_Properties_SetProperty(object, name, type, value) \
00194 ATX_INTERFACE(object)->SetProperty(object, \
00195 name, \
00196 type, \
00197 value)
00198
00203 #define ATX_Properties_UnsetProperty(object, name) \
00204 ATX_INTERFACE(object)->UnsetProperty(object, name)
00205
00210 #define ATX_Properties_Clear(object) \
00211 ATX_INTERFACE(object)->Clear(object)
00212
00217 #define ATX_Properties_GetIterator(object, iterator) \
00218 ATX_INTERFACE(object)->GetIterator(object, iterator)
00219
00224 #define ATX_Properties_AddListener(object, name, listener, handle) \
00225 ATX_INTERFACE(object)->AddListener(object, \
00226 name, \
00227 listener, \
00228 handle)
00229
00234 #define ATX_Properties_RemoveListener(object, handle) \
00235 ATX_INTERFACE(object)->RemoveListener(object, handle)
00236
00241 #define ATX_PropertyListener_OnPropertyChanged(object, name, type, value) \
00242 ATX_INTERFACE(object)->OnPropertyChanged(object, \
00243 name, \
00244 type, \
00245 value)
00246
00247
00248
00249
00250 #ifdef __cplusplus
00251 extern "C" {
00252 #endif
00253
00254 ATX_Result ATX_Properties_Create(ATX_Properties** properties);
00255
00256 #ifdef __cplusplus
00257 }
00258 #endif
00259
00260 #endif
00261
00262
00263
00264
00265
00266
00267
00268
00269