00001 #ifndef __CPHIDGETDICTIONARY
00002 #define __CPHIDGETDICTIONARY
00003 #include "cphidget.h"
00004
00013 typedef enum {
00014 PHIDGET_DICTIONARY_VALUE_CHANGED = 1,
00015 PHIDGET_DICTIONARY_ENTRY_ADDED,
00016 PHIDGET_DICTIONARY_ENTRY_REMOVING,
00017 PHIDGET_DICTIONARY_CURRENT_VALUE
00018 } CPhidgetDictionary_keyChangeReason;
00019
00023 DPHANDLE(Dictionary)
00027 DPHANDLE(DictionaryListener)
00028
00029 #ifndef EXTERNALPROTO
00030
00031 typedef struct _CPhidgetDictionaryListener
00032 {
00033 CPhidgetDictionaryHandle dict;
00034 int(CCONV *fptr)(CPhidgetDictionaryHandle dict, void *userPtr, const char *key, const char *val, CPhidgetDictionary_keyChangeReason reason);
00035 void *userPtr;
00036 int listen_id;
00037 } CPhidgetDictionaryListener;
00038
00039 typedef struct _CPhidgetDictionaryListenerList
00040 {
00041 struct _CPhidgetDictionaryListenerList *next;
00042 CPhidgetDictionaryListenerHandle listener;
00043 } CPhidgetDictionaryListenerList, *CPhidgetDictionaryListenerListHandle;
00044
00045 typedef struct _CPhidgetDictionary
00046 {
00047 CPhidgetRemoteHandle networkInfo;
00048 int(CCONV *fptrError)(CPhidgetDictionaryHandle , void *, int, const char *);
00049 void *fptrErrorptr;
00050 int(CCONV *fptrServerConnect)(CPhidgetDictionaryHandle , void *);
00051 void *fptrServerConnectptr;
00052 int(CCONV *fptrServerDisconnect)(CPhidgetDictionaryHandle , void *);
00053 void *fptrServerDisconnectptr;
00054 CThread_mutex_t lock;
00055 int status;
00056 CThread_mutex_t openCloseLock;
00057 CPhidgetDictionaryListenerListHandle listeners;
00058 CThread_mutex_t listenersLock;
00059 } CPhidgetDictionary;
00060
00061 typedef struct _CPhidgetDictionaryList
00062 {
00063 struct _CPhidgetDictionaryList *next;
00064 CPhidgetDictionaryHandle dict;
00065 } CPhidgetDictionaryList, *CPhidgetDictionaryListHandle;
00066
00067 int CPhidgetDictionary_areEqual(void *arg1, void *arg2);
00068 void CPhidgetDictionary_free(void *arg);
00069 int CPhidgetDictionaryListener_areEqual(void *arg1, void *arg2);
00070 void CPhidgetDictionaryListener_free(void *arg);
00071
00072 #endif
00073
00077 PHIDGET21_API int CCONV CPhidgetDictionary_create(CPhidgetDictionaryHandle *dict);
00082 PHIDGET21_API int CCONV CPhidgetDictionary_close(CPhidgetDictionaryHandle dict);
00087 PHIDGET21_API int CCONV CPhidgetDictionary_delete(CPhidgetDictionaryHandle dict);
00094 PHIDGET21_API int CCONV CPhidgetDictionary_set_OnError_Handler(CPhidgetDictionaryHandle dict,
00095 int(CCONV *fptr)(CPhidgetDictionaryHandle, void *userPtr, int errorCode, const char *errorString), void *userPtr);
00103 PHIDGET21_API int CCONV CPhidgetDictionary_addKey(CPhidgetDictionaryHandle dict, const char *key, const char *value, int persistent);
00109 PHIDGET21_API int CCONV CPhidgetDictionary_removeKey(CPhidgetDictionaryHandle dict, const char *pattern);
00118 typedef int(CCONV *CPhidgetDictionary_OnKeyChange_Function)(CPhidgetDictionaryHandle dict, void *userPtr,
00119 const char *key, const char *value, CPhidgetDictionary_keyChangeReason reason);
00129 PHIDGET21_API int CCONV CPhidgetDictionary_set_OnKeyChange_Handler(CPhidgetDictionaryHandle dict, CPhidgetDictionaryListenerHandle *dictlistener, const char *pattern,
00130 CPhidgetDictionary_OnKeyChange_Function fptr, void *userPtr);
00135 PHIDGET21_API int CCONV CPhidgetDictionary_remove_OnKeyChange_Handler(CPhidgetDictionaryListenerHandle dictlistener);
00143 PHIDGET21_API int CCONV CPhidgetDictionary_getKey(CPhidgetDictionaryHandle dict, const char *key, char *value, int valuelen);
00150 PHIDGET21_API int CCONV CPhidgetDictionary_set_OnServerConnect_Handler(CPhidgetDictionaryHandle dict, int (CCONV *fptr)(CPhidgetDictionaryHandle dict, void *userPtr), void *userPtr);
00157 PHIDGET21_API int CCONV CPhidgetDictionary_set_OnServerDisconnect_Handler(CPhidgetDictionaryHandle dict, int (CCONV *fptr)(CPhidgetDictionaryHandle dict, void *userPtr), void *userPtr);
00163 PHIDGET21_API int CCONV CPhidgetDictionary_getServerID(CPhidgetDictionaryHandle dict, const char **serverID);
00170 PHIDGET21_API int CCONV CPhidgetDictionary_getServerAddress(CPhidgetDictionaryHandle dict, const char **address, int *port);
00176 PHIDGET21_API int CCONV CPhidgetDictionary_getServerStatus(CPhidgetDictionaryHandle dict, int *serverStatus);
00178 #endif