libsxbp  v0.27
Experimental generation of 2D spiralling lines based on input binary data.
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
saxbospiral.h File Reference

This compilation unit provides most of the data types used by the library, as well as defining some library constants and versioning functionality. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <time.h>
Include dependency graph for saxbospiral.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sxbp_version_t
 Used to represent a version of libsxbp. More...
 
struct  sxbp_line_t
 Represents one line segment in the spiral structure. More...
 
struct  sxbp_tuple_t
 A generic Tuple type for storing a vector-based quantity. More...
 
struct  sxbp_co_ord_array_t
 Struct type for holding a dynamically allocated array of co-ordinates. More...
 
struct  sxbp_co_ord_cache_t
 Struct type for holding a cached set of co-ords. More...
 
struct  sxbp_spiral_t
 Struct type representing a Spiral figure, in any state of completion. More...
 
struct  sxbp_buffer_t
 A simple buffer type for storing arrays of bytes. More...
 

Macros

#define SXBP_UP   0
 
#define SXBP_RIGHT   1
 
#define SXBP_DOWN   2
 
#define SXBP_LEFT   3
 
#define SXBP_CLOCKWISE   1
 
#define SXBP_ANTI_CLOCKWISE   -1
 

Typedefs

typedef struct sxbp_version_t sxbp_version_t
 Used to represent a version of libsxbp. More...
 
typedef enum sxbp_status_t sxbp_status_t
 Represents the success or failure status of an executed function. More...
 
typedef uint8_t sxbp_direction_t
 Type for representing one of the cartesian directions. More...
 
typedef int8_t sxbp_rotation_t
 Type for representing a rotational direction. More...
 
typedef uint32_t sxbp_length_t
 Type for representing the length of a line segment of a spiral. More...
 
typedef struct sxbp_line_t sxbp_line_t
 Represents one line segment in the spiral structure. More...
 
typedef int32_t sxbp_tuple_item_t
 Type for storing one of the items of a tuple.
 
typedef struct sxbp_tuple_t sxbp_tuple_t
 A generic Tuple type for storing a vector-based quantity.
 
typedef sxbp_tuple_t sxbp_vector_t
 A Vector type used for representing directions.
 
typedef sxbp_tuple_t sxbp_co_ord_t
 A co-ord type used for representing cartesian co-ordinates.
 
typedef struct sxbp_co_ord_array_t sxbp_co_ord_array_t
 Struct type for holding a dynamically allocated array of co-ordinates.
 
typedef struct sxbp_co_ord_cache_t sxbp_co_ord_cache_t
 Struct type for holding a cached set of co-ords. More...
 
typedef struct sxbp_spiral_t sxbp_spiral_t
 Struct type representing a Spiral figure, in any state of completion. More...
 
typedef struct sxbp_buffer_t sxbp_buffer_t
 A simple buffer type for storing arrays of bytes.
 

Enumerations

enum  sxbp_status_t {
  SXBP_STATE_UNKNOWN = 0, SXBP_OPERATION_OK, SXBP_OPERATION_FAIL, SXBP_MALLOC_REFUSED,
  SXBP_IMPOSSIBLE_CONDITION, SXBP_NOT_IMPLEMENTED
}
 Represents the success or failure status of an executed function. More...
 

Functions

bool sxbp_version_less_than (sxbp_version_t a, sxbp_version_t b)
 Checks if a version is less than another. More...
 
bool sxbp_version_greater_than (sxbp_version_t a, sxbp_version_t b)
 Checks if a version is greater than another. More...
 
bool sxbp_version_equal_to (sxbp_version_t a, sxbp_version_t b)
 Checks if a version is equal to another. More...
 

Variables

const sxbp_version_t LIB_SXBP_VERSION
 Stores the current version of libsxbp.
 
const sxbp_vector_t SXBP_VECTOR_DIRECTIONS [4]
 Vector direction constants. More...
 

Detailed Description

This compilation unit provides most of the data types used by the library, as well as defining some library constants and versioning functionality.

Author
Joshua Saxby <joshua.a.saxby+TNOPLuc8vM==.com
Date
2016, 2017

Macro Definition Documentation

#define SXBP_ANTI_CLOCKWISE   -1

The rotational direction 'ANTI-CLOCKWISE'

#define SXBP_CLOCKWISE   1

The rotational direction 'CLOCKWISE'

#define SXBP_DOWN   2

The cartesian direction 'DOWN'

#define SXBP_LEFT   3

The cartesian direction 'LEFT'

#define SXBP_RIGHT   1

The cartesian direction 'RIGHT'

#define SXBP_UP   0

The cartesian direction 'UP'

Typedef Documentation

Struct type for holding a cached set of co-ords.

This is useful for co-ords that are intended for re-use between operations which require co-ords which are certified as being correct up to a given line index.

typedef uint8_t sxbp_direction_t

Type for representing one of the cartesian directions.

This can be one of SXBP_UP, SXBP_RIGHT, SXBP_DOWN or SXBP_LEFT.

Todo:
This should be changed to an enum.
typedef uint32_t sxbp_length_t

Type for representing the length of a line segment of a spiral.

Note
Although the width of this type is 32 bits, it is actually only 30 bits when used in the sxbp_spiral_t struct type. This is because here it is a bitfield field with 30 bits allocated to it.
typedef struct sxbp_line_t sxbp_line_t

Represents one line segment in the spiral structure.

This includes the direction of the line and it's length (initially set to 0).

Note
The whole struct uses bitfields to occupy 32 bits of memory.
typedef int8_t sxbp_rotation_t

Type for representing a rotational direction.

This can be SXBP_CLOCKWISE or SXBP_ANTI_CLOCKWISE.

Todo:
This might need to be changed to an enum.
typedef struct sxbp_spiral_t sxbp_spiral_t

Struct type representing a Spiral figure, in any state of completion.

This is the most important data type in the whole library, and is passed to and from many different library functions. A partially-complete spiral object may be produced from binary data, and a fully-complete spiral may be produced from the partially complete one via the routines in the library.

Represents the success or failure status of an executed function.

Not all functions have this as their return type, but most do. Functions that may encounter error conditions which need to be propagated back to the caller will have this type as their return type.

Used to represent a version of libsxbp.

Versions are of the format <MAJOR.MINOR.patch>

Enumeration Type Documentation

Represents the success or failure status of an executed function.

Not all functions have this as their return type, but most do. Functions that may encounter error conditions which need to be propagated back to the caller will have this type as their return type.

Enumerator
SXBP_STATE_UNKNOWN 

unknown, the default state

SXBP_OPERATION_OK 

no problem

SXBP_OPERATION_FAIL 

generic failure state

SXBP_MALLOC_REFUSED 

memory allocation or re-allocation was refused

SXBP_IMPOSSIBLE_CONDITION 

condition thought to be impossible detected

SXBP_NOT_IMPLEMENTED 

function is not implemented / enabled

Function Documentation

bool sxbp_version_equal_to ( sxbp_version_t  a,
sxbp_version_t  b 
)

Checks if a version is equal to another.

Checks if version a is considered 'equal to' version b.

Parameters
aThe version on the left-hand side of this comparison.
bThe version on the right-hand side of this comparison.
Returns
true or false telling if this condition is satisfied or not.
bool sxbp_version_greater_than ( sxbp_version_t  a,
sxbp_version_t  b 
)

Checks if a version is greater than another.

Checks if version a is considered 'greater than' version b.

Parameters
aThe version on the left-hand side of this comparison.
bThe version on the right-hand side of this comparison.
Returns
true or false telling if this condition is satisfied or not.
bool sxbp_version_less_than ( sxbp_version_t  a,
sxbp_version_t  b 
)

Checks if a version is less than another.

Checks if version a is considered 'less than' version b.

Parameters
aThe version on the left-hand side of this comparison.
bThe version on the right-hand side of this comparison.
Returns
true or false telling if this condition is satisfied or not.

Variable Documentation

const sxbp_vector_t SXBP_VECTOR_DIRECTIONS[4]

Vector direction constants.

This is an array of vectors representing each cartesian direction as a vector direction. They can be indexed by the cartesian direction macros, for example:

1 sxbp_vector_t up = SXBP_VECTOR_DIRECTIONS[SXBP_UP];