Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

simplemap.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *
00003  * Verball Model Storage Library, Common Information Model Library 
00004  * for integration of Intelligent Services.
00005  * Copyright (C) 2005 Nikita Vinokurov, Orgway LLC.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; 
00010  * version 2.1 of the License.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00020  * Boston, MA  02110-1301  USA
00021  *
00022  * $Id: simplemap.h,v 1.5 2006/09/18 21:38:32 sbreg Exp $
00023  **********************************************************************/
00024 
00025 #ifndef __SIMPLE_MAP_H__
00026 #define __SIMPLE_MAP_H__
00027 
00028 #if defined(_WIN32) || defined(__declspec)
00029 
00030 #ifdef COMPILE_DLL
00031 #define STORAGE_TYPE __declspec(dllexport)
00032 #else // COMPILE_DLL
00033 #define STORAGE_TYPE __declspec(dllimport)
00034 #endif // COMPILE_DLL
00035 
00036 #else
00037 #define STORAGE_TYPE extern
00038 #endif // _WIN32 || __declspec
00039 
00040 
00041 
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00052 typedef struct _simple_map_el {
00053     void *value;
00054     char *key;
00055     struct _simple_map_el *next;    
00056 
00057 } SimpleMapEl;
00058 
00060 typedef void (*MapDestructor) (void*);
00061 typedef unsigned int  (*MapHashFunc)   (char *);
00062 typedef int  (*MapCompareFunc) (char *, char *);
00063 typedef char *(*MapCopyFunc) (char *);
00064 typedef void (*MapFreeFunc)(char *);
00065 
00066 
00067 typedef struct {
00068     MapHashFunc hash_element;
00069     MapCompareFunc compare_elements;
00070     MapCopyFunc    copy_element;
00071     MapFreeFunc    free_element;
00072 
00073 } MapTypeInfo;
00074  
00075 
00076 
00079 typedef struct {
00080     
00081     int size; 
00082     struct _simple_map_el **table;
00083     MapDestructor free_element;
00084     MapTypeInfo type;
00085 
00086 } SimpleMap;
00087 
00089 typedef int (*MapIterator) (SimpleMap *map, char *key, void *value, void *data);
00090 
00091 
00094 STORAGE_TYPE SimpleMap* map_new();
00095 
00096 
00099 STORAGE_TYPE SimpleMap* map_new_with_destructor(MapDestructor destructor);
00100 
00103 STORAGE_TYPE SimpleMap* map_new_configured(int size, MapDestructor destructor);
00104 
00107 STORAGE_TYPE SimpleMap* map_new_configured_full(int size, MapDestructor destructor,
00108                                                 MapTypeInfo *pInfo);
00109 
00110 
00113 STORAGE_TYPE void map_set(SimpleMap *map, char *key, void *value );
00114 
00117 STORAGE_TYPE void map_remove(SimpleMap *map, char *key);
00118 
00119 
00124 STORAGE_TYPE int  map_foreach(SimpleMap *map, MapIterator iterator, void *data);
00125 
00128 STORAGE_TYPE void *map_get(SimpleMap *map, char *key);
00129 
00131 STORAGE_TYPE int map_has_key(SimpleMap *map, char *key);
00132 
00133 
00136 STORAGE_TYPE void* map_get_element( SimpleMap*, char* key );
00137 
00140 STORAGE_TYPE void map_free(SimpleMap *map);
00141 
00142 
00145 STORAGE_TYPE SimpleMap *map_copy(SimpleMap *map);
00146 
00147 
00148 #ifdef __cplusplus
00149 }
00150 #endif
00151 
00152 #endif /* __SIMPLE_MAP_H__ */

Generated on Wed Dec 27 16:52:18 2006 for VRB Online Server by  doxygen 1.4.4