osaf/services/saf/amf/amfd/comp.cc        |   45 +++++++---
 osaf/services/saf/amf/amfd/include/comp.h |  126 ++++++++++++++++-------------
 osaf/services/saf/amf/amfd/include/msg.h  |    4 +-
 osaf/services/saf/amf/amfd/include/su.h   |    6 +-
 osaf/services/saf/amf/amfd/include/util.h |    6 +-
 5 files changed, 106 insertions(+), 81 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
@@ -52,25 +52,41 @@ void avd_comp_db_add(AVD_COMP *comp)
        }
 }
 
+//
+void AVD_COMP::initialize() {
+  comp_info = {};
+  comp_info.cap = SA_AMF_COMP_ONE_ACTIVE_OR_ONE_STANDBY;
+  comp_info.category = AVSV_COMP_TYPE_NON_SAF;
+  comp_info.def_recvr = SA_AMF_COMPONENT_RESTART;
+  comp_info.inst_level = 1;
+  comp_info.comp_restart = true;
+  nodefail_cleanfail = false;
+  saAmfCompOperState = SA_AMF_OPERATIONAL_DISABLED;
+  saAmfCompReadinessState = SA_AMF_READINESS_OUT_OF_SERVICE;
+  saAmfCompPresenceState = SA_AMF_PRESENCE_UNINSTANTIATED;
+}
+
+//
+AVD_COMP::AVD_COMP() {
+  initialize();
+}
+
+//
+AVD_COMP::AVD_COMP(const SaNameT *dn) {
+  initialize();
+
+  memcpy(&comp_info.name.value, dn->value, dn->length);
+  comp_info.name.length = dn->length;
+}
+
+//
 AVD_COMP *avd_comp_new(const SaNameT *dn)
 {
        AVD_COMP *comp;
 
-       comp = new AVD_COMP();
-       
-       memcpy(comp->comp_info.name.value, dn->value, dn->length);
-       comp->comp_info.name.length = dn->length;
-       comp->comp_info.cap = SA_AMF_COMP_ONE_ACTIVE_OR_ONE_STANDBY;
-       comp->comp_info.category = AVSV_COMP_TYPE_NON_SAF;
-       comp->comp_info.def_recvr = SA_AMF_COMPONENT_RESTART;
-       comp->comp_info.inst_level = 1;
-       comp->comp_info.comp_restart = true;
-       comp->nodefail_cleanfail = false;
-       comp->saAmfCompOperState = SA_AMF_OPERATIONAL_DISABLED;
-       comp->saAmfCompReadinessState = SA_AMF_READINESS_OUT_OF_SERVICE;
-       comp->saAmfCompPresenceState = SA_AMF_PRESENCE_UNINSTANTIATED;
+       comp = new AVD_COMP(dn);
 
-       return comp;
+        return comp;
 }
 
 /**
@@ -206,7 +222,6 @@ static void comp_add_to_model(AVD_COMP *
 
        avsv_sanamet_init(&comp->comp_info.name, &dn, "safSu");
        su = comp->su = su_db->find(Amf::to_string(&dn));
-
        avd_comp_db_add(comp);
        comp->comp_type = 
comptype_db->find(Amf::to_string(&comp->saAmfCompType));
        osafassert(comp->comp_type);
diff --git a/osaf/services/saf/amf/amfd/include/comp.h 
b/osaf/services/saf/amf/amfd/include/comp.h
--- a/osaf/services/saf/amf/amfd/include/comp.h
+++ b/osaf/services/saf/amf/amfd/include/comp.h
@@ -54,73 +54,83 @@ typedef struct {
 } AVD_COMP_GLOBALATTR;
 
 /* AMF Class SaAmfCompType */
-typedef struct avd_comp_tag {
+class AVD_COMP {
+ public:
+  AVD_COMP();
+  explicit AVD_COMP(const SaNameT* dn );
+  
+  SaNameT saAmfCompType;
 
-       SaNameT saAmfCompType;
+  /* Detailed as in data structure definition */
+  AVSV_COMP_INFO comp_info;    /* component name field with 
+                                 * the length field in the 
+                                 * network order is used as the
+                                 * index. */
+  SaTimeT inst_retry_delay;    /* Delay interval after which
+                                 * the component is reinstantiated.
+                                 * Checkpointing - Sent as a one time update.
+                                 */
 
-       /* Detailed as in data structure definition */
-       AVSV_COMP_INFO comp_info;       /* component name field with 
-                                        * the length field in the 
-                                        * network order is used as the
-                                        * index. */
-       SaTimeT inst_retry_delay;       /* Delay interval after which
-                                        * the component is reinstantiated.
-                                        * Checkpointing - Sent as a one time 
update.
-                                        */
+  bool nodefail_cleanfail;     /* If flag set to true node will
+                                 * be considered failed when the
+                                 * cleanup script fails.
+                                 * Checkpointing - Sent as a one time update.
+                                 */
 
-       bool nodefail_cleanfail;        /* If flag set to true node will
-                                        * be considered failed when the
-                                        * cleanup script fails.
-                                        * Checkpointing - Sent as a one time 
update.
-                                        */
+  uint32_t max_num_inst_delay; /* the maximum number of times
+                                 * AMF tries to instantiate
+                                 * the component with delay.
+                                 * Checkpointing - Sent as a one time update.
+                                 */
 
-       uint32_t max_num_inst_delay;    /* the maximum number of times
-                                        * AMF tries to instantiate
-                                        * the component with delay.
-                                        * Checkpointing - Sent as a one time 
update.
-                                        */
+  SaUint32T max_num_csi_actv;  /* number of CSI relationships that can be
+                                 * assigned active to this component 
+                                 * Checkpointing - Sent as a one time update.
+                                 */
 
-       SaUint32T max_num_csi_actv;     /* number of CSI relationships that can 
be
-                                        * assigned active to this component 
-                                        * Checkpointing - Sent as a one time 
update.
-                                        */
+  SaUint32T max_num_csi_stdby; /* number of CSI relationships that can be
+                                 * assigned standby to this component 
+                                 * Checkpointing - Sent as a one time update.
+                                 */
 
-       SaUint32T max_num_csi_stdby;    /* number of CSI relationships that can 
be
-                                        * assigned standby to this component 
-                                        * Checkpointing - Sent as a one time 
update.
-                                        */
+  SaUint32T curr_num_csi_actv; /* the number of CSI relationships that have
+                                 * been assigned active to this component
+                                 * Checkpointing - Sent update independently.
+                                 */
 
-       SaUint32T curr_num_csi_actv;    /* the number of CSI relationships that 
have
-                                        * been assigned active to this 
component
-                                        * Checkpointing - Sent update 
independently.
-                                        */
+  SaUint32T curr_num_csi_stdby;        /* the number of CSI relationships that 
have
+                                 * been assigned standby to this component
+                                 * Checkpointing - Sent update independently.
+                                 */
+  SaNameT comp_proxy_csi;
+  SaNameT comp_container_csi;
 
-       SaUint32T curr_num_csi_stdby;   /* the number of CSI relationships that 
have
-                                        * been assigned standby to this 
component
-                                        * Checkpointing - Sent update 
independently.
-                                        */
-       SaNameT comp_proxy_csi;
-       SaNameT comp_container_csi;
+  /* runtime attributes */
+  SaAmfOperationalStateT saAmfCompOperState;   
+  SaAmfReadinessStateT   saAmfCompReadinessState;
+  SaAmfPresenceStateT    saAmfCompPresenceState;
+  SaUint32T              saAmfCompRestartCount;
+  SaNameT                saAmfCompCurrProxyName;
+  SaNameT              **saAmfCompCurrProxiedNames;
 
-       /* runtime attributes */
-       SaAmfOperationalStateT saAmfCompOperState;      
-       SaAmfReadinessStateT   saAmfCompReadinessState;
-       SaAmfPresenceStateT    saAmfCompPresenceState;
-       SaUint32T              saAmfCompRestartCount;
-       SaNameT                saAmfCompCurrProxyName;
-       SaNameT              **saAmfCompCurrProxiedNames;
+  bool assign_flag;    /* Flag used while assigning. to mark this
+                         * comp has been assigned a CSI from
+                         * current SI being assigned
+                         */
+  struct avd_amf_comp_type_tag *comp_type;
+  AVD_COMP *comp_type_list_comp_next;
+  AVD_SU *su;          /* SU to which this component belongs */
+  AVD_COMP *su_comp_next;      /* the next component in list of  components
+                                 * in this SU */
+  AVD_ADMIN_OPER_CBK admin_pend_cbk;  /* holds callback invocation for admin 
operation */
 
-       bool assign_flag;       /* Flag used while assigning. to mark this
-                                * comp has been assigned a CSI from
-                                * current SI being assigned
-                                */
-       struct avd_amf_comp_type_tag *comp_type;
-       struct avd_comp_tag *comp_type_list_comp_next;
-       AVD_SU *su;             /* SU to which this component belongs */
-       struct avd_comp_tag *su_comp_next;      /* the next component in list 
of  components
-                                                * in this SU */
-       AVD_ADMIN_OPER_CBK admin_pend_cbk;  /* holds callback invocation for 
admin operation */
-} AVD_COMP;
+ private:
+  void initialize();
+  // disallow copy and assign
+  AVD_COMP(const AVD_COMP&);
+  void operator=(const AVD_COMP&);
+
+};
 
 extern AmfDb<std::string, AVD_COMP> *comp_db;
 
@@ -148,7 +158,7 @@ typedef struct avd_amf_comp_type_tag {
        SaAmfRecommendedRecoveryT saAmfCtDefRecoveryOnError;
        SaBoolT saAmfCtDefDisableRestart;
 
-       struct avd_comp_tag *list_of_comp;
+       AVD_COMP *list_of_comp;
 
 } AVD_COMP_TYPE;
 extern  AmfDb<std::string, AVD_COMP_TYPE> *comptype_db;
diff --git a/osaf/services/saf/amf/amfd/include/msg.h 
b/osaf/services/saf/amf/amfd/include/msg.h
--- a/osaf/services/saf/amf/amfd/include/msg.h
+++ b/osaf/services/saf/amf/amfd/include/msg.h
@@ -72,7 +72,7 @@ struct cl_cb_tag;
 struct avd_avnd_tag;
 class AVD_SU;
 struct avd_su_si_rel_tag;
-struct avd_comp_tag;
+class AVD_COMP;
 struct avd_comp_csi_rel_tag;
 struct avd_csi_tag;
 
@@ -105,7 +105,7 @@ uint32_t avd_snd_pg_upd_msg(struct cl_cb
                                  SaAmfProtectionGroupChangesT, SaNameT *);
 uint32_t avd_snd_hb_msg(struct cl_cb_tag *);
 uint32_t avd_snd_comp_validation_resp(struct cl_cb_tag *cb, struct 
avd_avnd_tag *avnd,
-                                           struct avd_comp_tag *comp_ptr, 
AVD_DND_MSG *n2d_msg);
+                                           AVD_COMP *comp_ptr, AVD_DND_MSG 
*n2d_msg);
 void avsv_d2d_msg_free(AVD_D2D_MSG *);
 void avd_mds_d_enc(MDS_CALLBACK_ENC_INFO *);
 void avd_mds_d_dec(MDS_CALLBACK_DEC_INFO *);
diff --git a/osaf/services/saf/amf/amfd/include/su.h 
b/osaf/services/saf/amf/amfd/include/su.h
--- a/osaf/services/saf/amf/amfd/include/su.h
+++ b/osaf/services/saf/amf/amfd/include/su.h
@@ -90,7 +90,7 @@ class AVD_SU {
        struct avd_su_si_rel_tag *list_of_susi; /* the list of su si 
relationship elements */
 
        // TODO: use some container for the comp list
-       struct avd_comp_tag *list_of_comp;      /* the list of  components in 
this SU */
+       AVD_COMP *list_of_comp; /* the list of  components in this SU */
 
        AVD_SU *sg_list_su_next;        /* the next SU in the SG */
        AVD_SU *avnd_list_su_next;      /* the next SU in the AvND */
@@ -103,8 +103,8 @@ class AVD_SU {
        void inc_curr_act_si();
        void dec_curr_act_si();
        int hastate_assignments_count(SaAmfHAStateT ha_state);
-       void add_comp(struct avd_comp_tag *comp);
-       void remove_comp(struct avd_comp_tag *comp);
+       void add_comp(AVD_COMP *comp);
+       void remove_comp(AVD_COMP *comp);
        void set_admin_state(SaAmfAdminStateT admin_state);
        void set_pres_state(SaAmfPresenceStateT state);
        void set_readiness_state(SaAmfReadinessStateT readiness_state);
diff --git a/osaf/services/saf/amf/amfd/include/util.h 
b/osaf/services/saf/amf/amfd/include/util.h
--- a/osaf/services/saf/amf/amfd/include/util.h
+++ b/osaf/services/saf/amf/amfd/include/util.h
@@ -92,7 +92,7 @@ struct cl_cb_tag;
 struct avd_avnd_tag;
 struct avd_hlt_tag;
 struct avd_su_si_rel_tag;
-struct avd_comp_tag;
+class AVD_COMP;
 struct avd_comp_csi_rel_tag;
 struct avd_csi_tag;
 
@@ -116,7 +116,7 @@ uint32_t avd_snd_oper_state_msg(struct c
 uint32_t avd_snd_op_req_msg(struct cl_cb_tag *cb, struct avd_avnd_tag *avnd, 
AVSV_PARAM_INFO *param_info);
 uint32_t avd_snd_su_reg_msg(struct cl_cb_tag *cb, struct avd_avnd_tag *avnd, 
bool fail_over);
 uint32_t avd_snd_su_msg(struct cl_cb_tag *cb, AVD_SU *su);
-uint32_t avd_snd_comp_msg(struct cl_cb_tag *cb, struct avd_comp_tag *comp);
+uint32_t avd_snd_comp_msg(struct cl_cb_tag *cb, AVD_COMP *comp);
 uint32_t avd_snd_susi_msg(struct cl_cb_tag *cb, AVD_SU *su, struct 
avd_su_si_rel_tag *susi,
                                AVSV_SUSI_ACT actn, bool single_csi, struct 
avd_comp_csi_rel_tag*);
 uint32_t avd_snd_set_leds_msg(struct cl_cb_tag *cb, struct avd_avnd_tag *avnd);
@@ -127,7 +127,7 @@ uint32_t avd_snd_pg_upd_msg(struct cl_cb
                                  SaAmfProtectionGroupChangesT, SaNameT *);
 uint32_t avd_snd_hb_msg(struct cl_cb_tag *);
 uint32_t avd_snd_comp_validation_resp(struct cl_cb_tag *cb, struct 
avd_avnd_tag *avnd,
-                                           struct avd_comp_tag *comp_ptr, 
AVD_DND_MSG *n2d_msg);
+                                           AVD_COMP *comp_ptr, AVD_DND_MSG 
*n2d_msg);
 void avsv_d2d_msg_free(AVD_D2D_MSG *);
 uint32_t avd_d2d_msg_snd(struct cl_cb_tag *, AVD_D2D_MSG *);
 

------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to