Update copyright date and email address.
[sort-networks.git] / src / sn_stage.h
1 /**
2  * collectd - src/sn_stage.h
3  * Copyright (C) 2008-2010  Florian octo Forster
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; only version 2 of the License is applicable.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17  *
18  * Authors:
19  *   Florian octo Forster <ff at octo.it>
20  **/
21
22 #ifndef SN_STAGE_H
23 #define SN_STAGE_H 1
24
25 #include <stdio.h>
26
27 #include "sn_comparator.h"
28
29 struct sn_stage_s
30 {
31   int depth;
32   sn_comparator_t *comparators;
33   int comparators_num;
34 };
35 typedef struct sn_stage_s sn_stage_t;
36
37 enum sn_network_cut_dir_e
38 {
39   DIR_MIN,
40   DIR_MAX
41 };
42
43 #define SN_STAGE_DEPTH(s) (s)->depth
44 #define SN_STAGE_COMP_NUM(s) (s)->comparators_num
45 #define SN_STAGE_COMP_GET(s,n) ((s)->comparators + (n))
46
47 sn_stage_t *sn_stage_create (int depth);
48 sn_stage_t *sn_stage_clone (const sn_stage_t *s);
49 void sn_stage_destroy (sn_stage_t *s);
50
51 int sn_stage_sort (sn_stage_t *s, int *values);
52
53 int sn_stage_comparator_add (sn_stage_t *s, const sn_comparator_t *c);
54 int sn_stage_comparator_remove (sn_stage_t *s, int c_num);
55 int sn_stage_comparator_check_conflict (sn_stage_t *s, const sn_comparator_t *c);
56
57 int sn_stage_show (sn_stage_t *s);
58 int sn_stage_invert (sn_stage_t *s);
59 int sn_stage_shift (sn_stage_t *s, int sw, int inputs_num);
60 int sn_stage_swap (sn_stage_t *s, int con0, int con1);
61 int sn_stage_cut_at (sn_stage_t *s, int input, enum sn_network_cut_dir_e dir);
62 int sn_stage_remove_input (sn_stage_t *s, int input);
63
64 sn_stage_t *sn_stage_read (FILE *fh);
65 int sn_stage_write (sn_stage_t *s, FILE *fh);
66
67 int sn_stage_serialize (sn_stage_t *s,
68     char **ret_buffer, size_t *ret_buffer_size);
69 sn_stage_t *sn_stage_unserialize (char **buffer, size_t *buffer_size);
70
71 #endif /* SN_STAGE_H */
72
73 /* vim: set shiftwidth=2 softtabstop=2 : */