2 This file is part of GNUnet.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero 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.
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.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @file rps/gnunet-service-rps_view.h
21 * @brief wrapper around the "local view"
22 * @author Julius Bünger
24 #include "gnunet_util_lib.h"
30 * Create an empty view.
32 * @param len the maximum length for the view
33 * @return The newly created view
36 View_create (unsigned int len);
40 * Change length of view
42 * If size is decreased, peers with higher indices are removed.
44 * @param view The view that is changed
45 * @param len the (maximum) length for the view
48 View_change_len (struct View *view,
52 * Get the view as an array
54 * @return the view in array representation
56 const struct GNUNET_PeerIdentity *
57 View_get_as_array (const struct View *view);
61 * Get the size of the view
63 * @param view The view of which the size should be returned
64 * @return current number of actually contained peers
67 View_size (const struct View *view);
71 * Insert peer into the view
73 * @param view The view to put the peer into
74 * @param peer the peer to insert
76 * @return GNUNET_OK if peer was actually inserted
77 * GNUNET_NO if peer was not inserted
80 View_put (struct View *view,
81 const struct GNUNET_PeerIdentity *peer);
85 * Check whether view contains a peer
87 * @param view The which is checked for a peer
88 * @param peer the peer to check for
90 * @return GNUNET_OK if view contains peer
94 View_contains_peer (const struct View *view,
95 const struct GNUNET_PeerIdentity *peer);
99 * Remove peer from view
101 * @param view The view of which to remove the peer
102 * @param peer the peer to remove
104 * @return GNUNET_OK if view contained peer and removed it successfully
105 * GNUNET_NO if view does not contain peer
108 View_remove_peer (struct View *view,
109 const struct GNUNET_PeerIdentity *peer);
113 * Get a peer by index
115 * @param view the view of which to get the peer
116 * @param index the index of the peer to get
118 * @return peer to the corresponding index.
119 * NULL if this index is not known
121 const struct GNUNET_PeerIdentity *
122 View_get_peer_by_index (const struct View *view,
129 * @param view The view to clear
132 View_clear (struct View *view);
138 * @param view the view to destroy
141 View_destroy (struct View *view);
143 /* end of gnunet-service-rps_view.h */