libamxb  4.8.2
Bus Agnostic C API
Data Model Registration

Functions

int amxb_register (amxb_bus_ctx_t *const ctx, amxd_dm_t *const dm)
 Registers a data model to a certain bus context (connection). More...
 

Detailed Description

Function Documentation

◆ amxb_register()

int amxb_register ( amxb_bus_ctx_t *const  ctx,
amxd_dm_t *const  dm 
)

Registers a data model to a certain bus context (connection).

When a data model has been created it can be registered to one or more software busses. After registering a data model it can be accessed by other processes through that software bus system.

The bus specific back-end implementation will also take care that when objects are added or deleted, the bus system (broker/dispatcher) is updated if needed.

To unregister the data model, it is sufficient to close the connection to the bus system.

Parameters
ctxThe bus context (or connection)
dmthe data model pointer
Returns
AMXB_STATUS_OK remote function has completed successful

Definition at line 75 of file amxb_ba_register.c.

76  {
77  int retval = -1;
78  const amxb_be_funcs_t* fns = NULL;
79 
80  when_null(ctx, exit);
81  when_null(ctx->bus_ctx, exit);
82  when_not_null(ctx->dm, exit);
83  when_null(dm, exit);
84 
85  fns = ctx->bus_fn;
86  if(amxb_is_valid_be_func(fns, register_dm, fns->register_dm)) {
87  retval = fns->register_dm(ctx->bus_ctx, dm);
88  } else {
90  }
91 
92  if(retval == 0) {
93  ctx->dm = dm;
94  }
95 
96 exit:
97  return retval;
98 }
#define amxb_is_valid_be_func(ft, member, ptr)
Definition: amxb_priv.h:78
#define AMXB_ERROR_NOT_SUPPORTED_OP
Function/operation not supported.
Definition: amxb_error.h:110
The back-end interface structure.
amxb_be_register_fn_t register_dm
const amxb_be_funcs_t * bus_fn
Definition: amxb_types.h:121
amxd_dm_t * dm
Definition: amxb_types.h:123
void * bus_ctx
Definition: amxb_types.h:122
static amxd_dm_t dm
Definition: test_amxb_e2e.c:85