tblite
Light-weight tight-binding framework
Loading...
Searching...
No Matches
context.h File Reference

Provides a persistent configuration object to modify the behaviour of a calculation. Acts as an error handler. More...

#include "tblite/macros.h"
#include "tblite/error.h"

Go to the source code of this file.

Typedefs

typedef struct _tblite_context * tblite_context
 Context manager for the library usage.
 
typedef void(* tblite_logger_callback) (tblite_error, char *, int, void *)
 Define callback function for use in custom logger.
 

Functions

TBLITE_API_ENTRY tblite_context TBLITE_API_CALL tblite_new_context (void)
 
TBLITE_API_ENTRY void TBLITE_API_CALL tblite_delete_context (tblite_context *ctx)
 
TBLITE_API_ENTRY int TBLITE_API_CALL tblite_check_context (tblite_context ctx)
 
TBLITE_API_ENTRY void TBLITE_API_CALL tblite_get_context_error (tblite_context ctx, char *buffer, const int *buffersize)
 
TBLITE_API_ENTRY void TBLITE_API_CALL tblite_set_context_logger (tblite_context ctx, tblite_logger_callback callback, void *userdata)
 
TBLITE_API_ENTRY void TBLITE_API_CALL tblite_set_context_color (tblite_context ctx, int color)
 
TBLITE_API_ENTRY void TBLITE_API_CALL tblite_set_context_verbosity (tblite_context ctx, int verbosity)
 

Detailed Description

Provides a persistent configuration object to modify the behaviour of a calculation. Acts as an error handler.

The environment context tblite_context can be considered a persistent setup for all calculations performed with the library, it is usually used together with calculator objects tblite_calculator. While the error handle can only contain a single error, multiple errors can be accumulated in a context object, which allows storing more complex error information like they can occur in an actual calculation.

Function Documentation

◆ tblite_check_context()

TBLITE_API_ENTRY int TBLITE_API_CALL tblite_check_context ( tblite_context ctx)

Check calculation environment status

Parameters
ctxContext handle
Returns
Current status, 0: okay, 1: error

◆ tblite_delete_context()

TBLITE_API_ENTRY void TBLITE_API_CALL tblite_delete_context ( tblite_context * ctx)

Delete a calculation environment object

Parameters
ctxContext handle

◆ tblite_get_context_error()

TBLITE_API_ENTRY void TBLITE_API_CALL tblite_get_context_error ( tblite_context ctx,
char * buffer,
const int * buffersize )

Get error message from calculation environment

Parameters
ctxContext handle
bufferCharacter buffer for writing error message to
buffersizeMaximum length of buffer (optional)

◆ tblite_new_context()

TBLITE_API_ENTRY tblite_context TBLITE_API_CALL tblite_new_context ( void )

Create new calculation environment object

Returns
New context handle

◆ tblite_set_context_color()

TBLITE_API_ENTRY void TBLITE_API_CALL tblite_set_context_color ( tblite_context ctx,
int color )

Enable colorful output

Parameters
ctxContext handle
colorSet color support, 0: disabled, 1: enabled

◆ tblite_set_context_logger()

TBLITE_API_ENTRY void TBLITE_API_CALL tblite_set_context_logger ( tblite_context ctx,
tblite_logger_callback callback,
void * userdata )

Set custom logger function

Parameters
ctxContext handle
callbackProcedure pointer implementing logger
userdataPassthrough data pointer

◆ tblite_set_context_verbosity()

TBLITE_API_ENTRY void TBLITE_API_CALL tblite_set_context_verbosity ( tblite_context ctx,
int verbosity )

Set verbosity level of printout

Parameters
ctxContext handle
verbosityPrintout verbosity