v_listener v_listenerNew( v_participant p, c_bool combine) { v_listener _this; v_kernel kernel; assert(C_TYPECHECK(p,v_participant)); kernel = v_objectKernel(p); _this = v_listener(v_objectNew(kernel,K_LISTENER)); if (_this != NULL) { v_publicInit(v_public(_this)); (void)c_mutexInit(c_getBase(_this), &_this->mutex); c_condInit(c_getBase(_this), &_this->cv, &_this->mutex); _this->participant = p; _this->eventList = NULL; _this->lastEvent = NULL; v_participantAdd(p, v_object(_this)); _this->terminate = FALSE; _this->waitCount = 0; _this->combine = combine; } return _this; }
void v_topicAdapterInit( v_topicAdapter adapter, v_topic topic, v_participant p, const c_char *name) { v_eventMask mask = V_EVENT_ALL_DATA_DISPOSED | V_EVENT_INCONSISTENT_TOPIC; assert(adapter != NULL); assert(p != NULL); assert(C_TYPECHECK(adapter, v_topicAdapter)); assert(C_TYPECHECK(p,v_participant)); assert(C_TYPECHECK(topic,v_topic)); v_entityInit(v_entity(adapter), name); adapter->topic = c_keep(topic); (void)v_entityEnable(v_entity(adapter)); (void)v_observerSetEvent(v_observer(adapter), mask); OSPL_ADD_OBSERVER(topic, adapter, mask, NULL); v_participantAdd(p, v_object(adapter)); v_topic(adapter)->owner = p; }
v_waitset v_waitsetNew( v_participant p) { v_waitset _this; v_kernel kernel; c_type proxyType; assert(C_TYPECHECK(p,v_participant)); kernel = v_objectKernel(p); _this = v_waitset(v_objectNew(kernel,K_WAITSET)); if (_this != NULL) { v_observerInit(v_observer(_this),"Waitset", NULL, TRUE); _this->participant = p; _this->eventCache = NULL; proxyType = v_kernelType(kernel,K_PROXY); _this->observables = c_setNew(proxyType); v_observerSetEventData(v_observer(_this), NULL); v_participantAdd(p, v_entity(_this)); } return _this; }
v_subscriber v_subscriberNew( v_participant p, const c_char *name, v_subscriberQos qos, c_bool enable) { v_kernel kernel; v_subscriber s; v_subscriberQos q; v_entity found; v_accessMode access; kernel = v_objectKernel(p); /* ES, dds1576: If a partition policy was provided then we need to verify * if the partition policy does not contain any partition expressions for * which read access is not allowed. * If read access is not allowed for one of the partitions listed in the * partition policy of the qos, then the subscriber will not be created at * all. */ if(qos && qos->partition) { access = v_kernelPartitionAccessMode(kernel, qos->partition); } else { access = V_ACCESS_MODE_READ_WRITE;/* default */ } if(access == V_ACCESS_MODE_READ_WRITE || access == V_ACCESS_MODE_READ) { q = v_subscriberQosNew(kernel,qos); if (q != NULL) { s = v_subscriber(v_objectNew(kernel,K_SUBSCRIBER)); v_observerInit(v_observer(s),name, NULL, enable); s->qos = q; c_mutexInit(&s->sharesMutex, SHARED_MUTEX); if (q->share.enable) { v_lockShares(kernel); found = v_addShareUnsafe(kernel,v_entity(s)); if (found != v_entity(s)) { /* Make sure to set the partition list to NULL, because * v_publicFree will cause a crash in the v_subscriberDeinit * otherwise. */ s->partitions = NULL; /*v_publicFree to free reference held by the handle server.*/ v_publicFree(v_public(s)); /*Now free the local reference as well.*/ c_free(s); pa_increment(&(v_subscriber(found)->shareCount)); v_unlockShares(kernel); return c_keep(found); } s->shares = c_tableNew(v_kernelType(kernel,K_READER), "qos.share.name"); } else { s->shares = NULL; } s->shareCount = 1; s->partitions = v_partitionAdminNew(kernel); s->readers = c_setNew(v_kernelType(kernel,K_READER)); if (q->share.enable) { s->participant = kernel->builtin->participant; } else { s->participant = p; } c_lockInit(&s->lock,SHARED_LOCK); v_participantAdd(v_participant(s->participant),v_entity(s)); if (q->share.enable) { v_unlockShares(kernel); } if (enable) { v_subscriberEnable(s); } } else { OS_REPORT(OS_ERROR, "v_subscriberNew", 0, "Subscriber not created: inconsistent qos"); s = NULL; } } else { OS_REPORT(OS_ERROR, "v_subscriberNew", 0, "Subscriber not created: Access rights for one of the partitions listed in the partition list was not sufficient (i.e. read or readwrite)."); s = NULL; } return s; }