first batch of license fixes (boring)
[oweals/gnunet.git] / src / rps / gnunet-service-rps_view.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C)
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      Affero General Public License for more details.
14 */
15
16 /**
17  * @file rps/gnunet-service-rps_view.h
18  * @brief wrapper around the "local view"
19  * @author Julius Bünger
20  */
21 #include "gnunet_util_lib.h"
22 #include <inttypes.h>
23
24
25 /**
26  * Create an empty view.
27  *
28  * @param len the maximum length for the view
29  */
30 void
31 View_create (unsigned int len);
32
33 /**
34  * Change length of view
35  *
36  * If size is decreased, peers with higher indices are removed.
37  *
38  * @param len the (maximum) length for the view
39  */
40 void
41 View_change_len (unsigned int len);
42
43 /**
44  * Get the view as an array
45  *
46  * @return the view in array representation
47  */
48 const struct GNUNET_PeerIdentity *
49 View_get_as_array ();
50
51 /**
52  * Get the size of the view
53  *
54  * @return current number of actually contained peers
55  */
56 unsigned int
57 View_size ();
58
59 /**
60  * Insert peer into the view
61  *
62  * @param peer the peer to insert
63  *
64  * @return GNUNET_OK if peer was actually inserted
65  *         GNUNET_NO if peer was not inserted
66  */
67 int
68 View_put (const struct GNUNET_PeerIdentity *peer);
69
70 /**
71  * Check whether view contains a peer
72  *
73  * @param peer the peer to check for
74  *
75  * @return GNUNET_OK if view contains peer
76  *         GNUNET_NO otherwise
77  */
78 int
79 View_contains_peer (const struct GNUNET_PeerIdentity *peer);
80
81 /**
82  * Remove peer from view
83  *
84  * @param peer the peer to remove
85  *
86  * @return GNUNET_OK if view contained peer and removed it successfully
87  *         GNUNET_NO if view does not contain peer
88  */
89 int
90 View_remove_peer (const struct GNUNET_PeerIdentity *peer);
91
92 /**
93  * Get a peer by index
94  *
95  * @param index the index of the peer to get
96  *
97  * @return peer to the corresponding index.
98  *         NULL if this index is not known
99  */
100 const struct GNUNET_PeerIdentity *
101 View_get_peer_by_index (uint32_t index);
102
103 /**
104  * Clear the custom peer map
105  *
106  * @param c_peer_map the custom peer map to look in
107  *
108  * @return size of the map
109  */
110 void
111 View_clear ();
112
113 /**
114  * Destroy peermap.
115  *
116  * @param c_peer_map the map to destroy
117  */
118 void
119 View_destroy ();
120
121 /* end of gnunet-service-rps_view.h */