-
Notifications
You must be signed in to change notification settings - Fork 0
/
NodeVector.h
118 lines (103 loc) · 2.61 KB
/
NodeVector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef HOMEWORK_NODEVECTOR_H
#define HOMEWORK_NODEVECTOR_H
/**
* @file NodeVector.h
* @brief Structures and functions related to Node Vectors
* @version 0.1
* @date 2019-11-05
*
* @copyright Copyright (c) 2019
*
*/
#include <stddef.h>
#include "Node.h"
/**
* @brief Struct of a vector containing nodes
*
*/
typedef struct NodeVector {
Node *nodes; /**< Nodes in the vector */
size_t count; /**< Number of nodes in the vector */
size_t capacity; /**< Capacity of the vector */
} NodeVector;
/**
* @brief Create a node vector
*
* @param count Number of items originally in the vector
* @return NodeVector Resulting vector
*/
NodeVector nodev_create(size_t count);
/**
* @brief Add element to the back of the vector
*
* @param vector Vector to push to
* @param node Node to push
*/
void nodev_push_back(NodeVector *vector, Node node);
/**
* @brief Erase an element from the vector
*
* @param vector Vector to erase from
* @param index Index to erase
*/
void nodev_erase(NodeVector *vector, int index);
/**
* @brief Get the element of the vector at the specified position
*
* @param vector Vector to get the element from
* @param index Index to get the element from
* @return Node* Resulting node
*/
Node *nodev_at(NodeVector *vector, int index);
/**
* @brief Connect two nodes in the vector
*
* @param vector Vector to connect two nodes in
* @param idA Id of the first node
* @param pinA Pin of the first node
* @param idB Id of the second node
* @param pinB Pin of the second node
*/
void nodev_connect(NodeVector *vector, int idA, int pinA, int idB, int pinB);
/**
* @brief Render the nodes inside a vector
*
* @param vector Vector to render
* @param camPos Camera position to render at
*/
void nodev_render(NodeVector *vector, Point camPos);
/**
* @brief Run simulation
*
* @param vector Vector to simulate
*/
void nodev_update(NodeVector *vector);
/**
* @brief Check and handle mouse clicks
*
* @param vector Vector to check
* @param mousePos Position of the mouse
*/
void nodev_check_clicks(NodeVector *vector, Point mousePos);
/**
* @brief Free vector
*
* @param vector Vector to free
*/
void nodev_free(NodeVector *vector);
/**
* @brief Repositions a node in the vector
*
* @param vector Vector to get the node from
* @param node Node to reposition
* @param position New position
*/
void nodev_reposition(NodeVector *vector, Node *node, Point position);
/**
* @brief Delete a node and erase the connections
*
* @param vector Vector to delete node from
* @param node Node to delete
*/
void nodev_delete(NodeVector *vector, Node *node);
#endif //HOMEWORK_NODEVECTOR_H