osaf/services/saf/amf/amfd/comp.cc | 2 +- osaf/services/saf/amf/amfd/csi.cc | 2 +- osaf/services/saf/amf/amfd/cstype.cc | 31 +++++++++++++++++-------------- osaf/services/saf/amf/amfd/include/csi.h | 26 ++++++++++++++++++-------- 4 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/osaf/services/saf/amf/amfd/comp.cc b/osaf/services/saf/amf/amfd/comp.cc --- a/osaf/services/saf/amf/amfd/comp.cc +++ b/osaf/services/saf/amf/amfd/comp.cc @@ -898,7 +898,7 @@ static SaAisErrorT ccb_completed_modify_ if (compcstype->comp == comp) { SaNameT cstype_name; AVD_CTCS_TYPE *ctcstype = NULL; - avd_cstype_t *cst = NULL; + AVD_CS_TYPE *cst = NULL; get_child_dn_from_ass_dn(&compcstype->name, &cstype_name); //First check if this cstype exists in the sustem. if ((cst = cstype_db->find(Amf::to_string(&cstype_name))) == NULL) { diff --git a/osaf/services/saf/amf/amfd/csi.cc b/osaf/services/saf/amf/amfd/csi.cc --- a/osaf/services/saf/amf/amfd/csi.cc +++ b/osaf/services/saf/amf/amfd/csi.cc @@ -862,7 +862,7 @@ static void csi_ccb_apply_modify_hdlr(st while ((attr_mod = opdata->param.modify.attrMods[i++]) != NULL) { if (!strcmp(attr_mod->modAttr.attrName, "saAmfCSType")) { - struct avd_cstype *csi_type; + AVD_CS_TYPE *csi_type; SaNameT cstype_name = *(SaNameT*) attr_mod->modAttr.attrValues[0]; TRACE("saAmfCSType modified from '%s' to '%s' for Csi'%s'", csi->saAmfCSType.value, cstype_name.value, csi->name.value); diff --git a/osaf/services/saf/amf/amfd/cstype.cc b/osaf/services/saf/amf/amfd/cstype.cc --- a/osaf/services/saf/amf/amfd/cstype.cc +++ b/osaf/services/saf/amf/amfd/cstype.cc @@ -22,7 +22,7 @@ #include <csi.h> #include <imm.h> -AmfDb<std::string, avd_cstype_t> *cstype_db = NULL; +AmfDb<std::string, AVD_CS_TYPE> *cstype_db = NULL; // // TODO(HANO) Temporary use this function instead of strdup which uses malloc. @@ -35,23 +35,26 @@ static char *StrDup(const char *s) return c; } -static void cstype_add_to_model(avd_cstype_t *cst) +static void cstype_add_to_model(AVD_CS_TYPE *cst) { uint32_t rc = cstype_db->insert(Amf::to_string(&cst->name),cst); osafassert(rc == NCSCC_RC_SUCCESS); } -static avd_cstype_t *cstype_create(const SaNameT *dn, const SaImmAttrValuesT_2 **attributes) +// +AVD_CS_TYPE::AVD_CS_TYPE(const SaNameT *dn) { + memcpy(&name.value, dn->value, dn->length); + name.length = dn->length; +} + +static AVD_CS_TYPE *cstype_create(const SaNameT *dn, const SaImmAttrValuesT_2 **attributes) { - avd_cstype_t *cst; + AVD_CS_TYPE *cst; SaUint32T values_number; TRACE_ENTER2("'%s'", dn->value); - cst = new avd_cstype_t(); - - memcpy(cst->name.value, dn->value, dn->length); - cst->name.length = dn->length; + cst = new AVD_CS_TYPE(dn); if ((immutil_getAttrValuesNumber(const_cast<SaImmAttrNameT>("saAmfCSAttrName"), attributes, &values_number) == SA_AIS_OK) && (values_number > 0)) { @@ -70,7 +73,7 @@ static avd_cstype_t *cstype_create(const * Delete from DB and return memory * @param cst */ -static void cstype_delete(avd_cstype_t *cst) +static void cstype_delete(AVD_CS_TYPE *cst) { char *p; int i = 0; @@ -153,7 +156,7 @@ SaAisErrorT avd_cstype_config_get(void) SaNameT dn; const SaImmAttrValuesT_2 **attributes; const char *className = "SaAmfCSType"; - avd_cstype_t *cst; + AVD_CS_TYPE *cst; TRACE_ENTER(); @@ -197,7 +200,7 @@ done1: static SaAisErrorT cstype_ccb_completed_hdlr(CcbUtilOperationData_t *opdata) { SaAisErrorT rc = SA_AIS_ERR_BAD_OPERATION; - avd_cstype_t *cst; + AVD_CS_TYPE *cst; AVD_CSI *csi; bool csi_exist = false; CcbUtilOperationData_t *t_opData; @@ -246,7 +249,7 @@ done: static void cstype_ccb_apply_cb(CcbUtilOperationData_t *opdata) { - avd_cstype_t *cst; + AVD_CS_TYPE *cst; TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, opdata->objectName.value); @@ -257,7 +260,7 @@ static void cstype_ccb_apply_cb(CcbUtilO cstype_add_to_model(cst); break; case CCBUTIL_DELETE: - cstype_delete(static_cast<avd_cstype_t*>(opdata->userData)); + cstype_delete(static_cast<AVD_CS_TYPE*>(opdata->userData)); break; default: osafassert(0); @@ -267,7 +270,7 @@ static void cstype_ccb_apply_cb(CcbUtilO void avd_cstype_constructor(void) { - cstype_db= new AmfDb<std::string, avd_cstype_t>; + cstype_db= new AmfDb<std::string, AVD_CS_TYPE>; avd_class_impl_set("SaAmfCSType", NULL, NULL, cstype_ccb_completed_hdlr, cstype_ccb_apply_cb); diff --git a/osaf/services/saf/amf/amfd/include/csi.h b/osaf/services/saf/amf/amfd/include/csi.h --- a/osaf/services/saf/amf/amfd/include/csi.h +++ b/osaf/services/saf/amf/amfd/include/csi.h @@ -49,6 +49,8 @@ typedef struct avd_csi_deps_tag { struct avd_csi_deps_tag *csi_dep_next; /* the next CSI dependency in the list */ } AVD_CSI_DEPS; +class AVD_CS_TYPE; + /* Availability directors Component service in.stance structure(AVD_CSI): * This data structure lives in the AvD and reflects data points * associated with the CSI on the AvD. @@ -77,19 +79,27 @@ typedef struct avd_csi_tag { * wrt to this CSI. */ uint32_t compcsi_cnt; /* no of comp-csi rels */ struct avd_csi_tag *csi_list_cs_type_next; - struct avd_cstype *cstype; + AVD_CS_TYPE *cstype; bool assign_flag; /* Flag used while assigning. to mark this csi has been assigned a Comp from * current SI being assigned */ } AVD_CSI; extern AmfDb<std::string, AVD_CSI> *csi_db; -typedef struct avd_cstype { - SaNameT name; /* name of the CSType */ - SaStringT *saAmfCSAttrName; - AVD_CSI *list_of_csi; -} avd_cstype_t; +class AVD_CS_TYPE { + public: + explicit AVD_CS_TYPE(const SaNameT *dn); + SaNameT name {}; /* name of the CSType */ + SaStringT *saAmfCSAttrName {}; + AVD_CSI *list_of_csi {}; -extern AmfDb<std::string, avd_cstype_t> *cstype_db; + private: + AVD_CS_TYPE(); + // disallow copy and assign + AVD_CS_TYPE(const AVD_CS_TYPE&); + void operator=(const AVD_CS_TYPE&); +}; + +extern AmfDb<std::string, AVD_CS_TYPE> *cstype_db; /* This data structure lives in the AvD and reflects relationship * between the component and CSI on the AvD. @@ -149,7 +159,7 @@ extern void avd_csi_add_csiattr(AVD_CSI extern void avd_csi_remove_csiattr(AVD_CSI *csi, AVD_CSI_ATTR *attr); extern void avd_csi_constructor(void); -extern avd_cstype_t *avd_cstype_get(const SaNameT *dn); +extern AVD_CS_TYPE *avd_cstype_get(const SaNameT *dn); extern void avd_cstype_add_csi(AVD_CSI *csi); extern void avd_cstype_remove_csi(AVD_CSI *csi); extern void avd_cstype_constructor(void); ------------------------------------------------------------------------------ _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel