C Configuration Space and Tuning Library (CCS)
Loading...
Searching...
No Matches
Functions
context.h File Reference

A Context is a collection of parameters defining a value space. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ccs_result_t ccs_context_get_name (ccs_context_t context, const char **name_ret)
 Get the name of a context.
 
ccs_result_t ccs_context_get_parameter (ccs_context_t context, size_t index, ccs_parameter_t *parameter_ret)
 Get an parameter in a context given its index.
 
ccs_result_t ccs_context_get_parameters (ccs_context_t context, size_t num_parameters, ccs_parameter_t *parameters, size_t *num_parameters_ret)
 Get the parameters in the given context.
 
ccs_result_t ccs_context_get_parameter_by_name (ccs_context_t context, const char *name, ccs_parameter_t *parameter_ret)
 Get an parameter in a context given its name.
 
ccs_result_t ccs_context_get_parameter_index_by_name (ccs_context_t context, const char *name, ccs_bool_t *found_ret, size_t *index_ret)
 Get the index of an parameter in the context given its name.
 
ccs_result_t ccs_context_get_parameter_index (ccs_context_t context, ccs_parameter_t parameter, ccs_bool_t *found_ret, size_t *index_ret)
 Get the index of an parameter in the context.
 
ccs_result_t ccs_context_get_parameter_indexes (ccs_context_t context, size_t num_parameters, ccs_parameter_t *parameters, ccs_bool_t *found, size_t *indexes)
 Get the indices of a set of parameters in a context.
 
ccs_result_t ccs_context_validate_value (ccs_context_t context, size_t index, ccs_datum_t value, ccs_datum_t *value_ret)
 Validate that a given value at the given index is valid in the context, and return a sanitized value.
 

Detailed Description

A Context is a collection of parameters defining a value space.

Each parameter has a specific index that can be used to reference it. The methods defined in this file can be used on objects who are contexts. In practice those are useful for binding to avoid binding the children methods, whereas a C application would rather use the object class specific versions in order to benefit from the added type safety.

Function Documentation

◆ ccs_context_get_name()

ccs_result_t ccs_context_get_name ( ccs_context_t  context,
const char **  name_ret 
)
extern

Get the name of a context.

Parameters
[in]context
[out]name_reta pointer to a char * variable which will contain a pointer to the context name.
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if context is not a valid CCS object
CCS_RESULT_ERROR_INVALID_VALUE if name_ret is NULL
Remarks
This function is thread-safe

◆ ccs_context_get_parameter()

ccs_result_t ccs_context_get_parameter ( ccs_context_t  context,
size_t  index,
ccs_parameter_t parameter_ret 
)
extern

Get an parameter in a context given its index.

Parameters
[in]context
[in]indexthe index of the parameter to retrieve
[out]parameter_reta pointer to the variable that will contain the parameter
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if context is not a valid CCS object
CCS_RESULT_ERROR_INVALID_VALUE if parameter_ret is NULL
CCS_RESULT_ERROR_OUT_OF_BOUNDS if index is greater than the count of parameters in the context
Remarks
This function is thread-safe

◆ ccs_context_get_parameter_by_name()

ccs_result_t ccs_context_get_parameter_by_name ( ccs_context_t  context,
const char *  name,
ccs_parameter_t parameter_ret 
)
extern

Get an parameter in a context given its name.

Parameters
[in]context
[in]namethe name of the parameter to retrieve
[out]parameter_reta pointer to the variable that will contain the parameter, or NULL if the parameter is not found in the context
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if context is not a valid CCS object
CCS_RESULT_ERROR_INVALID_VALUE if name or parameter_ret are NULL
Remarks
This function is thread-safe

◆ ccs_context_get_parameter_index()

ccs_result_t ccs_context_get_parameter_index ( ccs_context_t  context,
ccs_parameter_t  parameter,
ccs_bool_t found_ret,
size_t *  index_ret 
)
extern

Get the index of an parameter in the context.

Parameters
[in]context
[in]parameter
[out]found_reta pointer to the an optional variable that will hold whether the parameter was found in the context
[out]index_reta pointer to the variable which will contain the index of the parameter
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if context is not a valid CCS object;
CCS_RESULT_ERROR_INVALID_VALUE if index_ret is NULL
CCS_RESULT_ERROR_INVALID_PARAMETER if found_ret is NULL and context does not contain parameter
Remarks
This function is thread-safe

◆ ccs_context_get_parameter_index_by_name()

ccs_result_t ccs_context_get_parameter_index_by_name ( ccs_context_t  context,
const char *  name,
ccs_bool_t found_ret,
size_t *  index_ret 
)
extern

Get the index of an parameter in the context given its name.

Parameters
[in]context
[in]namethe name of the parameter to retrieve the index of
[out]found_reta pointer to the an optional variable that will hold whether a parameter named name was found in context
[out]index_reta pointer to the variable that will contain the index of parameter in the context
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if context is not a valid CCS object
CCS_RESULT_ERROR_INVALID_VALUE if name or index_ret are NULL
CCS_RESULT_ERROR_INVALID_NAME if found_ret is NULL and no parameter with such name exist in the context
Remarks
This function is thread-safe

◆ ccs_context_get_parameter_indexes()

ccs_result_t ccs_context_get_parameter_indexes ( ccs_context_t  context,
size_t  num_parameters,
ccs_parameter_t parameters,
ccs_bool_t found,
size_t *  indexes 
)
extern

Get the indices of a set of parameters in a context.

Parameters
[in]context
[in]num_parametersthe number of parameters to query the index for
[in]parametersan array of num_parameters parameters to query the index for
[out]foundan optional array of num_parameters variables that will hold whether the parameter was found in context
[out]indexesan array of num_parameters indices that will contain the values of the parameter indices
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if context is not a valid CCS object
CCS_RESULT_ERROR_INVALID_VALUE if parameters is NULL and num_parameters is greater than 0; or if indexes is NULL and num_parameters is greater than 0
CCS_RESULT_ERROR_INVALID_PARAMETER if found_ret is NULL and at least one of the parameters is not contained in context
Remarks
This function is thread-safe

◆ ccs_context_get_parameters()

ccs_result_t ccs_context_get_parameters ( ccs_context_t  context,
size_t  num_parameters,
ccs_parameter_t parameters,
size_t *  num_parameters_ret 
)
extern

Get the parameters in the given context.

Parameters
[in]context
[in]num_parametersis the number of parameters that can be added to parameters. If parameters is not NULL num_parameters must be greater than 0
[in]parametersan array of num_parameters that will contain the returned parameters or NULL. If the array is too big, extra values are set to NULL
[out]num_parameters_reta pointer to a variable that will contain the number of parameters that are or would be returned. Can be NULL
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if context is not a valid CCS object
CCS_RESULT_ERROR_INVALID_VALUE if parameters is NULL and num_parameters is greater than 0; or if parameters is NULL and num_parameters_ret is NULL; or if num_parameters is less than the number of parameters that would be returned
Remarks
This function is thread-safe

◆ ccs_context_validate_value()

ccs_result_t ccs_context_validate_value ( ccs_context_t  context,
size_t  index,
ccs_datum_t  value,
ccs_datum_t value_ret 
)
extern

Validate that a given value at the given index is valid in the context, and return a sanitized value.

Parameters
[in]context
[in]indexthe index of the value in the context
[in]valuethe datum to validate
[out]value_reta pointer that will contain the validated value. If value is a string value_ret will contain a non transient string.
Returns
CCS_RESULT_SUCCESS on success
CCS_RESULT_ERROR_INVALID_OBJECT if context is not a valid CCS object
CCS_RESULT_ERROR_OUT_OF_BOUNDS if index is greater than the number of parameters in context
CCS_RESULT_ERROR_OUT_OF_MEMORY if there was a lack of memory while memoizing a string
CCS_RESULT_ERROR_INVALID_VALUE if the value did not validate or if value_ret is NULL
Remarks
This function is thread-safe