atobase  3.2.0
ATOMAS atobase
Context

Query the current thread local context. More...

Functions

ATO_EXPORT void ato_ctx_create (ato_Ctx **ctx, const char *id)
 Create a context object for thread local storage - use ato_ctx_free() to free. More...
 
ATO_EXPORT void ato_ctx_free (ato_Ctx *ctx)
 Free the context object. More...
 
ATO_EXPORT ato_Logato_ctx_log (ato_Ctx *ctx)
 Get the logger associated with the current context. More...
 
ATO_EXPORT ato_Errato_ctx_err (ato_Ctx *ctx)
 Get the error object associated with the current context, if any. More...
 
ATO_EXPORT const char * ato_ctx_id (ato_Ctx *ctx)
 Get the unique id associated with this instance. More...
 
ATO_EXPORT ato_Logato_ctx_log_set (ato_Ctx *ctx, const char *id, const char *logindent, const char *logpath, const char *mode)
 Set logging properties to control the behaviour of logging. More...
 
ATO_EXPORT void * ato_ctx_cache (ato_Ctx *ctx, const char *key)
 Get the value object associated with the given key in the given context. More...
 
ATO_EXPORT void * ato_ctx_cache_set (ato_Ctx *ctx, const char *key, void *value)
 Set the value object associated with the given key in the given context. More...
 
ATO_EXPORT const void * ato_ctx_cachec (ato_Ctx *ctx, const char *key)
 Get the value object associated with the given key in the given context. More...
 
ATO_EXPORT const void * ato_ctx_cachec_set (ato_Ctx *ctx, const char *key, const void *value)
 Set the value object associated with the given key in the given context. More...
 

Detailed Description

Query the current thread local context.

typedef struct _ato_Ctx ato_Ctx;

Function Documentation

◆ ato_ctx_create()

ATO_EXPORT void ato_ctx_create ( ato_Ctx **  ctx,
const char *  id 
)

Create a context object for thread local storage - use ato_ctx_free() to free.

At least one object should be created per thread.

    ato_ctx_create(&global_ctx);
Parameters
ctxthe address of the context object to create.
idif NULL create an internal guid to distinguish instances.

◆ ato_ctx_free()

ATO_EXPORT void ato_ctx_free ( ato_Ctx ctx)

Free the context object.

This should be done AFTER freeing all other objects bug PRIOR to freeing the configuration manager.

Parameters
ctxthe context object

◆ ato_ctx_log()

ATO_EXPORT ato_Log* ato_ctx_log ( ato_Ctx ctx)

Get the logger associated with the current context.

Parameters
ctxthe context.
Returns
the logger or NULL if none has been initialised.

◆ ato_ctx_err()

ATO_EXPORT ato_Err* ato_ctx_err ( ato_Ctx ctx)

Get the error object associated with the current context, if any.

Parameters
ctxthe context.
Returns
the error object or NULL if no error.

◆ ato_ctx_id()

ATO_EXPORT const char* ato_ctx_id ( ato_Ctx ctx)

Get the unique id associated with this instance.

Parameters
ctxthe context.
Returns
the context "id".

◆ ato_ctx_log_set()

ATO_EXPORT ato_Log* ato_ctx_log_set ( ato_Ctx ctx,
const char *  id,
const char *  logindent,
const char *  logpath,
const char *  mode 
)

Set logging properties to control the behaviour of logging.

Parameters
ctxthe context.
ida logging id to use - if NULL defaults to the context id
logindentamount to indent nested calls - NULL or empty - use ato_arg_value("logindent") else use "2"
logpathnull or empty - use ato_arg_value("logpath") else use "messages.log"; "none" - don't log; "stdout"; "stderr"; else use as logfile (ato_log_outputtype())
modepassed to fopen
Returns
the logging object associated with the context.

◆ ato_ctx_cache()

ATO_EXPORT void* ato_ctx_cache ( ato_Ctx ctx,
const char *  key 
)

Get the value object associated with the given key in the given context.

Parameters
ctxthe context.
keythe key name.
Returns
the associate value or NULL.

◆ ato_ctx_cache_set()

ATO_EXPORT void* ato_ctx_cache_set ( ato_Ctx ctx,
const char *  key,
void *  value 
)

Set the value object associated with the given key in the given context.

Parameters
ctxthe context.
keythe key name - an internal copy is made.
value- this is referenced - do not free
Returns
the associate value or NULL.

◆ ato_ctx_cachec()

ATO_EXPORT const void* ato_ctx_cachec ( ato_Ctx ctx,
const char *  key 
)

Get the value object associated with the given key in the given context.

Parameters
ctxthe context.
keythe key name.
Returns
the associate value or NULL.

◆ ato_ctx_cachec_set()

ATO_EXPORT const void* ato_ctx_cachec_set ( ato_Ctx ctx,
const char *  key,
const void *  value 
)

Set the value object associated with the given key in the given context.

Parameters
ctxthe context.
keythe key name - an internal copy is made.
value- this is referenced - do not free
Returns
the associate value or NULL.