summaryrefslogtreecommitdiff
path: root/src/charon-tkm/src/tkm/tkm_chunk_map.h
blob: a2864f07a825601496f6ef0759e13ee4eade9cd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * Copyright (C) 2012 Reto Buerki
 * Copyright (C) 2012 Adrian-Ken Rueegsegger
 * HSR Hochschule fuer Technik Rapperswil
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

/**
 * @defgroup tkm-chunk-map chunk map
 * @{ @ingroup tkm
 */

#ifndef TKM_CHUNK_MAP_H_
#define TKM_CHUNK_MAP_H_

#include <stdint.h>
#include <utils/chunk.h>

typedef struct tkm_chunk_map_t tkm_chunk_map_t;

/**
 * The tkm chunk map handles mappings of chunks to ids.
 */
struct tkm_chunk_map_t {

	/**
	 * Store new mapping for given chunk and id.
	 *
	 * @param data	data associated with id
	 * @param id	id associated with data
	 */
	void (*insert)(tkm_chunk_map_t * const this, const chunk_t * const data,
				   const uint64_t id);

	/**
	 * Get id for given chunk.
	 *
	 * @param data	data specifying the mapping
	 * @return		id of given chunk, 0 if not found
	 */
	uint64_t (*get_id)(tkm_chunk_map_t * const this, chunk_t *data);

	/**
	 * Remove mapping for given chunk.
	 *
	 * @param data	data specifying the mapping to remove
	 * @return		TRUE if mapping was removed, FALSE otherwise
	 */
	bool (*remove)(tkm_chunk_map_t * const this, chunk_t *data);

	/**
	 * Destroy a tkm chunk map instance.
	 */
	void (*destroy)(tkm_chunk_map_t *this);

};

/**
 * Create a tkm chunk map instance.
 */
tkm_chunk_map_t *tkm_chunk_map_create();

#endif /** TKM_CHUNK_MAP_H_ @}*/