3 * \brief The sn_stage_t class and associated methods.
6 * libsortnetwork - src/sn_stage.h
7 * Copyright (C) 2008-2010 Florian octo Forster
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; only version 2 of the License is applicable.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 * Florian octo Forster <ff at octo.it>
32 #include "sn_comparator.h"
37 sn_comparator_t *comparators;
40 typedef struct sn_stage_s sn_stage_t;
42 enum sn_network_cut_dir_e
48 #define SN_STAGE_DEPTH(s) (s)->depth
49 #define SN_STAGE_COMP_NUM(s) (s)->comparators_num
50 #define SN_STAGE_COMP_GET(s,n) ((s)->comparators + (n))
52 sn_stage_t *sn_stage_create (int depth);
55 * Clones an existing stage.
57 * \param s Stage to clone.
58 * \return Copied stage or NULL on error. The returned stage must be freed
59 * using sn_stage_destroy().
61 sn_stage_t *sn_stage_clone (const sn_stage_t *s);
62 void sn_stage_destroy (sn_stage_t *s);
64 int sn_stage_sort (sn_stage_t *s, int *values);
66 int sn_stage_comparator_add (sn_stage_t *s, const sn_comparator_t *c);
67 int sn_stage_comparator_remove (sn_stage_t *s, int c_num);
68 int sn_stage_comparator_check_conflict (sn_stage_t *s, const sn_comparator_t *c);
70 int sn_stage_show (sn_stage_t *s);
71 int sn_stage_invert (sn_stage_t *s);
72 int sn_stage_shift (sn_stage_t *s, int sw, int inputs_num);
73 int sn_stage_swap (sn_stage_t *s, int con0, int con1);
74 int sn_stage_cut_at (sn_stage_t *s, int input, enum sn_network_cut_dir_e dir);
75 int sn_stage_remove_input (sn_stage_t *s, int input);
77 sn_stage_t *sn_stage_read (FILE *fh);
78 int sn_stage_write (sn_stage_t *s, FILE *fh);
80 int sn_stage_serialize (sn_stage_t *s,
81 char **ret_buffer, size_t *ret_buffer_size);
82 sn_stage_t *sn_stage_unserialize (char **buffer, size_t *buffer_size);
84 #endif /* SN_STAGE_H */
86 /* vim: set shiftwidth=2 softtabstop=2 : */