Query the current thread local context.
More...
|
| 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_Log * | ato_ctx_log (ato_Ctx *ctx) |
| | Get the logger associated with the current context. More...
|
| |
| ATO_EXPORT ato_Err * | ato_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_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. 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...
|
| |
Query the current thread local context.
typedef struct _ato_Ctx ato_Ctx;
◆ 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
-
| ctx | the address of the context object to create. |
| id | if 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
-
◆ ato_ctx_log()
Get the logger associated with the current context.
- Parameters
-
- Returns
- the logger or NULL if none has been initialised.
◆ ato_ctx_err()
Get the error object associated with the current context, if any.
- Parameters
-
- 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
-
- 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
-
| ctx | the context. |
| id | a logging id to use - if NULL defaults to the context id |
| logindent | amount to indent nested calls - NULL or empty - use ato_arg_value("logindent") else use "2" |
| logpath | null or empty - use ato_arg_value("logpath") else use "messages.log"; "none" - don't log; "stdout"; "stderr"; else use as logfile (ato_log_outputtype()) |
| mode | passed 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
-
| ctx | the context. |
| key | the 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
-
| ctx | the context. |
| key | the 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
-
| ctx | the context. |
| key | the 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
-
| ctx | the context. |
| key | the key name - an internal copy is made. |
| value | - this is referenced - do not free |
- Returns
- the associate value or NULL.