v_service v_serviceNew( v_kernel kernel, const c_char *name, const c_char *extStateName, v_serviceType serviceType, v_participantQos qos, c_bool enable) { v_service s = NULL; v_participantQos q; assert(C_TYPECHECK(kernel, v_kernel)); /* Do not C_TYPECHECK qos parameter, since it might be allocated on heap! */ assert(name != NULL); if (v_participantQosCheck(qos) == V_RESULT_OK) { q = v_participantQosNew(kernel, (v_participantQos)qos); if (q == NULL) { OS_REPORT(OS_ERROR, "v_serviceNew", V_RESULT_INTERNAL_ERROR, "Creation of service <%s> failed. Cannot create participant QoS.", name); } else { s = v_service(v_objectNew(kernel, K_SERVICE)); v_serviceInit(s, name, extStateName, serviceType, q, enable); c_free(q); if (s->state == NULL) { v_serviceFree(s); s = NULL; } } } return s; }
v_cmsoap v_cmsoapNew( v_serviceManager manager, const c_char *name, const c_char *extStateName, v_participantQos qos) { v_kernel k; v_cmsoap s; v_participantQos q; assert(C_TYPECHECK(manager, v_serviceManager)); assert(name != NULL); k = v_objectKernel(manager); q = v_participantQosNew(k, qos); if (q == NULL) { OS_REPORT(OS_ERROR, "v_cmsoapNew", 0, "CMSoap service not created: inconsistent qos"); s = NULL; } else { s = v_cmsoap(v_objectNew(k, K_CMSOAP)); v_serviceInit(v_service(s), manager, name, extStateName, q, v_statistics(v_cmsoapStatisticsNew(k))); c_free(q); /* always add, even when s->state==NULL, since v_participantFree always removes the participant.*/ v_addParticipant(k, v_participant(s)); if (v_service(s)->state == NULL) { v_serviceFree(v_service(s)); s = NULL; } } return s; }
v_networking v_networkingNew( v_serviceManager manager, const c_char *name, const c_char *extStateName, v_participantQos qos) { v_kernel k; v_networking s; v_participantQos q; v_networkingStatistics ns; assert(C_TYPECHECK(manager, v_serviceManager)); assert(name != NULL); k = v_objectKernel(manager); q = v_participantQosNew(k, qos); if (q == NULL) { OS_REPORT(OS_ERROR, "v_networkingNew", 0, "Networking service not created: inconsistent qos"); s = NULL; } else { s = v_networking(v_objectNew(k, K_NETWORKING)); if (v_isEnabledStatistics(k, V_STATCAT_NETWORKING)) { ns = v_networkingStatistics(v_networkingStatisticsNew(k)); } else { ns = NULL; } v_serviceInit(v_service(s), manager, name, extStateName, q, v_statistics(ns)); c_free(q); /* always add, even when s->state==NULL, * since v_participantFree always removes the participant. */ v_addParticipant(k, v_participant(s)); if (v_service(s)->state == NULL) { v_serviceFree(v_service(s)); s = NULL; } } return s; }
v_durability v_durabilityNew( v_serviceManager manager, const c_char *name, const c_char *extStateName, v_participantQos qos) { v_kernel k; v_durability s; v_participantQos q; v_durabilityStatistics dStat; assert(C_TYPECHECK(manager, v_serviceManager)); assert(name != NULL); k = v_objectKernel(manager); q = v_participantQosNew(k, qos); if (q == NULL) { OS_REPORT(OS_ERROR, "v_durabilityNew", 0, "Durability service not created: inconsistent qos"); s = NULL; } else { s = v_durability(v_objectNew(k, K_DURABILITY)); if (v_isEnabledStatistics(k, V_STATCAT_DURABILITY)) { dStat = v_durabilityStatisticsNew(k); } else { dStat = NULL; } v_serviceInit(v_service(s), manager, name, extStateName, q, v_statistics(dStat)); c_free(q); /* always add, even when s->state==NULL, since v_participantFree always removes the participant.*/ v_addParticipant(k, v_participant(s)); if (v_service(s)->state == NULL) { v_serviceFree(v_service(s)); s = NULL; } } return s; }
/************************************************************** * constructor/destructor **************************************************************/ v_service v_serviceNew( v_serviceManager manager, const c_char *name, const c_char *extStateName, v_participantQos qos, v_statistics stats) { v_kernel k; v_service s; v_participantQos q; assert(C_TYPECHECK(manager, v_serviceManager)); /* Do not C_TYPECHECK qos parameter, since it might be allocated on heap! */ assert(name != NULL); k = v_objectKernel(manager); /* do no use cast method on qos parameter, * it is most likely allocated on heap! */ q = v_participantQosNew(k, (v_participantQos)qos); if (q == NULL) { OS_REPORT(OS_ERROR, "v_serviceNew", 0, "Service not created: inconsistent qos"); s = NULL; } else { s = v_service(v_objectNew(k, K_SERVICE)); v_serviceInit(s, manager, name, extStateName, q, stats); c_free(q); /* always add, even when s->state==NULL, since v_participantFree always removes the participant.*/ v_addParticipant(k, v_participant(s)); if (s->state == NULL) { v_serviceFree(s); s = NULL; } } return s; }
v_rnr v_rnrNew( v_kernel kernel, const c_char *name, const c_char *extStateName, v_participantQos qos, c_bool enable) { v_rnr _this; v_participantQos q; assert(C_TYPECHECK(kernel, v_kernel)); assert(name != NULL); q = v_participantQosNew(kernel, qos); if (q == NULL) { OS_REPORT(OS_ERROR, "v_rnrNew", V_RESULT_ILL_PARAM, "Record and Replay service not created: inconsistent qos"); _this = NULL; } else { _this = v_rnr(v_objectNew(kernel, K_RNR)); _this->statistics = v_rnrStatisticsNew (kernel, name); v_serviceInit(v_service(_this), name, extStateName, V_SERVICETYPE_RECORD_REPLAY, q, enable); c_free(q); /* always add, even when s->state==NULL, since v_participantFree always * removes the participant. */ v_addParticipant(kernel, v_participant(_this)); if (v_service(_this)->state == NULL) { v_serviceFree(v_service(_this)); _this = NULL; } else { OSPL_ADD_OBSERVER(kernel, _this, V_EVENT_NEW_GROUP, NULL); } } return _this; }