This source file includes following definitions.
- opal_dss_register
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include "opal_config.h"
21
22 #include "opal/dss/dss_internal.h"
23
24 int opal_dss_register(opal_dss_pack_fn_t pack_fn,
25 opal_dss_unpack_fn_t unpack_fn,
26 opal_dss_copy_fn_t copy_fn,
27 opal_dss_compare_fn_t compare_fn,
28 opal_dss_print_fn_t print_fn,
29 bool structured,
30 const char *name, opal_data_type_t *type)
31 {
32 opal_dss_type_info_t *info, *ptr;
33 int32_t i;
34
35
36
37 if (NULL == pack_fn || NULL == unpack_fn || NULL == copy_fn || NULL == compare_fn ||
38 NULL == print_fn || NULL == name || NULL == type) {
39 return OPAL_ERR_BAD_PARAM;
40 }
41
42
43 for (i=0; i < opal_pointer_array_get_size(&opal_dss_types); i++) {
44 ptr = opal_pointer_array_get_item(&opal_dss_types, i);
45 if (NULL != ptr) {
46
47 if (0 == strcmp(ptr->odti_name, name)) {
48 return OPAL_ERR_DATA_TYPE_REDEF;
49 }
50
51 if (*type > 0 && ptr->odti_type == *type) {
52 return OPAL_ERR_DATA_TYPE_REDEF;
53 }
54 }
55 }
56
57
58
59
60 if (0 >= *type) {
61 return OPAL_ERR_BAD_PARAM;
62 }
63
64
65 info = (opal_dss_type_info_t*) OBJ_NEW(opal_dss_type_info_t);
66 if (NULL == info) {
67 return OPAL_ERR_OUT_OF_RESOURCE;
68 }
69 info->odti_type = *type;
70 info->odti_name = strdup(name);
71 info->odti_pack_fn = pack_fn;
72 info->odti_unpack_fn = unpack_fn;
73 info->odti_copy_fn = copy_fn;
74 info->odti_compare_fn = compare_fn;
75 info->odti_print_fn = print_fn;
76 info->odti_structured = structured;
77
78 return opal_pointer_array_set_item(&opal_dss_types, *type, info);
79 }