libamxd  6.4.1
Data Model Manager
amxd_priv.h File Reference
#include <amxc/amxc_macros.h>
#include <amxc/amxc.h>
#include <amxp/amxp.h>
#include <amxd/amxd_types.h>

Go to the source code of this file.

Data Structures

struct  _list_parts
 

Macros

#define GET_FIELD(var, field)    amxc_var_get_path(var, field, AMXC_VAR_FLAG_DEFAULT)
 

Typedefs

typedef amxd_status_t(* list_part_fn_t) (amxd_object_t *const object, const amxc_var_t *args, amxc_var_t *const retval)
 
typedef struct _list_parts list_parts_t
 

Functions

amxd_dm_cb_t *PRIVATE amxd_get_action (const amxc_llist_t *const cb_fns, const amxd_action_t reason, amxd_action_fn_t fn)
 
void PRIVATE amxd_function_arg_clean (amxd_func_arg_t *const arg)
 
bool PRIVATE amxd_param_is_unique (amxd_object_t *const templ, amxd_object_t *const current, amxd_param_t *const param, const amxc_var_t *const value)
 
amxd_status_t PRIVATE amxd_action_set_values (amxd_object_t *const object, amxd_dm_access_t access, bool ro, const amxc_var_t *values, amxc_var_t *retval, bool required)
 
void PRIVATE amxd_param_free (amxd_param_t **param)
 
amxd_status_t PRIVATE amxd_param_counter_destroy (amxd_object_t *const object, amxd_param_t *const param, amxd_action_t reason, const amxc_var_t *const args, amxc_var_t *const retval, void *priv)
 
amxc_var_t *PRIVATE amxd_resolve_param_ref (amxd_object_t *object, amxc_var_t *ref)
 
bool PRIVATE amxd_must_add (const amxc_var_t *const args, const char *name, amxd_object_t *object)
 

Macro Definition Documentation

◆ GET_FIELD

#define GET_FIELD (   var,
  field 
)     amxc_var_get_path(var, field, AMXC_VAR_FLAG_DEFAULT)

Definition at line 76 of file amxd_priv.h.

Typedef Documentation

◆ list_part_fn_t

typedef amxd_status_t(* list_part_fn_t) (amxd_object_t *const object, const amxc_var_t *args, amxc_var_t *const retval)

Definition at line 68 of file amxd_priv.h.

◆ list_parts_t

typedef struct _list_parts list_parts_t

Function Documentation

◆ amxd_action_set_values()

amxd_status_t PRIVATE amxd_action_set_values ( amxd_object_t *const  object,
amxd_dm_access_t  access,
bool  ro,
const amxc_var_t *  values,
amxc_var_t *  retval,
bool  required 
)

Definition at line 186 of file amxd_action_object_write.c.

191  {
193 
194  amxc_var_for_each(value, values) {
195  const char* name = amxc_var_key(value);
197  if(amxc_var_type_of(value) == AMXC_VAR_ID_HTABLE) {
198  amxd_object_t* instance = NULL;
199  when_true_status(amxd_object_get_type(object) != amxd_object_template,
200  exit,
202  instance = amxd_object_get_instance(object, name, 0);
203  when_null_status(instance, exit, status = amxd_status_object_not_found);
204  ps = amxd_action_set_values(instance, access, ro, value, ret, required);
205  if(ps != amxd_status_ok) {
206  status = ps;
207  }
208  } else {
209  ps = amxd_action_set_value(object, access, name, value, ro, required, ret);
210  if(ps != amxd_status_ok) {
211  status = ps;
212  }
213  }
214  }
215 
216 exit:
217  return status;
218 }
amxd_status_t PRIVATE amxd_action_set_values(amxd_object_t *const object, amxd_dm_access_t access, bool ro, const amxc_var_t *values, amxc_var_t *ret, bool required)
static amxd_status_t amxd_action_set_value(amxd_object_t *object, amxd_dm_access_t access, const char *name, amxc_var_t *value, bool ro, bool required, amxc_var_t *ret)
enum _amxd_status amxd_status_t
@ amxd_status_object_not_found
Definition: amxd_types.h:80
@ amxd_status_ok
Definition: amxd_types.h:78
@ amxd_object_template
Definition: amxd_types.h:183
amxd_object_t * amxd_object_get_instance(const amxd_object_t *object, const char *name, uint32_t index)
Get an instance of the template object.
static amxd_object_type_t amxd_object_get_type(const amxd_object_t *const object)
Returns the object type.
Definition: amxd_object.h:586
static amxd_status_t status

◆ amxd_function_arg_clean()

void PRIVATE amxd_function_arg_clean ( amxd_func_arg_t *const  arg)

Definition at line 132 of file amxd_function_args.c.

132  {
133  amxc_llist_it_take(&arg->it);
134 
135  amxc_var_clean(&arg->default_value);
136  free(arg->name);
137  arg->name = NULL;
138 }
amxc_llist_it_t it
Definition: amxd_types.h:298
amxc_var_t default_value
Definition: amxd_types.h:302

◆ amxd_get_action()

amxd_dm_cb_t* PRIVATE amxd_get_action ( const amxc_llist_t *const  cb_fns,
const amxd_action_t  reason,
amxd_action_fn_t  fn 
)

Definition at line 99 of file amxd_common.c.

101  {
102  amxd_dm_cb_t* cb = NULL;
103  amxc_llist_for_each(it, cb_fns) {
104  cb = amxc_llist_it_get_data(it, amxd_dm_cb_t, it);
105  if((cb->reason == reason) &&
106  ((fn == NULL) || (cb->fn == fn))) {
107  break;
108  }
109  cb = NULL;
110  }
111 
112  return cb;
113 }
amxd_action_t reason
Definition: amxd_types.h:160
amxd_action_fn_t fn
Definition: amxd_types.h:159

◆ amxd_must_add()

bool PRIVATE amxd_must_add ( const amxc_var_t *const  args,
const char *  name,
amxd_object_t object 
)

Definition at line 257 of file amxd_action_object_list.c.

259  {
260  bool retval = false;
261  amxc_var_t* arg = amxc_var_get_key(args, name, AMXC_VAR_FLAG_DEFAULT);
262 
263  if(amxc_var_is_null(arg) ||
264  ( amxc_var_dyncast(bool, arg) == true)) {
265  retval = true;
266  }
267  if((strcmp(name, "instances") == 0) &&
269  retval = false;
270  }
271 
272  return retval;
273 }

◆ amxd_param_counter_destroy()

amxd_status_t PRIVATE amxd_param_counter_destroy ( amxd_object_t *const  object,
amxd_param_t *const  param,
amxd_action_t  reason,
const amxc_var_t *const  args,
amxc_var_t *const  retval,
void *  priv 
)

◆ amxd_param_free()

void PRIVATE amxd_param_free ( amxd_param_t **  param)

Definition at line 266 of file amxd_parameter.c.

266  {
267  when_null(param, exit);
268  when_null((*param), exit);
269 
270  amxd_param_clean((*param));
271  amxc_llist_it_take(&(*param)->it);
272 
273  free(*param);
274  *param = NULL;
275 
276 exit:
277  return;
278 }
static int amxd_param_clean(amxd_param_t *const param)

◆ amxd_param_is_unique()

bool PRIVATE amxd_param_is_unique ( amxd_object_t *const  templ,
amxd_object_t *const  current,
amxd_param_t *const  param,
const amxc_var_t *const  value 
)

Definition at line 166 of file amxd_action_object_write.c.

169  {
170  bool unique = true;
173  const char* pname = amxd_param_get_name(param);
174  char* v = amxc_var_dyncast(cstring_t, value);
175  amxd_object_t* instance = amxd_object_findf(templ, "[%s == '%s']", pname, v);
176  free(v);
177  if((instance != NULL) && (instance != current)) {
178  unique = false;
179  }
180 
181  }
182 
183  return unique;
184 }
bool amxd_param_is_attr_set(const amxd_param_t *const param, const amxd_pattr_id_t attr)
const char * amxd_param_get_name(const amxd_param_t *const param)
@ amxd_pattr_unique
Definition: amxd_types.h:363
@ amxd_pattr_key
Definition: amxd_types.h:362
amxd_object_t * amxd_object_findf(amxd_object_t *object, const char *rel_path,...) __attribute__((format(printf
Find an object in the data model tree, starting from an object.

◆ amxd_resolve_param_ref()

amxc_var_t* PRIVATE amxd_resolve_param_ref ( amxd_object_t object,
amxc_var_t *  ref 
)

Definition at line 189 of file amxd_action_param_validate.c.

190  {
191  amxd_object_t* ref_object = NULL;
192  amxd_param_t* ref_param = NULL;
193  amxc_var_t* ref_value = NULL;
195  char* full_ref = amxc_var_dyncast(cstring_t, ref);
196  int ref_len = strlen(full_ref);
197  char* object = full_ref;
198  char* param = NULL;
199 
200  for(int i = ref_len; i >= 0; i--) {
201  if(full_ref[i] == '.') {
202  full_ref[i] = 0;
203  param = full_ref + i + 1;
204  break;
205  }
206  }
207 
208  when_str_empty(param, exit);
209 
210  if(object[0] == 0) {
211  ref_object = obj;
212  } else {
213  if(object[0] == '.') {
214  ref_object = amxd_object_findf(obj, "%s", object);
215  } else {
216  ref_object = amxd_dm_findf(dm, "%s", object);
217  }
218  }
219  ref_param = amxd_object_get_param_def(ref_object, param);
220  when_null(ref_param, exit);
221  ref_value = &ref_param->value;
222 
223 exit:
224  free(full_ref);
225  return ref_value;
226 }
amxd_object_t * amxd_dm_findf(amxd_dm_t *const dm, const char *abs_path,...) __attribute__((format(printf
amxd_dm_t * amxd_object_get_dm(const amxd_object_t *const object)
Get the data model.
amxd_param_t * amxd_object_get_param_def(const amxd_object_t *const object, const char *name)
Gets a parameter definition from an object.
amxc_var_t value
Definition: amxd_types.h:390
static amxd_dm_t dm