libamxs  0.6.0
Data Model Synchronization C API
Object synchronization API
Collaboration diagram for Object synchronization API:

Functions

amxs_status_t amxs_sync_object_new (amxs_sync_object_t **object, const char *object_a, const char *object_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
 Synchronization object constructor function. More...
 
amxs_status_t amxs_sync_object_new_copy (amxs_sync_object_t **object, const char *object_a, const char *object_b, int attributes)
 Synchronization object constructor function. More...
 
void amxs_sync_object_delete (amxs_sync_object_t **object)
 Synchronization object destructor function. More...
 
amxs_status_t amxs_sync_object_add_param (amxs_sync_object_t *object, amxs_sync_param_t *param)
 Adds a synchronization parameter to a synchronization object. More...
 
amxs_status_t amxs_sync_object_add_new_param (amxs_sync_object_t *object, const char *param_a, const char *param_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
 Creates and adds a synchronization parameter to a synchronization object. More...
 
amxs_status_t amxs_sync_object_add_new_copy_param (amxs_sync_object_t *object, const char *param_a, const char *param_b, int attributes)
 Creates and adds a synchronization parameter to a synchronization object. More...
 
amxs_status_t amxs_sync_object_add_object (amxs_sync_object_t *parent, amxs_sync_object_t *child)
 Adds a synchronization object to a synchronization object. More...
 
amxs_status_t amxs_sync_object_add_new_object (amxs_sync_object_t *parent, const char *object_a, const char *object_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
 Creates and adds a synchronization object to a synchronization object. More...
 
amxs_status_t amxs_sync_object_add_new_copy_object (amxs_sync_object_t *parent, const char *object_a, const char *object_b, int attributes)
 Creates and adds a synchronization object to a synchronization object. More...
 

Detailed Description

Function Documentation

◆ amxs_sync_object_add_new_copy_object()

amxs_status_t amxs_sync_object_add_new_copy_object ( amxs_sync_object_t parent,
const char *  object_a,
const char *  object_b,
int  attributes 
)

Creates and adds a synchronization object to a synchronization object.

Allocates memory for a new synchronization object and initializes this object. Then adds it to the parent synchronization object.

Adding the synchronization object fails when:

  • The child object was already added to the parent object.
  • The child object attributes are conflicting with those of the parent object. E.g. The child object has the AMXS_SYNC_ONLY_B_TO_A attribute set, and the parent object has AMXS_SYNC_ONLY_A_TO_B set.

If the parent attributes are more strict than those of the child, the child attributes will be updated to match those of the parent.

Uses default translation amxs_sync_object_copy_trans_cb and action amxs_sync_object_copy_action_cb callbacks.

Parameters
parentPointer to the parent synchronization object.
object_aName of the object in object A
object_bName of the object in object B
attributesBitwise OR of zero or more of the following attributes:
Returns
  • amxs_status_ok: the new child object is added to the parent object
  • amxs_status_duplicate: another child object with the same direction and object names already exists for the parent object
  • amxs_status_invalid_attr: the attributes of the child object are conflicting with those of the parent object
  • amxs_status_unknown_error: any other error

Definition at line 195 of file amxs_sync_object.c.

198  {
199  return amxs_sync_object_add_new_object(parent,
200  object_a,
201  object_b,
202  attributes,
205  NULL);
206 }
amxs_status_t amxs_sync_object_add_new_object(amxs_sync_object_t *parent, const char *object_a, const char *object_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
Creates and adds a synchronization object to a synchronization object.
amxs_status_t amxs_sync_object_copy_trans_cb(const amxs_sync_entry_t *entry, amxs_sync_direction_t direction, const amxc_var_t *input, amxc_var_t *output, void *priv)
Translates data from a dm:instance-added or dm:instance-removed event to data suited for an amxb call...
amxs_status_t amxs_sync_object_copy_action_cb(const amxs_sync_entry_t *entry, amxs_sync_direction_t direction, amxc_var_t *data, void *priv)
Adds, removes or updates an object with the given data using an amxb call.

◆ amxs_sync_object_add_new_copy_param()

amxs_status_t amxs_sync_object_add_new_copy_param ( amxs_sync_object_t object,
const char *  param_a,
const char *  param_b,
int  attributes 
)

Creates and adds a synchronization parameter to a synchronization object.

Allocates memory for a new synchronization parameter and initializes this parameter. Then adds it to the synchronization object.

Adding the synchronization parameter fails when:

  • The parameter was already added to the object.
  • The parameter attributes are conflicting with those of the object. E.g. The object has the AMXS_SYNC_ONLY_B_TO_A attribute set, and the parameter has AMXS_SYNC_ONLY_A_TO_B set.

If the object attributes are more strict than those of the parameter, the parameter attributes will be updated to match those of the object.

Uses default translation amxs_sync_batch_param_copy_trans_cb and action amxs_sync_param_copy_action_cb callbacks.

Parameters
objectPointer to a synchronization object.
param_aName of the parameter in object A
param_bName of the parameter in object B
attributesBitwise OR of zero or more of the following attributes:
Returns
  • amxs_status_ok: the synchronization parameter is added to the synchronization object
  • amxs_status_duplicate: another synchronization parameter with the same direction and parameter names already exists for this synchronization object
  • amxs_status_invalid_attr: the attributes of the synchronization parameter are conflicting with those of the synchronization object
  • amxs_status_unknown_error: any other error

Definition at line 147 of file amxs_sync_object.c.

150  {
151  return amxs_sync_object_add_new_param(object,
152  param_a,
153  param_b,
154  attributes | AMXS_SYNC_PARAM_BATCH,
155  NULL,
156  NULL,
157  NULL);
158 }
amxs_status_t amxs_sync_object_add_new_param(amxs_sync_object_t *object, const char *param_a, const char *param_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
Creates and adds a synchronization parameter to a synchronization object.
#define AMXS_SYNC_PARAM_BATCH
Indicate that this parameter may be part of a batch copy operation.
Definition: amxs_types.h:210

◆ amxs_sync_object_add_new_object()

amxs_status_t amxs_sync_object_add_new_object ( amxs_sync_object_t parent,
const char *  object_a,
const char *  object_b,
int  attributes,
amxs_translation_cb_t  translation_cb,
amxs_action_cb_t  action_cb,
void *  priv 
)

Creates and adds a synchronization object to a synchronization object.

Allocates memory for a new synchronization object and initializes this object. Then adds it to the parent synchronization object.

Adding the synchronization object fails when:

  • The child object was already added to the parent object.
  • The child object attributes are conflicting with those of the parent object. E.g. The child object has the AMXS_SYNC_ONLY_B_TO_A attribute set, and the parent object has AMXS_SYNC_ONLY_A_TO_B set.

If the parent attributes are more strict than those of the child, the child attributes will be updated to match those of the parent.

Parameters
parentPointer to the parent synchronization object.
object_aName of the object in object A
object_bName of the object in object B
attributesBitwise OR of zero or more of the following attributes:
translation_cbCallback function to translate data coming from an object event. The output data of this function will be passed to the action callback function if this function executes succesfully. If this argument is NULL, the data from the event will be passed directly to the action callback function.
action_cbCallback function to act on an object event.
privPointer to user data which will be passed to the translation and action callbacks.
Returns
  • amxs_status_ok: the new child object is added to the parent object
  • amxs_status_duplicate: another child object with the same direction and object names already exists for the parent object
  • amxs_status_invalid_attr: the attributes of the child object are conflicting with those of the parent object
  • amxs_status_unknown_error: any other error

Definition at line 173 of file amxs_sync_object.c.

179  {
181  amxs_sync_object_t* child = NULL;
182 
183  status = amxs_sync_object_new(&child, object_a, object_b, attributes, translation_cb, action_cb, priv);
184  when_failed(status, exit);
185 
186  status = amxs_sync_object_add_object(parent, child);
187  if(status != amxs_status_ok) {
188  amxs_sync_object_delete(&child);
189  }
190 
191 exit:
192  return status;
193 }
@ amxs_status_ok
Definition: amxs_types.h:86
@ amxs_status_unknown_error
Definition: amxs_types.h:90
enum _amxs_status amxs_status_t
amxs_status_t amxs_sync_object_new(amxs_sync_object_t **object, const char *object_a, const char *object_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
Synchronization object constructor function.
void amxs_sync_object_delete(amxs_sync_object_t **object)
Synchronization object destructor function.
amxs_status_t amxs_sync_object_add_object(amxs_sync_object_t *parent, amxs_sync_object_t *child)
Adds a synchronization object to a synchronization object.
Definition: amxs_types.h:161

◆ amxs_sync_object_add_new_param()

amxs_status_t amxs_sync_object_add_new_param ( amxs_sync_object_t object,
const char *  param_a,
const char *  param_b,
int  attributes,
amxs_translation_cb_t  translation_cb,
amxs_action_cb_t  action_cb,
void *  priv 
)

Creates and adds a synchronization parameter to a synchronization object.

Allocates memory for a new synchronization parameter and initializes this parameter. Then adds it to the synchronization object.

Adding the synchronization parameter fails when:

  • The parameter was already added to the object.
  • The parameter attributes are conflicting with those of the object. E.g. The object has the AMXS_SYNC_ONLY_B_TO_A attribute set, and the parameter has AMXS_SYNC_ONLY_A_TO_B set.

If the object attributes are more strict than those of the parameter, the parameter attributes will be updated to match those of the object.

Parameters
objectPointer to a synchronization object.
param_aName of the parameter in object A
param_bName of the parameter in object B
attributesBitwise OR of zero or more of the following attributes:
translation_cbCallback function to translate data coming from a parameter changed event. The output data of this function will be passed to the action callback function if this function executes succesfully. If this argument is NULL, the data from the event will be passed directly to the action callback function.
action_cbCallback function to act on a parameter changed event.
privPointer to user data which will be passed to the translation and action callbacks.
Returns
  • amxs_status_ok: the synchronization parameter is added to the synchronization object
  • amxs_status_duplicate: another synchronization parameter with the same direction and parameter names already exists for this synchronization object
  • amxs_status_invalid_attr: the attributes of the synchronization parameter are conflicting with those of the synchronization object
  • amxs_status_unknown_error: any other error

Definition at line 125 of file amxs_sync_object.c.

131  {
133  amxs_sync_param_t* param = NULL;
134 
135  status = amxs_sync_param_new(&param, param_a, param_b, attributes, translation_cb, action_cb, priv);
136  when_failed(status, exit);
137 
138  status = amxs_sync_object_add_param(object, param);
139  if(status != amxs_status_ok) {
140  amxs_sync_param_delete(&param);
141  }
142 
143 exit:
144  return status;
145 }
amxs_status_t amxs_sync_object_add_param(amxs_sync_object_t *object, amxs_sync_param_t *param)
Adds a synchronization parameter to a synchronization object.
void amxs_sync_param_delete(amxs_sync_param_t **param)
Synchronization parameter destructor function.
amxs_status_t amxs_sync_param_new(amxs_sync_param_t **param, const char *param_a, const char *param_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv)
Synchronization parameter constructor function.

◆ amxs_sync_object_add_object()

amxs_status_t amxs_sync_object_add_object ( amxs_sync_object_t parent,
amxs_sync_object_t child 
)

Adds a synchronization object to a synchronization object.

The synchronization object can be be created using amxs_sync_object_new.

Adding the synchronization object fails when:

  • The child object was already added to the parent object.
  • The child object attributes are conflicting with those of the parent object. E.g. The child object has the AMXS_SYNC_ONLY_B_TO_A attribute set, and the parent object has AMXS_SYNC_ONLY_A_TO_B set.

If the parent attributes are more strict than those of the child, the child attributes will be updated to match those of the parent.

Parameters
parentPointer to the parent synchronization object.
childPointer to the child synchronization object.
Returns
  • amxs_status_ok: the child object is added to the parent object
  • amxs_status_duplicate: another child object with the same direction and object names already exists for the parent object
  • amxs_status_invalid_attr: the attributes of the child object are conflicting with those of the parent object
  • amxs_status_unknown_error: any other error

Definition at line 160 of file amxs_sync_object.c.

160  {
162  when_null(parent, exit);
163  when_null(child, exit);
164  when_false_status(parent->type == amxs_sync_type_object, exit, status = amxs_status_invalid_type);
165  when_false_status(child->type == amxs_sync_type_object, exit, status = amxs_status_invalid_type);
166 
167  status = amxs_sync_entry_add_entry(parent, child);
168 
169 exit:
170  return status;
171 }
amxs_status_t amxs_sync_entry_add_entry(amxs_sync_entry_t *parent, amxs_sync_entry_t *child)
@ amxs_status_invalid_type
Definition: amxs_types.h:92
@ amxs_sync_type_object
Definition: amxs_types.h:101
amxs_sync_entry_type_t type
Definition: amxs_types.h:170

◆ amxs_sync_object_add_param()

amxs_status_t amxs_sync_object_add_param ( amxs_sync_object_t object,
amxs_sync_param_t param 
)

Adds a synchronization parameter to a synchronization object.

The synchronization parameter can be be created using amxs_sync_param_new.

Adding the synchronization parameter fails when:

  • The parameter was already added to the object.
  • The parameter attributes are conflicting with those of the object. E.g. The object has the AMXS_SYNC_ONLY_B_TO_A attribute set, and the parameter has AMXS_SYNC_ONLY_A_TO_B set.

If the object attributes are more strict than those of the parameter, the parameter attributes will be updated to match those of the object.

Parameters
objectPointer to a synchronization object.
paramPointer to a synchronization parameter.
Returns
  • amxs_status_ok: the synchronization parameter is added to the synchronization object
  • amxs_status_duplicate: another synchronization parameter with the same direction and parameter names already exists for this synchronization object
  • amxs_status_invalid_attr: the attributes of the synchronization parameter are conflicting with those of the synchronization object
  • amxs_status_unknown_error: any other error

Definition at line 112 of file amxs_sync_object.c.

112  {
114  when_null(object, exit);
115  when_null(param, exit);
116  when_false_status(object->type == amxs_sync_type_object, exit, status = amxs_status_invalid_type);
117  when_false_status(param->type == amxs_sync_type_param, exit, status = amxs_status_invalid_type);
118 
119  status = amxs_sync_entry_add_entry(object, param);
120 
121 exit:
122  return status;
123 }
@ amxs_sync_type_param
Definition: amxs_types.h:102

◆ amxs_sync_object_delete()

void amxs_sync_object_delete ( amxs_sync_object_t **  object)

Synchronization object destructor function.

Frees all memory allocated for a synchronization object. Also removes the synchronization object from any synchronization object or context it was attached to. All attached synchronization objects and parameters will be freed as well.

Parameters
objectPointer to a synchronization object pointer.

Definition at line 101 of file amxs_sync_object.c.

101  {
102  when_null(object, exit);
103  when_null(*object, exit);
104  when_false((*object)->type == amxs_sync_type_object, exit);
105 
106  amxs_sync_entry_delete(object);
107 
108 exit:
109  return;
110 }
void amxs_sync_entry_delete(amxs_sync_entry_t **entry)

◆ amxs_sync_object_new()

amxs_status_t amxs_sync_object_new ( amxs_sync_object_t **  object,
const char *  object_a,
const char *  object_b,
int  attributes,
amxs_translation_cb_t  translation_cb,
amxs_action_cb_t  action_cb,
void *  priv 
)

Synchronization object constructor function.

Allocates memory for a new synchronization object and initializes this object.

Use amxs_sync_object_delete to remove the synchronization object and free all allocated memory.

Parameters
objectPointer to a synchronization object pointer. The address of the new allocated synchronization object is stored in this pointer.
object_aName of the object in object A
object_bName of the object in object B
attributesBitwise OR of zero or more of the following attributes:
translation_cbCallback function to translate data coming from an object event. The output data of this function will be passed to the action callback function if this function executes succesfully. If this argument is NULL, the data from the event will be passed directly to the action callback function.
action_cbCallback function to act on an object event.
privPointer to user data which will be passed to the translation and action callbacks.
Returns
amxs_status_ok when the synchronization object is created, or another status code when failed to create the synchronization object.

Definition at line 71 of file amxs_sync_object.c.

77  {
78  return amxs_sync_entry_new(object,
79  object_a,
80  object_b,
81  attributes,
82  translation_cb,
83  action_cb,
85  priv);
86 }
amxs_status_t amxs_sync_entry_new(amxs_sync_entry_t **entry, const char *a, const char *b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, amxs_sync_entry_type_t type, void *priv)

◆ amxs_sync_object_new_copy()

amxs_status_t amxs_sync_object_new_copy ( amxs_sync_object_t **  object,
const char *  object_a,
const char *  object_b,
int  attributes 
)

Synchronization object constructor function.

Allocates memory for a new synchronization object and initializes this object.

Use amxs_sync_object_delete to remove the synchronization object and free all allocated memory.

Uses default translation amxs_sync_object_copy_trans_cb and action amxs_sync_object_copy_action_cb callbacks.

Parameters
objectPointer to a synchronization object pointer. The address of the new allocated synchronization object is stored in this pointer.
object_aName of the object in object A
object_bName of the object in object B
attributesBitwise OR of zero or more of the following attributes:
Returns
amxs_status_ok when the synchronization object is created, or another status code when failed to create the synchronization object.

Definition at line 88 of file amxs_sync_object.c.

91  {
92  return amxs_sync_object_new(object,
93  object_a,
94  object_b,
95  attributes,
98  NULL);
99 }