Publisher* ParticipantImpl::createPublisher(PublisherAttributes& att, PublisherListener* listen) { const char* const METHOD_NAME = "createPublisher"; logInfo(PARTICIPANT,"CREATING PUBLISHER IN TOPIC: "<<att.topic.getTopicName(),C_B_YELLOW) //Look for the correct type registration TopicDataType* p_type = nullptr; if(!getRegisteredType(att.topic.getTopicDataType().c_str(),&p_type)) { logError(PARTICIPANT,"Type : "<< att.topic.getTopicDataType() << " Not Registered"); return nullptr; } if(att.topic.topicKind == WITH_KEY && !p_type->m_isGetKeyDefined) { logError(PARTICIPANT,"Keyed Topic needs getKey function"); return nullptr; } if(m_att.rtps.builtin.use_STATIC_EndpointDiscoveryProtocol) { if(att.getUserDefinedID() <= 0) { logError(PARTICIPANT,"Static EDP requires user defined Id"); return nullptr; } } if(!att.unicastLocatorList.isValid()) { logError(PARTICIPANT,"Unicast Locator List for Publisher contains invalid Locator"); return nullptr; } if(!att.multicastLocatorList.isValid()) { logError(PARTICIPANT," Multicast Locator List for Publisher contains invalid Locator"); return nullptr; } if(!att.qos.checkQos() || !att.topic.checkQos()) return nullptr; //TODO CONSTRUIR LA IMPLEMENTACION DENTRO DEL OBJETO DEL USUARIO. PublisherImpl* pubimpl = new PublisherImpl(this,p_type,att,listen); Publisher* pub = new Publisher(pubimpl); pubimpl->mp_userPublisher = pub; pubimpl->mp_rtpsParticipant = this->mp_rtpsParticipant; WriterAttributes watt; watt.endpoint.durabilityKind = att.qos.m_durability.kind == VOLATILE_DURABILITY_QOS ? VOLATILE : TRANSIENT_LOCAL; watt.endpoint.endpointKind = WRITER; watt.endpoint.multicastLocatorList = att.multicastLocatorList; watt.endpoint.reliabilityKind = att.qos.m_reliability.kind == RELIABLE_RELIABILITY_QOS ? RELIABLE : BEST_EFFORT; watt.endpoint.topicKind = att.topic.topicKind; watt.endpoint.unicastLocatorList = att.unicastLocatorList; if(att.getEntityID()>0) watt.endpoint.setEntityID((uint8_t)att.getEntityID()); if(att.getUserDefinedID()>0) watt.endpoint.setUserDefinedID((uint8_t)att.getUserDefinedID()); watt.times = att.times; RTPSWriter* writer = RTPSDomain::createRTPSWriter(this->mp_rtpsParticipant, watt, (WriterHistory*)&pubimpl->m_history, (WriterListener*)&pubimpl->m_writerListener); if(writer == nullptr) { logError(PARTICIPANT,"Problem creating associated Writer"); delete(pubimpl); return nullptr; } pubimpl->mp_writer = writer; //SAVE THE PUBLISHER PAIR t_p_PublisherPair pubpair; pubpair.first = pub; pubpair.second = pubimpl; m_publishers.push_back(pubpair); //REGISTER THE WRITER this->mp_rtpsParticipant->registerWriter(writer,att.topic,att.qos); return pub; };
Subscriber* ParticipantImpl::createSubscriber(SubscriberAttributes& att, SubscriberListener* listen) { const char* const METHOD_NAME = "createSubscriber"; logInfo(PARTICIPANT,"CREATING SUBSCRIBER IN TOPIC: "<<att.topic.getTopicName(),C_B_YELLOW) //Look for the correct type registration TopicDataType* p_type = nullptr; if(!getRegisteredType(att.topic.getTopicDataType().c_str(),&p_type)) { logError(PARTICIPANT,"Type : "<< att.topic.getTopicDataType() << " Not Registered"); return nullptr; } if(att.topic.topicKind == WITH_KEY && !p_type->m_isGetKeyDefined) { logError(PARTICIPANT,"Keyed Topic needs getKey function"); return nullptr; } if(m_att.rtps.builtin.use_STATIC_EndpointDiscoveryProtocol) { if(att.getUserDefinedID() <= 0) { logError(PARTICIPANT,"Static EDP requires user defined Id"); return nullptr; } } if(!att.unicastLocatorList.isValid()) { logError(PARTICIPANT,"Unicast Locator List for Subscriber contains invalid Locator"); return nullptr; } if(!att.multicastLocatorList.isValid()) { logError(PARTICIPANT," Multicast Locator List for Subscriber contains invalid Locator"); return nullptr; } if(!att.qos.checkQos() || !att.topic.checkQos()) return nullptr; SubscriberImpl* subimpl = new SubscriberImpl(this,p_type,att,listen); Subscriber* sub = new Subscriber(subimpl); subimpl->mp_userSubscriber = sub; subimpl->mp_rtpsParticipant = this->mp_rtpsParticipant; ReaderAttributes ratt; ratt.endpoint.durabilityKind = att.qos.m_durability.kind == VOLATILE_DURABILITY_QOS ? VOLATILE : TRANSIENT_LOCAL; ratt.endpoint.endpointKind = READER; ratt.endpoint.multicastLocatorList = att.multicastLocatorList; ratt.endpoint.reliabilityKind = att.qos.m_reliability.kind == RELIABLE_RELIABILITY_QOS ? RELIABLE : BEST_EFFORT; ratt.endpoint.topicKind = att.topic.topicKind; ratt.endpoint.unicastLocatorList = att.unicastLocatorList; ratt.expectsInlineQos = att.expectsInlineQos; if(att.getEntityID()>0) ratt.endpoint.setEntityID((uint8_t)att.getEntityID()); if(att.getUserDefinedID()>0) ratt.endpoint.setUserDefinedID((uint8_t)att.getUserDefinedID()); ratt.times = att.times; RTPSReader* reader = RTPSDomain::createRTPSReader(this->mp_rtpsParticipant, ratt, (ReaderHistory*)&subimpl->m_history, (ReaderListener*)&subimpl->m_readerListener); if(reader == nullptr) { logError(PARTICIPANT,"Problem creating associated Reader"); delete(subimpl); return nullptr; } subimpl->mp_reader = reader; //SAVE THE PUBLICHER PAIR t_p_SubscriberPair subpair; subpair.first = sub; subpair.second = subimpl; m_subscribers.push_back(subpair); //REGISTER THE READER this->mp_rtpsParticipant->registerReader(reader,att.topic,att.qos); return sub; };
ELSE_LEXICAL_ANY(unsigned short); ELSE_LEXICAL_ANY(int); ELSE_LEXICAL_ANY(unsigned int); ELSE_LEXICAL_ANY(long); ELSE_LEXICAL_ANY(unsigned long); ELSE_LEXICAL_ANY(::int64_t); ELSE_LEXICAL_ANY(::uint64_t); ELSE_LEXICAL_ANY(long long); ELSE_LEXICAL_ANY(unsigned long long); ELSE_LEXICAL_ANY(float); ELSE_LEXICAL_ANY(double); #undef ELSE_LEXICAL_ANY else { AbstractTypeHandler *handler = getRegisteredType(&v.type(), true); if (handler) return handler->asString(v, WString::Empty).jsStringLiteral(); else { LOG_ERROR("unsupported type: '"<< v.type().name() << "'"); return "''"; } } } boost::any updateFromJS(const boost::any& v, std::string s) { if (v.empty()) return boost::any(s); else if (v.type() == typeid(WString)) return boost::any(WString::fromUTF8(s));