Go to the documentation of this file.00001 #ifndef recoveryStore_H
00002 #define recoveryStore_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __cplusplus
00015 #error This is a C++ include file and cannot be used from plain C
00016 #endif
00017
00018 #include <acsutil.h>
00019 #include <recoveryExport.h>
00020
00021 #include <ace/pre.h>
00022 #include <ace/SString.h>
00023 #include <ace/Hash_Map_Manager.h>
00024 #include <Thread_Mutex.h>
00025 #include <Recursive_Thread_Mutex.h>
00026
00027 namespace recovery {
00028
00032 #define MAX_RECORD_SIZE 1500
00033
00037 #define SEPARATOR_CHAR 1
00038
00051 class recovery_EXPORT RecoveryStore
00052 {
00053 public:
00054
00062 RecoveryStore (const ACE_CString& file_name, bool load = true, ACE_UINT32 max_size = 0);
00063
00067 ~RecoveryStore (void);
00068
00074 int open (void);
00075
00081 int close (void);
00082
00087 ACE_UINT32 get_max_size (void);
00088
00093 void set_max_size (ACE_UINT32 size);
00094
00099 ACE_UINT32 get_current_size (void);
00100
00105 ACE_UINT32 get_n_records (void);
00106
00114 int log (const ACE_CString& id, const ACE_CString& data, bool bsave=true);
00115
00121 int exists (const ACE_CString& id);
00122
00129 int retrieve (const ACE_CString& id, ACE_CString& data);
00130
00138 int update (const ACE_CString& id, const ACE_CString& data, bool bsave=true);
00139
00146 int remove (const ACE_CString& id, bool bsave=true);
00147
00148 typedef ACE_Hash_Map_Manager <ACE_CString, ACE_CString, ACE_Thread_Mutex> STORE_HASH_MAP;
00149 typedef ACE_Hash_Map_Iterator <ACE_CString, ACE_CString, ACE_Thread_Mutex> STORE_HASH_MAP_ITER;
00150 typedef ACE_Hash_Map_Entry <ACE_CString, ACE_CString> STORE_HASH_MAP_ENTRY;
00151
00156 STORE_HASH_MAP_ITER get_iterator (void);
00157
00162 int save(void);
00163
00168 int load(void);
00169
00174 int unlink(void);
00175
00176 protected:
00177
00181 RecoveryStore::STORE_HASH_MAP rec_hash_;
00182
00186 ACE_CString file_name_;
00187
00191 ACE_UINT32 max_size_;
00192
00196 ACE_UINT32 current_size_;
00197
00201 ACE_UINT32 num_records_;
00202
00206 ACE_Recursive_Thread_Mutex mutex_;
00207 };
00208
00209 #include <ace/post.h>
00210
00211 };
00212
00213 #endif
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239