#Describe what will have to be installed or in the package by default the prefix (CMAKE_INSTALL_PREFIX) is '/usr/’ or '/usr/local' depending on your system
You are advised to used standard [blaar install](https://framagit.org/blaar/blaar/wikis/INSTALL) but you are free to make a manual installation
Manual install with cmake
-------------------------
You need git, g++, cmake and doxygen for the documentation:
- Ubuntu:
```sh
sudo apt-get install git g++ cmake
```
- OSX with [homebrew](http://brew.sh) and any C++ compiler
```sh
brew install git cmake
```
You can copy past the following code:
```sh
git clone https://framagit.org/blaar/blc_core.git
cd blc_core
mkdir build
cd build
cmake ..
make
sudo make install
```
The created library `libblc_core.{so|dylib}` and `libblc_core.a` will be in `/usr/local/lib`. Includes in `/usr/local/include/blc_core` and a cmake config file in `/usr/local/share/blc_core`
You can create a debian package (.deb) with:
make package
Manual install with simple makefiles
====================================
All the sources are in src, includes in include and the previous lines allow you to create an adequate makefile
/**Print all the properties of the array in a file or stderr by default. (i.e. "UIN8 RGB3 3x800x600")*/
voidfprint_properties(FILE*file=stderr);
/* Modifying the properties of the array
======================================*/
/**Add one dimention to the definition of the blc_array. You have to manage eventual **memory reallocation** yourself.*/
voidadd_dim(intlength,intstep);
/**Add one dimension ti the definition of the blc_array. The step is infered from the type of the data and the size of the previous dimension. You have to manage the eventual **memory reallocation** yourself.*/
voidadd_dim(intlength);
/** Set all the dims of the array*/
voidset_dims(intdims_nb,intlength,...);
intsprint_dims(char*string,intsize);
intfprint_dims(FILE*file)const;
voidfprint_debug(FILE*file)const;
/**Set all dims by reading the properties from the string (i.e. "3x800x600" ). You have to manage eventual **memory reallocation** yourself. */
intsscan_dims(charconst*string);
/**Set all dims by reading the properties from the file (i.e. "3x800x600" ). You have to manage eventual **memory reallocation** yourself. */
voidfscan_dims(FILE*file);
/**Set all properties by reading the properties from the string (i.e. "UIN8 RGB3 3x800x600" ). You have to manage eventual **memory reallocation** yourself. */
voidsscan_properties(charconst*string);
/**Set all properties by reading the properties from the file (i.e. "UIN8 RGB3 3x800x600" ). You have to manage eventual **memory reallocation** yourself. */
///Scan and interpret the string as the description of the dimensions of a **blc_channel**. **Return** how many chars have been interpreted.
intsscan_dims(charconst*string);
intget_type_size();
size_tget_minimum_size();
/**Defines the array without allocating the data by reading the file with .blc extension*/
voiddef_with_blc_file(charconst*filename);
/**Defines and allocates the blc_array depending on the description of the blc file (with .blc extension) but does not update the data. This allow you to refresh data without reallocating memory.*/
voidinit_with_blc_file(charconst*filename);
/**Update the content of the memory with the content of the blc file. The blc_array has to be properly defined and allocated before. .blc format is a specific format, whre de first line is the properties of the blc_array and them it is raw binary memory. It may be a problem with endianness */
voidupdate_with_blc_file(charconst*filename);
voidsave_blc_file(charconst*filename);
voidfprint_tsv(FILE*file);
/**Same as update_with_blc_file but this reas .tsv, tab separated values (i.e. 0.75 0.33 0.55 ). Typically used with excel and similar. You have to care yourself to define and allocate an appropriate blc_array.*/
voidupdate_with_tsv_file(charconst*filename);
voidsave_tsv_file(charconst*filename);
/*Writing data in files
=====================*/
/**Create a .blc file with the content of the blc_array. This is meant to be used with init_with_blc_file, update_with_blc_file.*/
voidsave_blc_file(charconst*filename);
/**Write the content of the blc_array as TSV (tab separated values) in a file. It can also be used to write on the terminal.*/
voidfprint_tsv(FILE*file=stderr);
/**Comme fprint_tsv but automtically create the file. With filename which must have .tsv extension.*/
voidsave_tsv_file(charconst*filename);
/**Print the blc_array as a text_graph surface. Only works with 2D blc_array of type 'UIN8'. It draws a matrix of values. If ansi terminal is 1, it draws colored valuse depending on the blc_uchar_color_scale.*/
/**Return the size in bytes of one element depending on the type of data of the blc_array*/
intget_type_size();
#else
{
blc_memmem;
blc_memmem;///< raw memory of the array
#endif
blc_dim*dims;
intdims_nb;
uint32_ttype,format;
size_ttotal_length;
blc_dim*dims;///< array of dimentions of the blc_array
intdims_nb;///< number of dimension of the blc_array
uint32_ttype;///< type of data in the memory as a unsigned int of 4 bytes. Possibilities are 'UIN8' uchar, 'INT8' char, 'UI16' uint16_t, 'IN16' int16_t, 'UI32' uint32_t, 'IN32' int32_t, 'FL32' float, 'FL64' double
uint32_tformat;///< describes how the data should be interpreted. 'NDEF' (no specification), 'TEXT' for strings, 'Y800' black and white image, 'RGB3' image in RGB, 'LPCM' sound in non compressed format, ...
size_ttotal_length;///<Total number of elements in the array. This differ of size if an element is bigger than one byte.
and, more generally, to use and operate it in the same conditions as regards security.
The fact that you are presently reading this means that you have had knowledge of the CeCILL v2.1 license and that you accept its terms. */
/**
@date Apr 28, 2014
@author Arnaud Blanchard
@defgroup blc_mem blc_mem
@{
@brief Structure with a data pointer and a size. This kind of functionnalities are more complete with the Standard Template Library (STL) or boost, but it is much simpler here.
@code{.c}
typedef struct blc_mem {
//This union is a convenient shortcut for casting the data pointer.
union{
void *data;
char *chars;
uchar *uchars;
int16_t *ints16;
uint16_t *uints16;
int32_t *ints32;
uint32_t *uints32;
float *floats;
double *doubles;
};
size_t size;
}
@endcode
*/
#ifndef BLC_MEM_H
#define BLC_MEM_H
...
...
@@ -45,8 +22,19 @@
#include "blc_tools.h"
#include <stdio.h>
/**
@defgroup blc_mem blc_mem
@{
@brief Provides simple tools to dynamically manipulate memory.
This kind of functionnalities are more complete with the Standard Template Library (https://en.wikipedia.org/wiki/Standard_Template_Library) but it much simpler here and works with plain C.
blc_mem is included in blc_array
*/
/** Description of a block of memory with a pointer and a size.*/
typedefstructblc_mem{
//We can use only one of this datatpe at a time
///The union is used to cast the pointer in whatever you want. It does NOT mean you allocate n pointers.
///Stop on pthread error and display the error message. Error is any int variable you need to provide to the macro.
/**
@defgroup blc_realtime blc_realtime
Few functions and shortcut helping for pseudo (standard unix is not realtime anyway) realtime applications
@{*/
///Maximum size of a semaphore name
#define BLC_SEM_NAME_LEN 31 // At least on OSX
/**Write the appropriate message error and exit the program for functions error returned by pthread_... functions. It is similar to EXIT_ON_SYSTEM_ERROR but for pthread_... functions*/
/**Execute the command which should be something like 'pthread_...', check the return value and display the error message and exit on error. Error_variable is any int variable you need to provide to the macro. It will be set to 0 in case of success.
It is a good habit to always check the return value of this function. Exemple: