libsxbp  v0.27
Experimental generation of 2D spiralling lines based on input binary data.
saxbospiral.h
Go to the documentation of this file.
1 /*
2  * This source file forms part of libsxbp, a library which generates
3  * experimental 2D spiral-like shapes based on input binary data.
4  */
5 
23 #ifndef SAXBOPHONE_SAXBOSPIRAL_SAXBOSPIRAL_H
24 #define SAXBOPHONE_SAXBOSPIRAL_SAXBOSPIRAL_H
25 
26 #include <stdbool.h>
27 #include <stddef.h>
28 #include <stdint.h>
29 #include <time.h>
30 
31 
32 #ifdef __cplusplus
33 extern "C"{
34 #endif
35 
40 typedef struct sxbp_version_t {
42  uint16_t major;
44  uint16_t minor;
46  uint16_t patch;
48  const char* string;
50 
52 extern const sxbp_version_t LIB_SXBP_VERSION;
53 
62 
71 
80 
87 typedef enum sxbp_status_t {
95 
101 typedef uint8_t sxbp_direction_t;
102 
103 #define SXBP_UP 0
104 #define SXBP_RIGHT 1
105 #define SXBP_DOWN 2
106 #define SXBP_LEFT 3
113 typedef int8_t sxbp_rotation_t;
114 
115 #define SXBP_CLOCKWISE 1
116 #define SXBP_ANTI_CLOCKWISE -1
124 typedef uint32_t sxbp_length_t;
125 
132 typedef struct sxbp_line_t {
134  sxbp_direction_t direction : 2;
136  sxbp_length_t length : 30;
137 } sxbp_line_t;
138 
140 typedef int32_t sxbp_tuple_item_t;
141 
145 typedef struct sxbp_tuple_t {
147  sxbp_tuple_item_t x;
149  sxbp_tuple_item_t y;
150 } sxbp_tuple_t;
151 
156 
160 typedef struct sxbp_co_ord_array_t {
162  sxbp_co_ord_t* items;
164  size_t size;
166 
173 typedef struct sxbp_co_ord_cache_t {
178  size_t validity;
180 
189 typedef struct sxbp_spiral_t {
191  uint32_t size;
198  sxbp_co_ord_cache_t co_ord_cache;
200  bool collides;
205  uint32_t collider;
207  uint32_t solved_count;
214  uint32_t seconds_spent;
224  clock_t current_clock_ticks;
232  clock_t elapsed_clock_ticks;
233 } sxbp_spiral_t;
234 
236 typedef struct sxbp_buffer_t {
238  uint8_t* bytes;
240  size_t size;
241 } sxbp_buffer_t;
242 
252 extern const sxbp_vector_t SXBP_VECTOR_DIRECTIONS[4];
253 
254 #ifdef __cplusplus
255 } // extern "C"
256 #endif
257 
258 // end of header file
259 #endif
uint8_t * bytes
pointer to array of bytes
Definition: saxbospiral.h:238
bool sxbp_version_less_than(sxbp_version_t a, sxbp_version_t b)
Checks if a version is less than another.
Definition: saxbospiral.c:28
const char * string
String form of the version (vX.Y.Z)
Definition: saxbospiral.h:48
uint32_t seconds_accuracy
stores the number of seconds&#39; accuracy of the seconds_spent field
Definition: saxbospiral.h:219
uint8_t sxbp_direction_t
Type for representing one of the cartesian directions.
Definition: saxbospiral.h:101
const sxbp_version_t LIB_SXBP_VERSION
Stores the current version of libsxbp.
Definition: saxbospiral.c:21
struct sxbp_co_ord_array_t sxbp_co_ord_array_t
Struct type for holding a dynamically allocated array of co-ordinates.
Definition: saxbospiral.h:93
struct sxbp_tuple_t sxbp_tuple_t
A generic Tuple type for storing a vector-based quantity.
A generic Tuple type for storing a vector-based quantity.
Definition: saxbospiral.h:145
uint32_t sxbp_length_t
Type for representing the length of a line segment of a spiral.
Definition: saxbospiral.h:124
size_t size
size of the array in number of items
Definition: saxbospiral.h:164
uint16_t minor
The minor version number of the version.
Definition: saxbospiral.h:44
struct sxbp_line_t sxbp_line_t
Represents one line segment in the spiral structure.
uint16_t patch
The patch version number of the version.
Definition: saxbospiral.h:46
uint32_t size
count of lines in the spiral
Definition: saxbospiral.h:191
sxbp_co_ord_array_t co_ords
the co-ord array containing the cached co-ords
Definition: saxbospiral.h:175
size_t validity
the index of the spiral line for which this set of cached co-ords is valid up to
Definition: saxbospiral.h:178
sxbp_tuple_t sxbp_vector_t
A Vector type used for representing directions.
Definition: saxbospiral.h:153
bool collides
whether this spiral collides or not
Definition: saxbospiral.h:200
const sxbp_vector_t SXBP_VECTOR_DIRECTIONS[4]
Vector direction constants.
Definition: saxbospiral.c:61
sxbp_co_ord_t * items
pointer to the array of co-ordinates
Definition: saxbospiral.h:162
int32_t sxbp_tuple_item_t
Type for storing one of the items of a tuple.
Definition: saxbospiral.h:140
Definition: saxbospiral.h:91
Struct type for holding a dynamically allocated array of co-ordinates.
Definition: saxbospiral.h:160
A simple buffer type for storing arrays of bytes.
Definition: saxbospiral.h:236
Definition: saxbospiral.h:92
sxbp_line_t * lines
dynamic array of lines in the spiral
Definition: saxbospiral.h:193
Represents one line segment in the spiral structure.
Definition: saxbospiral.h:132
struct sxbp_spiral_t sxbp_spiral_t
Struct type representing a Spiral figure, in any state of completion.
sxbp_tuple_item_t x
The x (across) value of the tuple.
Definition: saxbospiral.h:147
Definition: saxbospiral.h:89
bool sxbp_version_greater_than(sxbp_version_t a, sxbp_version_t b)
Checks if a version is greater than another.
Definition: saxbospiral.c:41
uint32_t solved_count
the count of lines solved so far (index of next line to solve)
Definition: saxbospiral.h:207
sxbp_tuple_t sxbp_co_ord_t
A co-ord type used for representing cartesian co-ordinates.
Definition: saxbospiral.h:155
Struct type representing a Spiral figure, in any state of completion.
Definition: saxbospiral.h:189
bool sxbp_version_equal_to(sxbp_version_t a, sxbp_version_t b)
Checks if a version is equal to another.
Definition: saxbospiral.c:54
struct sxbp_version_t sxbp_version_t
Used to represent a version of libsxbp.
struct sxbp_buffer_t sxbp_buffer_t
A simple buffer type for storing arrays of bytes.
size_t size
the size of the array of bytes
Definition: saxbospiral.h:240
Struct type for holding a cached set of co-ords.
Definition: saxbospiral.h:173
uint16_t major
The major version number of the version.
Definition: saxbospiral.h:42
Used to represent a version of libsxbp.
Definition: saxbospiral.h:40
sxbp_tuple_item_t y
The y (down) value of the tuple.
Definition: saxbospiral.h:149
Definition: saxbospiral.h:88
Definition: saxbospiral.h:90
struct sxbp_co_ord_cache_t sxbp_co_ord_cache_t
Struct type for holding a cached set of co-ords.
uint32_t seconds_spent
the count of seconds spent solving the spiral
Definition: saxbospiral.h:214
sxbp_status_t
Represents the success or failure status of an executed function.
Definition: saxbospiral.h:87