libamxd
6.4.1
Data Model Manager
|
Modules | |
Data Model Objects MIBs | |
Event Methods | |
RPC Methods | |
Hierarchical Tree | |
Parameters | |
Macros | |
#define | amxd_object_for_each(type, it, object) |
Helper macro for iterating object content. More... | |
#define | amxd_object_iterate(type, it, object) |
Helper macro for iterating object content. More... | |
Functions | |
amxd_status_t | amxd_object_new (amxd_object_t **object, const amxd_object_type_t type, const char *name) |
Data model object constructor function. More... | |
void | amxd_object_free (amxd_object_t **object) |
Data model object destructor function. More... | |
amxd_status_t | amxd_object_new_instance (amxd_object_t **object, amxd_object_t *templ, const char *name, uint32_t index, amxc_var_t *values) |
Data model object constructor function. More... | |
amxd_status_t | amxd_object_add_instance (amxd_object_t **object, amxd_object_t *templ, const char *name, uint32_t index, amxc_var_t *values) |
Data model object constructor function. More... | |
void | amxd_object_delete (amxd_object_t **object) |
Invokes the destroy handler(s) of the object. More... | |
const char * | amxd_object_get_name (const amxd_object_t *const object, const uint32_t flags) |
Get the name of the object (or index as a string for instance objects) More... | |
uint32_t | amxd_object_get_index (const amxd_object_t *const object) |
Get the index of an instance object. More... | |
static amxd_object_type_t | amxd_object_get_type (const amxd_object_t *const object) |
Returns the object type. More... | |
amxd_status_t | amxd_object_set_attr (amxd_object_t *const object, const amxd_oattr_id_t attr, const bool enable) |
Sets or unsets an object attribute. More... | |
amxd_status_t | amxd_object_set_attrs (amxd_object_t *const object, const uint32_t bitmask, bool enable) |
Sets or unsets object attributes using a bitmap. More... | |
uint32_t | amxd_object_get_attrs (const amxd_object_t *const object) |
Gets the set attributes of an object. More... | |
bool | amxd_object_is_attr_set (const amxd_object_t *const object, const amxd_oattr_id_t attr) |
Checks if an attribute is set. More... | |
#define amxd_object_for_each | ( | type, | |
it, | |||
object | |||
) |
Helper macro for iterating object content.
This helper macro can iterator over:
The iterator should not be declared.
Using this macro it is allowed to remove (delete) the iterators containing data structure
The iterator can be converted to the correct type using amxc_container_of macro.
For parameters the iterator is a member of the amxd_param_t structure, for functions the iterator is a member of the amxd_function_t structure, for instances and child objects the iterator is a member of the amxd_object_t structure.
type | can be one of [parameter, function, child, instance] |
it | a linked list iterator |
object | the object |
Definition at line 113 of file amxd_object.h.
#define amxd_object_iterate | ( | type, | |
it, | |||
object | |||
) |
Helper macro for iterating object content.
This helper macro can iterator over:
The iterator should not be declared.
The iterator can be converted to the correct type using amxc_container_of macro. For parameters the iterator is a member of the amxd_param_t structure, for functions the iterator is a member of the amxd_function_t structure, for instances and child objects the iterator is a member of the amxd_object_t structure.
type | can be one of [parameter, function, child, instance] |
it | a linked list iterator |
object | the object |
Definition at line 149 of file amxd_object.h.
amxd_status_t amxd_object_add_instance | ( | amxd_object_t ** | object, |
amxd_object_t * | templ, | ||
const char * | name, | ||
uint32_t | index, | ||
amxc_var_t * | values | ||
) |
Data model object constructor function.
Creates a new instance of a template object and sets the values of the parameters if provided.
If the template contains key parameters, the values for these parameters must be provided.
This function calls amxd_object_new_instance to allocate memory for the object and to check if it can be created (unique name, index and key values)
If creation is successful, the values for the key parameters and other parameters are set in one go.
To be able to create a new object a valid name must be given or NULL. The name of each node (object) in the hierarchy MUST start with a letter or underscore, and subsequent characters MUST be letters, digits, underscores or hyphens.
The name and index (if given) must be unique in the context of the template object - no other instance can exist with the same name or index.
The instance inherits all attributes, all parameters (except template only parameters) and all functions (except template only functions) of the template object.
The newly created object will have as parent the template object.
To remove an instance use amxd_object_delete
object | pointer to an object pointer. The address of the new allocated object is stored in this pointer. |
templ | pointer to template object. |
name | A valid object name or NULL. The name of each object in the hierarchy MUST start with a letter or underscore, and subsequent characters MUST be letters, digits, underscores or hyphens.' |
index | A uinique index or 0 |
values | A variant containing a hash table with at least all the values for key parameters. These values will be used to set the parameter values. |
Definition at line 301 of file amxd_action_object_add_inst.c.
void amxd_object_delete | ( | amxd_object_t ** | object | ) |
Invokes the destroy handler(s) of the object.
This method doesn't remove the object from the data model.
To remove the object, including the subtree, and free all allocated memory use amxd_object_free
object | pointer to an object pointer. |
Definition at line 80 of file amxd_action_object_destroy.c.
void amxd_object_free | ( | amxd_object_t ** | object | ) |
Data model object destructor function.
Frees all memory allocated for an object.
If the object was in a data model tree, it is removed from that tree.
If the object has childeren (or instances) all these are freed and removed as well.
object | pointer to an object pointer. |
Definition at line 153 of file amxd_object.c.
uint32_t amxd_object_get_attrs | ( | const amxd_object_t *const | object | ) |
Gets the set attributes of an object.
This function returns the set attributes of an object as a bitmask. To verify if a certain attribute is set, use the macro IS_BIT_SET.
To verify that one single attribute is set the function amxd_object_is_attr_set can be used.
object | the object pointer |
Definition at line 334 of file amxd_object.c.
uint32_t amxd_object_get_index | ( | const amxd_object_t *const | object | ) |
Get the index of an instance object.
This function returns the index of an instance object. For singletons or template objects this function will always return 0.
object | the object pointer |
Definition at line 265 of file amxd_object.c.
const char* amxd_object_get_name | ( | const amxd_object_t *const | object, |
const uint32_t | flags | ||
) |
Get the name of the object (or index as a string for instance objects)
Depending on the flags given the name or index is returned for instance objects, for all other types of objects the flags are ignored
object | the object pointer |
flags | can be one of AMXD_OBJECT_NAMED or AMXD_OBJECT_INDEXED |
Definition at line 239 of file amxd_object.c.
|
inlinestatic |
Returns the object type.
The type of a data model object can be:
object | the object pointer |
Definition at line 586 of file amxd_object.h.
bool amxd_object_is_attr_set | ( | const amxd_object_t *const | object, |
const amxd_oattr_id_t | attr | ||
) |
Checks if an attribute is set.
The following attribute identifiers can be checked
object | the object pointer |
attr | the object attribute id |
Definition at line 348 of file amxd_object.c.
amxd_status_t amxd_object_new | ( | amxd_object_t ** | object, |
const amxd_object_type_t | type, | ||
const char * | name | ||
) |
Data model object constructor function.
Allocates memory for a new data model object and initializes the object.
The following object types can be created with this function:
Instances of template objects must be created with the function amxd_object_new_instance or amxd_object_add_instance
To be able to create a new object a valid name must be given. The name of each node (object) in the hierarchy MUST start with a letter or underscore, and subsequent characters MUST be letters, digits, underscores or hyphens.
No attributes are set. Object attributes can be changed by using one of the following functions:
The newly created object is not added to the data model tree automatically. You can add the new object in the data model by using the function amxd_object_add_object.
Use amxd_object_delete to remove the object and free all allocated memory.
object | pointer to an object pointer. The address of the new allocated object is stored in this pointer. |
type | the object type that needs to be created. this can be one of amxd_object_singleton, amxd_object_template, amxd_object_mib |
name | A valid object name. The name of each object in the hierarchy MUST start with a letter or underscore, and subsequent characters MUST be letters, digits, underscores or hyphens. |
Definition at line 185 of file amxd_object.c.
amxd_status_t amxd_object_new_instance | ( | amxd_object_t ** | object, |
amxd_object_t * | templ, | ||
const char * | name, | ||
uint32_t | index, | ||
amxc_var_t * | values | ||
) |
Data model object constructor function.
Creates a new instance of a template object. When passing a NULL pointer for the name, the name is the same as the index (but in string format). When passing 0 for the index. the next index is taken.
This function only allocates memory to store the object but will not assign values to the parameters. The parameter values passed to this function are only used to check if no other instance exists with the same values for the key parameters.
If creation is successful, the values for the key parameters and other parameters must still be set. Use amxd_object_add_instance to create an instance an fill the parameter values in one go.
To be able to create a new object a valid name must be given or NULL. The name of each node (object) in the hierarchy MUST start with a letter or underscore, and subsequent characters MUST be letters, digits, underscores or hyphens.
The name and index (if given) must be unique in the context of the template object - no other instance can exist with the same name or index.
The instance inherts all attributes, all parameters (except template only paramters) and all functions (except template only functions) of the template object .
The newly created object will have as parent the template object.
To remove an instance use amxd_object_delete
object | pointer to an object pointer. The address of the new allocated object is stored in this pointer. |
templ | pointer to template object. |
name | A valid object name or NULL. The name of each object in the hierarchy MUST start with a letter or underscore, and subsequent characters MUST be letters, digits, underscores or hyphens.' |
index | A uinique index or 0 |
values | A variant containing a hash table with at least all the values for key parameters. These are used to verify that the innstance is unique. |
Definition at line 350 of file amxd_object_instance.c.
amxd_status_t amxd_object_set_attr | ( | amxd_object_t *const | object, |
const amxd_oattr_id_t | attr, | ||
const bool | enable | ||
) |
Sets or unsets an object attribute.
The following attributes can be set - unset:
object | the object pointer |
attr | the object attribute id |
enable | when true, sets the attribute, when false unsets the attribute |
Definition at line 269 of file amxd_object.c.
amxd_status_t amxd_object_set_attrs | ( | amxd_object_t *const | object, |
const uint32_t | bitmask, | ||
bool | enable | ||
) |
Sets or unsets object attributes using a bitmap.
The following attributes can be set - unset:
Use the macro SET_BIT to transform the attribute id to a bit. The bits can be joined together using the bitwise or operator '|'
When setting or unsetting one single attribute the function amxd_object_set_attr can be used.
object | the object pointer |
bitmask | the object attribute bitmask |
enable | when true, sets the attributes, when false unsets the attributes |
Definition at line 301 of file amxd_object.c.