3D-ICE 3.0.0
connection.c
1/******************************************************************************
2 * This file is part of 3D-ICE, version 3.1.0 . *
3 * *
4 * 3D-ICE is free software: you can redistribute it and/or modify it under *
5 * the terms of the GNU General Public License as published by the Free *
6 * Software Foundation, either version 3 of the License, or any later *
7 * version. *
8 * *
9 * 3D-ICE is distributed in the hope that it will be useful, but WITHOUT *
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
12 * more details. *
13 * *
14 * You should have received a copy of the GNU General Public License along *
15 * with 3D-ICE. If not, see <http://www.gnu.org/licenses/>. *
16 * *
17 * Copyright (C) 2021 *
18 * Embedded Systems Laboratory - Ecole Polytechnique Federale de Lausanne *
19 * All Rights Reserved. *
20 * *
21 * Authors: Arvind Sridhar Alessandro Vincenzi *
22 * Giseong Bak Martino Ruggiero *
23 * Thomas Brunschwiler Eder Zulian *
24 * Federico Terraneo Darong Huang *
25 * Luis Costero Marina Zapater *
26 * David Atienza *
27 * *
28 * For any comment, suggestion or request about 3D-ICE, please register and *
29 * write to the mailing list (see http://listes.epfl.ch/doc.cgi?liste=3d-ice) *
30 * Any usage of 3D-ICE for research, commercial or other purposes must be *
31 * properly acknowledged in the resulting products or publications. *
32 * *
33 * EPFL-STI-IEL-ESL Mail : 3d-ice@listes.epfl.ch *
34 * Batiment ELG, ELG 130 (SUBSCRIPTION IS NECESSARY) *
35 * Station 11 *
36 * 1015 Lausanne, Switzerland Url : http://esl.epfl.ch/3d-ice *
37 ******************************************************************************/
38#include <stdlib.h> // For the memory functions malloc/free
39
40#include "connection.h"
41#include "macros.h"
42
43void connection_init (Connection_t *connection)
44{
45 connection->node1=0;
46 connection->node2=0;
47 connection->node1_layer=0;
48 connection->node2_layer=0;
49 connection->direction = 0;
50 connection->value=0;
51}
52
53void connection_destroy (Connection_t *connection)
54{
55 connection_init(connection) ;
56}
57
58void connection_free (Connection_t *connection)
59{
60 if (connection == NULL)
61
62 return ;
63
64 connection_destroy (connection) ;
65
66 free (connection) ;
67}
68
69void connection_copy (Connection_t *dst, Connection_t *src)
70{
71 connection_init (dst) ;
72
73 dst->node1 = src->node1;
74 dst->node2 = src->node2;
75 dst->node1_layer = src->node1_layer;
76 dst->node2_layer = src->node2_layer;
77 dst->direction = src->direction;
78 dst->value = src->value;
79}
80
81bool connection_equal (Connection_t *connection, Connection_t *other)
82{
83 return connection->node1 == other->node1 &&
84 connection->node2 == other->node2 ;
85}
86
87void connection_print (Connection_t *connection, FILE *stream, String_t prefix)
88{
89 fprintf(stream, "%sNode%d in layer %d <-> Node%d in layer %d\n", prefix, connection->node1, connection->node1_layer, connection->node2, connection->node2_layer) ;
90 fprintf(stream, "%sDirection %d, Value %f\n", prefix, connection->direction, connection->value) ;
91}
void connection_init(Connection_t *connection)
Definition: connection.c:43
char * String_t
Definition: string_t.h:55