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: nodehvs.h,v 1.9 2006/09/18 21:38:32 sbreg Exp $ 00023 **********************************************************************/ 00024 00025 00057 #ifndef _NODEHVS_H_ 00058 #define _NODEHVS_H_ 00059 00060 #include "node.h" 00061 00062 00063 00071 typedef uword64 nhash_t; 00072 00073 00080 typedef struct _nhvs_seq_list { 00081 nhash_t hash_value; 00082 Node node_value; 00083 struct _nhvs_seq_list *next; 00085 } NHVSSeqList; 00086 00092 typedef struct _nhvs_tree_node { 00093 struct _nhvs_tree_node *left; 00094 struct _nhvs_tree_node *right; 00095 struct _nhvs_seq_list *first; 00096 int last_id; 00097 nhash_t hash_value; 00099 } NHVSTreeNode; 00100 00101 #if defined(_WIN32) && !defined(__MINGW32__) 00102 #define NHASH_SEQ_MASK 0xFF00000000000000i64 00103 #define NHASH_HASH_MASK 0x00FFFFFFFFFFFFFFi64 00104 #else 00105 #define NHASH_SEQ_MASK 0xFF00000000000000LL 00106 #define NHASH_HASH_MASK 0x00FFFFFFFFFFFFFFLL 00107 #endif 00108 00110 #if defined(_WIN32) && !defined(__MINGW32__) 00111 #define NHASH_SEQ(n) (((n) >> 56 ) & 0xFFi64) 00112 #else 00113 #define NHASH_SEQ(n) (((n) >> 56 ) & 0xFFLL) 00114 #endif 00115 00118 #define NHASH_HASH(n) ((n) & NHASH_HASH_MASK) 00119 00122 #define SET_NHASH_HASH(n,h) (((n) & NHASH_SEQ_MASK) | ((h) & NHASH_HASH_MASK)) 00123 00126 #if defined(_WIN32) && !defined(__MINGW32__) 00127 #define SET_NHASH_SEQ(n,s) (((n) & NHASH_HASH_MASK) | (((s) & 0xFFLL) << 56 )) 00128 #else 00129 #define SET_NHASH_SEQ(n,s) (((n) & NHASH_HASH_MASK) | (((s) & 0xFFLL) << 56 )) 00130 #endif 00131 00132 00133 00134 00138 nhash_t nhvs_get_hash( Node *node ); 00139 00144 STORAGE_TYPE 00145 Node *nhvs_get_node( nhash_t hash ); 00146 00147 int nhvs_put_local( nhash_t hash, Node *node ); 00148 00166 STORAGE_TYPE 00167 void nhvs_update_hash ( nhash_t *hash, Node *node); 00168 00169 00177 /* 00178 STORAGE_TYPE 00179 int nhvs_dict_set(Node *node, unsigned long id, const char *string); 00180 */ 00181 00182 /* Lookup for dictionary item. 00183 * Searches the item id, associated with the string. 00184 * If the string is found, fills the Node::id and Node::parsed fields 00185 * of \a node structure. 00186 * \returns positive value in case of success and zero otherwise. 00187 */ 00188 00189 STORAGE_TYPE 00190 int nhvs_dict_lookup(Node *node, const char *string); 00191 00196 void nhvs_parsed_set(Node *node, const char *string); 00197 00198 00203 int nhvs_gen_set(Node *node, const char *string); 00204 00207 nhash_t nhash_hash_func ( Node *node); 00208 00210 STORAGE_TYPE 00211 int nhvs_new(); 00212 00214 STORAGE_TYPE 00215 int nhvs_free(); 00216 00217 00218 #endif /* _NODEHVS_H_ */ 00219 #ifdef DMALLOC 00220 #include<dmalloc.h> 00221 #endif