Skip to content

Commit 8966ab0

Browse files
authored
Merge pull request #155 from saxbophone/josh/doxygen
Add Doxygen
2 parents 2916cea + 9a7a96b commit 8966ab0

File tree

18 files changed

+2965
-436
lines changed

18 files changed

+2965
-436
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ Makefile
4242
cmake_install.cmake
4343
CTestTestfile.cmake
4444
install_manifest.txt
45+
46+
# Doxygen build folder
47+
doc/

Doxyfile

Lines changed: 2427 additions & 0 deletions
Large diffs are not rendered by default.

sxbp/initialise.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
* This source file forms part of libsxbp, a library which generates
33
* experimental 2D spiral-like shapes based on input binary data.
44
*
5-
* This compilation unit provides basic functions to initialise a spiral.
6-
*
7-
*
8-
*
95
* Copyright (C) 2016, Joshua Saxby [email protected]
106
*
117
* This program is free software: you can redistribute it and/or modify
@@ -32,33 +28,16 @@
3228
extern "C"{
3329
#endif
3430

35-
/*
36-
* when facing the direction specified by current, return the direction that
37-
* will be faced when turning in the rotational direction specified by turn.
38-
*/
3931
sxbp_direction_t sxbp_change_direction(
4032
sxbp_direction_t current, sxbp_rotation_t turn
4133
) {
4234
return (current + turn) % 4U;
4335
}
4436

45-
/*
46-
* returns a spiral struct with all fields initialised to 0
47-
*/
4837
sxbp_spiral_t sxbp_blank_spiral() {
4938
return (sxbp_spiral_t){0, NULL, {{NULL, 0}, 0}, false, 0, 0, 0};
5039
}
5140

52-
/*
53-
* given a buffer_t full of data, and a pointer to a blank spiral_t
54-
* struct, populates the spiral struct from the data in the buffer
55-
* this converts the 0s and 1s in the data into UP, LEFT, DOWN, RIGHT
56-
* instructions which are then used to build the pattern.
57-
* returns a status_t struct with error information (if needed)
58-
*
59-
* Asserts:
60-
* - That the spiral struct pointed to has its pointer attributes set to NULL
61-
*/
6241
sxbp_status_t sxbp_init_spiral(sxbp_buffer_t buffer, sxbp_spiral_t* spiral) {
6342
// preconditional assertions
6443
assert(spiral->lines == NULL);

sxbp/initialise.h

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
/*
22
* This source file forms part of libsxbp, a library which generates
33
* experimental 2D spiral-like shapes based on input binary data.
4+
*/
5+
6+
/**
7+
* @file
48
*
5-
* This compilation unit provides basic functions to initialise a spiral.
6-
*
9+
* @brief This compilation unit provides basic functions to initialise a spiral.
710
*
11+
* @author Joshua Saxby <[email protected]
12+
* @date 2016
813
*
9-
* Copyright (C) 2016, Joshua Saxby [email protected]
14+
* @copyright Copyright (C) Joshua Saxby 2016
1015
*
11-
* This program is free software: you can redistribute it and/or modify
12-
* it under the terms of the GNU Affero General Public License (version 3),
13-
* as published by the Free Software Foundation.
16+
* @copyright This program is free software: you can redistribute it and/or
17+
* modify it under the terms of the GNU Affero General Public License
18+
* (version 3), as published by the Free Software Foundation.
1419
*
15-
* This program is distributed in the hope that it will be useful,
20+
* @copyright This program is distributed in the hope that it will be useful,
1621
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1722
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1823
* GNU Affero General Public License for more details.
1924
*
20-
* You should have received a copy of the GNU Affero General Public License
21-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
25+
* @copyright You should have received a copy of the GNU Affero General Public
26+
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
2227
*/
2328
#ifndef SAXBOPHONE_SAXBOSPIRAL_INITIALISE_H
2429
#define SAXBOPHONE_SAXBOSPIRAL_INITIALISE_H
@@ -30,28 +35,47 @@
3035
extern "C"{
3136
#endif
3237

33-
/*
34-
* when facing the direction specified by current, return the direction that
35-
* will be faced when turning in the rotational direction specified by turn.
38+
/**
39+
* @brief Gets the direction which is clockwise or anti-clockwise to the current
40+
* direction.
41+
* @details Given a current direction and a rotational direction, return the new
42+
* direction which would be faced after turning 90 degrees in the given
43+
* rotational direction.
44+
*
45+
* @param current The current direction to turn from.
46+
* @param turn The rotational direction to turn in.
47+
* @return The new direction which will be faced after turning.
3648
*/
3749
sxbp_direction_t sxbp_change_direction(
3850
sxbp_direction_t current, sxbp_rotation_t turn
3951
);
4052

41-
/*
42-
* returns a spiral struct with all fields initialised to 0
53+
/**
54+
* @brief Builds a blank spiral struct.
55+
* @details This is a convenience function, as the struct has many fields. This
56+
* function will create a spiral struct with all of these fields initialised to
57+
* 0 or their default 'blank' state. No memory is allocated.
58+
*
59+
* @return A blank spiral struct with all fields initialised to 0 or blank values.
4360
*/
4461
sxbp_spiral_t sxbp_blank_spiral();
4562

46-
/*
47-
* given a buffer_t full of data, and a pointer to a blank spiral_t
48-
* struct, populates the spiral struct from the data in the buffer
49-
* this converts the 0s and 1s in the data into UP, LEFT, DOWN, RIGHT
50-
* instructions which are then used to build the pattern.
51-
* returns a status_t struct with error information (if needed)
52-
*
53-
* Asserts:
54-
* - That the spiral struct pointed to has its pointer attributes set to NULL
63+
/**
64+
* @brief Builds a partially-complete spiral from binary input data stored in a
65+
* buffer.
66+
* @details This converts the 0s and 1s in the buffer data into UP, LEFT, DOWN,
67+
* RIGHT instructions which are then used to build the pattern. Only the line
68+
* directions are calculated at this point, all line lengths are 0.
69+
*
70+
* @param buffer A buffer containing at least one byte of data, used to
71+
* determine the directions of the lines in the spiral it will create.
72+
* @param spiral [out] Spiral object which the line directions will be written
73+
* to.
74+
* @return SXBP_OPERATION_OK on success.
75+
* @return SXBP_MALLOC_REFUSED on memory allocation failure.
76+
*
77+
* @note Asserts:
78+
* - That all the pointer members of parameter spiral are set to NULL
5579
*/
5680
sxbp_status_t sxbp_init_spiral(sxbp_buffer_t buffer, sxbp_spiral_t* spiral);
5781

sxbp/plot.c

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
* This source file forms part of libsxbp, a library which generates
33
* experimental 2D spiral-like shapes based on input binary data.
44
*
5-
* This compilation unit provides functions for plotting and caching the points
6-
* which make up the lines of a spiral.
7-
*
8-
*
9-
*
105
* Copyright (C) 2016, Joshua Saxby [email protected]
116
*
127
* This program is free software: you can redistribute it and/or modify
@@ -32,13 +27,6 @@
3227
extern "C"{
3328
#endif
3429

35-
/*
36-
* returns the sum of all line lengths within the given indexes
37-
*
38-
* Asserts:
39-
* - That start and end indexes are less than or equal to the spiral size
40-
* - That spiral.lines is not NULL
41-
*/
4230
size_t sxbp_sum_lines(sxbp_spiral_t spiral, size_t start, size_t end) {
4331
// preconditional assertions
4432
assert(start <= spiral.size);
@@ -51,21 +39,6 @@ size_t sxbp_sum_lines(sxbp_spiral_t spiral, size_t start, size_t end) {
5139
return size;
5240
}
5341

54-
/*
55-
* given a spiral_t struct, a pointer to a co_ord_array_t, a pair of co-ords
56-
* specifying the start point and indexes of the lowest and highest line
57-
* segments to use, write to the co_ord_array_t struct all the co-ordinates of
58-
* the line segments of the struct according to the current directions and
59-
* lengths of the lines in the spiral.
60-
* each line segment is only one unit long, meaning multiple ones are needed for
61-
* lines longer than one unit.
62-
* returns a status struct with error information (if any)
63-
*
64-
* Asserts:
65-
* - That the output struct's items pointer is NULL
66-
* - That start and end indexes are less than or equal to the spiral size
67-
* - That spiral.lines is not NULL
68-
*/
6942
sxbp_status_t sxbp_spiral_points(
7043
sxbp_spiral_t spiral, sxbp_co_ord_array_t* output,
7144
sxbp_co_ord_t start_point, size_t start, size_t end
@@ -110,19 +83,6 @@ sxbp_status_t sxbp_spiral_points(
11083
return result;
11184
}
11285

113-
/*
114-
* given a pointer to a spiral struct and limit, which is the index of the last
115-
* line to use, calculate and store the co-ordinates of all line segments that
116-
* would make up the spiral if the current lengths and directions were used.
117-
* each line segment is only one unit long, meaning multiple ones are needed for
118-
* lines longer than one unit. The co-ords are stored in the spiral's
119-
* co_ord_cache member and are re-used if they are still valid
120-
* returns a status struct with error information (if any)
121-
*
122-
* Asserts:
123-
* - That spiral->lines is not NULL
124-
* - That limit is less than or equal to spiral->size
125-
*/
12686
sxbp_status_t sxbp_cache_spiral_points(sxbp_spiral_t* spiral, size_t limit) {
12787
// preconditional assertions
12888
assert(spiral->lines != NULL);

sxbp/plot.h

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
/*
22
* This source file forms part of libsxbp, a library which generates
33
* experimental 2D spiral-like shapes based on input binary data.
4+
*/
5+
6+
/**
7+
* @file
48
*
5-
* This compilation unit provides functions for plotting and caching the points
6-
* which make up the lines of a spiral.
7-
*
9+
* @brief This compilation unit provides functions for plotting and caching the
10+
* points which make up the lines of a spiral.
811
*
12+
* @author Joshua Saxby <[email protected]
13+
* @date 2016
914
*
10-
* Copyright (C) 2016, Joshua Saxby [email protected]
15+
* @copyright Copyright (C) Joshua Saxby 2016
1116
*
12-
* This program is free software: you can redistribute it and/or modify
13-
* it under the terms of the GNU Affero General Public License (version 3),
14-
* as published by the Free Software Foundation.
17+
* @copyright This program is free software: you can redistribute it and/or
18+
* modify it under the terms of the GNU Affero General Public License
19+
* (version 3), as published by the Free Software Foundation.
1520
*
16-
* This program is distributed in the hope that it will be useful,
21+
* @copyright This program is distributed in the hope that it will be useful,
1722
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1823
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1924
* GNU Affero General Public License for more details.
2025
*
21-
* You should have received a copy of the GNU Affero General Public License
22-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
26+
* @copyright You should have received a copy of the GNU Affero General Public
27+
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
2328
*/
2429
#ifndef SAXBOPHONE_SAXBOSPIRAL_PLOT_H
2530
#define SAXBOPHONE_SAXBOSPIRAL_PLOT_H
@@ -33,45 +38,78 @@
3338
extern "C"{
3439
#endif
3540

36-
/*
37-
* returns the sum of all line lengths within the given indexes
41+
/**
42+
* @brief Calculates the sum of all line lengths in this spiral within the given
43+
* start and end indexes.
44+
* @details params start and end specify the range of line indexes to use for the
45+
* lines which are to be summed. These are inclusive of the lower bound but
46+
* exclusive of the upper bound.
47+
*
48+
* @param spiral The spiral of which line lengths should be summed.
49+
* @param start The index of the first line to include in those of which lengths
50+
* should be summed.
51+
* @param end The index of the line after the last line to include in those of
52+
* which lengths should be summed.
53+
* @return The sum of the lengths of all the lines in the given range.
3854
*
39-
* Asserts:
55+
* @note Asserts:
4056
* - That start and end indexes are less than or equal to the spiral size
4157
* - That spiral.lines is not NULL
58+
*
59+
* @todo Might also need to add an assertion to check that end is never less
60+
* than start.
4261
*/
4362
size_t sxbp_sum_lines(sxbp_spiral_t spiral, size_t start, size_t end);
4463

45-
/*
46-
* given a spiral_t struct, a pointer to a co_ord_array_t, a pair of co-ords
47-
* specifying the start point and indexes of the lowest and highest line
48-
* segments to use, write to the co_ord_array_t struct all the co-ordinates of
49-
* the line segments of the struct according to the current directions and
50-
* lengths of the lines in the spiral.
51-
* each line segment is only one unit long, meaning multiple ones are needed for
52-
* lines longer than one unit.
53-
* returns a status struct with error information (if any)
64+
/**
65+
* @brief Calculates a series of co-ords for which trace a given part of a
66+
* spiral line.
67+
* @details The whole spiral may be calculated, or just a given segment of it.
68+
* This is controlled by specifying which line to start at and which to end at.
69+
*
70+
* @param spiral The spiral for which line co-ords should be calculated.
71+
* @param output [out] The co-ords array which calculated co-ords should be
72+
* written to.
73+
* @param start_point The x/y co-ordinates at which the line being plotted
74+
* originates at.
75+
* @param start The index of the first line which makes up the segment which is
76+
* being calculated.
77+
* @param end The index of the line after the last line which makes up the
78+
* segment which is being calculated.
79+
* @return SXBP_OPERATION_OK on success.
80+
* @return SXBP_MALLOC_REFUSED on memory allocation failure.
81+
*
82+
* @note For this function to do anything useful, the spiral should at least
83+
* have some line lengths calculated, but this is not essential.
5484
*
55-
* Asserts:
56-
* - That the output struct's items pointer is NULL
85+
* @note Asserts:
86+
* - That output->items is NULL
5787
* - That start and end indexes are less than or equal to the spiral size
5888
* - That spiral.lines is not NULL
89+
*
90+
* @todo Might also need to add an assertion to check that end is never less
91+
* than start.
5992
*/
6093
sxbp_status_t sxbp_spiral_points(
6194
sxbp_spiral_t spiral, sxbp_co_ord_array_t* output,
6295
sxbp_co_ord_t start_point, size_t start, size_t end
6396
);
6497

65-
/*
66-
* given a pointer to a spiral struct and limit, which is the index of the last
67-
* line to use, calculate and store the co-ordinates of all line segments that
68-
* would make up the spiral if the current lengths and directions were used.
69-
* each line segment is only one unit long, meaning multiple ones are needed for
70-
* lines longer than one unit. The co-ords are stored in the spiral's
71-
* co_ord_cache member and are re-used if they are still valid
72-
* returns a status struct with error information (if any)
98+
/**
99+
* @brief Caches any uncached co-ords of the line of a spiral up to a given line
100+
* index.
101+
* @details If there are any outstanding co-ordinates which haven't been stored
102+
* in the spiral's internal cache, then these will be calculated and stored in
103+
* the cache. Subsequent identical calls will not incur the overhead of
104+
* re-calculating these co-ords, provided the lengths of any of the spiral's
105+
* lines are not changed in the process.
106+
*
107+
* @param spiral The spiral for which co-ords should be cached.
108+
* @param limit The highest index of line for which co-ords should be cached to.
109+
* @return SXBP_OPERATION_OK on success.
110+
* @return SXBP_MALLOC_REFUSED on memory allocation failure.
73111
*
74-
* Asserts:
112+
* @note Asserts:
75113
* - That spiral->lines is not NULL
76114
* - That limit is less than or equal to spiral->size
77115
*/

0 commit comments

Comments
 (0)