Updating tree for new function work in libhashkit.
[awesomized/libmemcached] / libhashkit / hashkit.h
1 /* HashKit
2 * Copyright (C) 2009 Brian Aker
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 */
8
9 #ifndef HASHKIT_H
10 #define HASHKIT_H
11
12 #if !defined(__cplusplus)
13 # include <stdbool.h>
14 #endif
15 #include <inttypes.h>
16 #include <sys/types.h>
17 #include <libhashkit/visibility.h>
18 #include <libhashkit/types.h>
19 #include <libhashkit/algorithm.h>
20 #include <libhashkit/behavior.h>
21 #include <libhashkit/function.h>
22 #include <libhashkit/strerror.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 struct hashkit_st
29 {
30 struct hashkit_function_st {
31 hashkit_hash_fn function;
32 void *context;
33 } base_hash, distribution_hash;
34
35 struct {
36 bool is_base_same_distributed:1;
37 } flags;
38
39 struct {
40 bool is_allocated:1;
41 } options;
42 };
43
44 HASHKIT_API
45 hashkit_st *hashkit_create(hashkit_st *hash);
46
47 HASHKIT_API
48 hashkit_st *hashkit_clone(hashkit_st *destination, const hashkit_st *ptr);
49
50 HASHKIT_API
51 bool hashkit_compare(const hashkit_st *first, const hashkit_st *second);
52
53 HASHKIT_API
54 void hashkit_free(hashkit_st *hash);
55
56 #define hashkit_is_allocated(__object) ((__object)->options.is_allocated)
57 #define hashkit_is_initialized(__object) ((__object)->options.is_initialized)
58
59 /** @} */
60
61 #ifdef __cplusplus
62 }
63 #endif
64
65 #endif /* HASHKIT_H */