bool testEval() { TBTD sample; sample.name = "Adam"; sample.durability.kind = DDS::PERSISTENT_DURABILITY_QOS; sample.durability_service.history_depth = 15; sample.durability_service.service_cleanup_delay.sec = 0; sample.durability_service.service_cleanup_delay.nanosec = 10; DDS::StringSeq params; params.length(1); params[0] = "3"; static const char* filters_pass[] = {"name LIKE 'Ad%'", "durability.kind = 'PERSISTENT_DURABILITY_QOS'", "durability_service.history_depth > %0", "durability_service.service_cleanup_delay.sec = 0 AND " "durability_service.service_cleanup_delay.nanosec >= 10", "durability_service.service_cleanup_delay.sec < " "durability_service.service_cleanup_delay.nanosec"}; static const char* filters_fail[] = {"name LIKE 'ZZ%'", "durability.kind = 'TRANSIENT_DURABILITY_QOS'", "durability_service.history_depth < %0", "durability_service.service_cleanup_delay.sec = 0 AND " "durability_service.service_cleanup_delay.nanosec BETWEEN 3 AND 5", "durability_service.service_cleanup_delay.sec = " "durability_service.service_cleanup_delay.nanosec"}; std::cout << std::boolalpha; bool ok = doEvalTest(filters_pass, true, sample, params); ok &= doEvalTest(filters_fail, false, sample, params); return ok; }
::DDS::ContentFilteredTopic_ptr DDS_DomainParticipant_i::create_contentfilteredtopic (const char * name, ::DDS::Topic_ptr related_topic, const char * filter_expression, const ::DDS::StringSeq & expression_parameters) { DDS4CCM_TRACE ("DDS_DomainParticipant_i::create_contentfilteredtopic"); DDS_Topic_i *top = dynamic_cast< DDS_Topic_i *> (related_topic); if (!top) { DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_CAST_ERROR, (LM_ERROR, DDS4CCM_INFO "DDS_DomainParticipant_i::create_contentfilteredtopic - " "Unable to cast provided topic.\n")); return ::DDS::ContentFilteredTopic::_nil (); } const char** parameterlist = 0; ACE_NEW_THROW_EX (parameterlist, const char*[expression_parameters.length ()], ::CORBA::NO_MEMORY ()); for (CORBA::ULong i = 0; i < expression_parameters.length (); ++i) { parameterlist[i] = expression_parameters[i].in (); } DDS_StringSeq parameters (expression_parameters.length ()); parameters.from_array (parameterlist, expression_parameters.length ()); DDSContentFilteredTopic * ccm_dds_cft = this->rti_entity ()->create_contentfilteredtopic ( name, top->get_rti_entity (), filter_expression, parameters); delete [] parameterlist; if (!ccm_dds_cft) { DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_DDS_NIL_RETURN, (LM_ERROR, DDS4CCM_INFO "DDS_DomainParticipant_i::create_contentfilteredtopic - " "RTI DDS returned a nil ContentFilteredTopic for " "name <%C> and filter expression <%C>.\n", name, filter_expression)); return ::DDS::ContentFilteredTopic::_nil (); } ::DDS::ContentFilteredTopic_var retval; ACE_NEW_THROW_EX (retval, DDS_ContentFilteredTopic_i (ccm_dds_cft, this), ::CORBA::NO_MEMORY ()); DDS4CCM_DEBUG (DDS4CCM_LOG_LEVEL_ACTION, (LM_INFO, DDS4CCM_INFO "DDS_DomainParticipant_i::create_contentfilteredtopic - " "Successfully created contentfilteredtopic with name <%C> and " "filter expression <%C>\n", name, filter_expression)); return retval._retn (); }
bool test_string_seq () { DDS::StringSeq foo (2); foo.length (2); foo[0] = CORBA::string_dup ("bar"); foo[1] = CORBA::string_dup ("foo"); DDS_StringSeq rti_foo; rti_foo <<= foo; DDS::StringSeq tao_foo; tao_foo <<= rti_foo; return StringSequence::check (rti_foo, tao_foo, "StringSeq"); }
void TAO_DDS_DCPSDataWriter_i::update_subscription_params( const OpenDDS::DCPS::RepoId& id, const DDS::StringSeq& params) { OpenDDS::DCPS::RepoIdConverter readerConv(id); ACE_DEBUG((LM_INFO, ACE_TEXT("\nTAO_DDS_DCPSDataWriter_i::update_subscription_params() :\n") ACE_TEXT("\treader = %C\n\tparams.length = %d\n"), std::string(readerConv).c_str(), params.length())); const CORBA::ULong length = params.length(); for (CORBA::ULong i = 0; i < length; ++i) { ACE_DEBUG((LM_INFO, ACE_TEXT("\tparams[%d] = %C\n"), i, params[i].in())); } received_.received(DiscReceivedCalls::UPDATE_SUB_PARAMS); }
void DDS::ccpp_sequenceCopyIn( const DDS::StringSeq &from, gapi_stringSeq &to) { to._maximum = from.length(); to._length = from.length(); to._release = TRUE; if (to._maximum > 0){ to._buffer = gapi_stringSeq_allocbuf(to._length); for (CORBA::ULong i=0; i<to._length; i++) { const char *value = from[i]; to._buffer[i] = gapi_string_dup(value); } } else { to._buffer = NULL; }; }
void DDS::ccpp_sequenceCopyOut( const gapi_stringSeq &from, DDS::StringSeq &to) { to.length(from._length); for (CORBA::ULong i=0; i<from._length; i++) { to[i] = CORBA::string_dup(reinterpret_cast<const char *>(from._buffer[i])); } }
QueryCondition(const dds::sub::Query& query, const dds::sub::status::DataState& data_state, const FUN& functor) : ReadCondition(query.data_reader(), data_state, functor, true), query_(query) { DDS::StringSeq params; params.length(static_cast<DDS::ULong>(query.parameters_length())); for(unsigned int i = 0; i < query.parameters_length(); i++) { params[i] = (query.begin() + i)->c_str(); } query_condition_ = adr_->get_dds_datareader()->create_querycondition(status_.sample_state().to_ulong(), status_.view_state().to_ulong(), status_.instance_state().to_ulong(), query.expression().c_str(), params); if (query_condition_.in() == 0) throw dds::core::NullReferenceError(org::opensplice::core::exception_helper( OSPL_CONTEXT_LITERAL("dds::core::NullReferenceError : Unable to create QueryCondition. " "Nil return from ::create_querycondition"))); condition_ = query_condition_.in(); }
int OSPL_MAIN ( int argc, char *argv[]) { /* Generic DDS entities */ DomainParticipantFactory_var dpf; DomainParticipant_var parentDP; ExtDomainParticipant_var participant; Topic_var chatMessageTopic; Topic_var nameServiceTopic; TopicDescription_var namedMessageTopic; Subscriber_var chatSubscriber; DataReader_var parentReader; /* Type-specific DDS entities */ ChatMessageTypeSupport_var chatMessageTS; NameServiceTypeSupport_var nameServiceTS; NamedMessageTypeSupport_var namedMessageTS; NamedMessageDataReader_var chatAdmin; NamedMessageSeq_var msgSeq = new NamedMessageSeq(); SampleInfoSeq_var infoSeq = new SampleInfoSeq(); /* QosPolicy holders */ TopicQos reliable_topic_qos; TopicQos setting_topic_qos; SubscriberQos sub_qos; DDS::StringSeq parameterList; /* DDS Identifiers */ DomainId_t domain = DOMAIN_ID_DEFAULT; ReturnCode_t status; /* Others */ bool terminated = false; const char * partitionName = "ChatRoom"; char * chatMessageTypeName = NULL; char * nameServiceTypeName = NULL; char * namedMessageTypeName = NULL; #ifdef USE_NANOSLEEP struct timespec sleeptime; struct timespec remtime; #endif /* Options: MessageBoard [ownID] */ /* Messages having owner ownID will be ignored */ parameterList.length(1); if (argc > 1) { parameterList[0] = DDS::string_dup(argv[1]); } else { parameterList[0] = "0"; } /* Create a DomainParticipantFactory and a DomainParticipant (using Default QoS settings. */ dpf = DomainParticipantFactory::get_instance(); checkHandle(dpf.in(), "DDS::DomainParticipantFactory::get_instance"); parentDP = dpf->create_participant ( domain, PARTICIPANT_QOS_DEFAULT, NULL, STATUS_MASK_NONE); checkHandle(parentDP.in(), "DDS::DomainParticipantFactory::create_participant"); /* Narrow the normal participant to its extended representative */ participant = ExtDomainParticipantImpl::_narrow(parentDP.in()); checkHandle(participant.in(), "DDS::ExtDomainParticipant::_narrow"); /* Register the required datatype for ChatMessage. */ chatMessageTS = new ChatMessageTypeSupport(); checkHandle(chatMessageTS.in(), "new ChatMessageTypeSupport"); chatMessageTypeName = chatMessageTS->get_type_name(); status = chatMessageTS->register_type( participant.in(), chatMessageTypeName); checkStatus(status, "Chat::ChatMessageTypeSupport::register_type"); /* Register the required datatype for NameService. */ nameServiceTS = new NameServiceTypeSupport(); checkHandle(nameServiceTS.in(), "new NameServiceTypeSupport"); nameServiceTypeName = nameServiceTS->get_type_name(); status = nameServiceTS->register_type( participant.in(), nameServiceTypeName); checkStatus(status, "Chat::NameServiceTypeSupport::register_type"); /* Register the required datatype for NamedMessage. */ namedMessageTS = new NamedMessageTypeSupport(); checkHandle(namedMessageTS.in(), "new NamedMessageTypeSupport"); namedMessageTypeName = namedMessageTS->get_type_name(); status = namedMessageTS->register_type( participant.in(), namedMessageTypeName); checkStatus(status, "Chat::NamedMessageTypeSupport::register_type"); /* Set the ReliabilityQosPolicy to RELIABLE. */ status = participant->get_default_topic_qos(reliable_topic_qos); checkStatus(status, "DDS::DomainParticipant::get_default_topic_qos"); reliable_topic_qos.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS; /* Make the tailored QoS the new default. */ status = participant->set_default_topic_qos(reliable_topic_qos); checkStatus(status, "DDS::DomainParticipant::set_default_topic_qos"); /* Use the changed policy when defining the ChatMessage topic */ chatMessageTopic = participant->create_topic( "Chat_ChatMessage", chatMessageTypeName, reliable_topic_qos, NULL, STATUS_MASK_NONE); checkHandle(chatMessageTopic.in(), "DDS::DomainParticipant::create_topic (ChatMessage)"); /* Set the DurabilityQosPolicy to TRANSIENT. */ status = participant->get_default_topic_qos(setting_topic_qos); checkStatus(status, "DDS::DomainParticipant::get_default_topic_qos"); setting_topic_qos.durability.kind = DDS::TRANSIENT_DURABILITY_QOS; /* Create the NameService Topic. */ nameServiceTopic = participant->create_topic( "Chat_NameService", nameServiceTypeName, setting_topic_qos, NULL, STATUS_MASK_NONE); checkHandle(nameServiceTopic.in(), "DDS::DomainParticipant::create_topic"); /* Create a multitopic that substitutes the userID with its corresponding userName. */ namedMessageTopic = participant->create_simulated_multitopic( "Chat_NamedMessage", namedMessageTypeName, "SELECT userID, name AS userName, index, content " "FROM Chat_NameService NATURAL JOIN Chat_ChatMessage WHERE userID <> %0", parameterList); checkHandle(namedMessageTopic.in(), "DDS::ExtDomainParticipant::create_simulated_multitopic"); /* Adapt the default SubscriberQos to read from the "ChatRoom" Partition. */ status = participant->get_default_subscriber_qos (sub_qos); checkStatus(status, "DDS::DomainParticipant::get_default_subscriber_qos"); sub_qos.partition.name.length(1); sub_qos.partition.name[0] = partitionName; /* Create a Subscriber for the MessageBoard application. */ chatSubscriber = participant->create_subscriber(sub_qos, NULL, STATUS_MASK_NONE); checkHandle(chatSubscriber.in(), "DDS::DomainParticipant::create_subscriber"); /* Create a DataReader for the NamedMessage Topic (using the appropriate QoS). */ parentReader = chatSubscriber->create_datareader( namedMessageTopic.in(), DATAREADER_QOS_USE_TOPIC_QOS, NULL, STATUS_MASK_NONE); checkHandle(parentReader.in(), "DDS::Subscriber::create_datareader"); /* Narrow the abstract parent into its typed representative. */ chatAdmin = Chat::NamedMessageDataReader::_narrow(parentReader.in()); checkHandle(chatAdmin.in(), "Chat::NamedMessageDataReader::_narrow"); /* Print a message that the MessageBoard has opened. */ cout << "MessageBoard has opened: send a ChatMessage with userID = -1 to close it...." << endl << endl; while (!terminated) { /* Note: using read does not remove the samples from unregistered instances from the DataReader. This means that the DataRase would use more and more resources. That's why we use take here instead. */ status = chatAdmin->take( msgSeq, infoSeq, LENGTH_UNLIMITED, ANY_SAMPLE_STATE, ANY_VIEW_STATE, ALIVE_INSTANCE_STATE ); checkStatus(status, "Chat::NamedMessageDataReader::take"); for (DDS::ULong i = 0; i < msgSeq->length(); i++) { NamedMessage *msg = &(msgSeq[i]); if (msg->userID == TERMINATION_MESSAGE) { cout << "Termination message received: exiting..." << endl; terminated = true; } else { cout << msg->userName << ": " << msg->content << endl; } fflush(stdout); } status = chatAdmin->return_loan(msgSeq, infoSeq); checkStatus(status, "Chat::ChatMessageDataReader::return_loan"); /* Sleep for some amount of time, as not to consume too much CPU cycles. */ #ifdef USE_NANOSLEEP sleeptime.tv_sec = 0; sleeptime.tv_nsec = 100000000; nanosleep(&sleeptime, &remtime); #elif defined _WIN32 Sleep(100); #else usleep(100000); #endif } /* Remove the DataReader */ status = chatSubscriber->delete_datareader(chatAdmin.in()); checkStatus(status, "DDS::Subscriber::delete_datareader"); /* Remove the Subscriber. */ status = participant->delete_subscriber(chatSubscriber.in()); checkStatus(status, "DDS::DomainParticipant::delete_subscriber"); /* Remove the Topics. */ status = participant->delete_simulated_multitopic(namedMessageTopic.in()); checkStatus(status, "DDS::ExtDomainParticipant::delete_simulated_multitopic"); status = participant->delete_topic(nameServiceTopic.in()); checkStatus(status, "DDS::DomainParticipant::delete_topic (nameServiceTopic)"); status = participant->delete_topic(chatMessageTopic.in()); checkStatus(status, "DDS::DomainParticipant::delete_topic (chatMessageTopic)"); /* De-allocate the type-names. */ DDS::string_free(namedMessageTypeName); DDS::string_free(nameServiceTypeName); DDS::string_free(chatMessageTypeName); /* Remove the DomainParticipant. */ status = dpf->delete_participant(participant.in()); checkStatus(status, "DDS::DomainParticipantFactory::delete_participant"); return 0; }
void BulkDataNTStream::removeDDSQoSProfile(const DDSConfiguration &cfg) { DDS::ReturnCode_t ret; DDS::DomainParticipantFactoryQos factory_qos; DDS::StringSeq newQoSprofiles; unsigned int profLen; if (cfg.stringProfileQoS.length()<=0) return; // if QoSprofile is empty we do not need to do anything // needed by RTI only ret = factory_m->get_qos(factory_qos); if (ret!=DDS::RETCODE_OK) { DDSQoSSetProblemExImpl ex(__FILE__, __LINE__, __PRETTY_FUNCTION__); ex.setDDSTypeCode(ret); ex.setQoS("factory_m->get_qos"); throw ex; }//if profLen = factory_qos.profile.string_profile.length(); //how many profiles do we have already ? if (profLen>0) // we should have more than 0 profiles { newQoSprofiles.ensure_length(profLen-1, profLen-1); // one profile one line // lets check if the library is already there unsigned int i=0; // index for the new profile unsigned int j=0; // index for current profile // first we have to get the start of QoS library std::string qoSlibTag("<qos_library name=\""); // we have to search for qos_libarary TAG qoSlibTag+=cfg.libraryQos; qoSlibTag+="\">"; //std::cout << "seraching for: " << qoSlibTag << std::endl; while (strcmp(qoSlibTag.c_str(), factory_qos.profile.string_profile[j]) != 0) { //std::cout << "try: " << factory_qos.profile.string_profile[j] << std::endl; newQoSprofiles[i] = DDS::String_dup(factory_qos.profile.string_profile[j]); i++; j++; } bool outOfQoSLib=false; //we are inside the QoSLib section for (;j<profLen;j++) //loop over all profiles { //we search for the profile if (outOfQoSLib || strcmp(cfg.stringProfileQoS.c_str(), factory_qos.profile.string_profile[j]) != 0 ) { newQoSprofiles[i] = DDS::String_dup(factory_qos.profile.string_profile[j]); // if we do not find it (or we are in different QoSlib), just copy over i++; if (!outOfQoSLib && strcmp("</qos_library>", factory_qos.profile.string_profile[j]) == 0) outOfQoSLib=true; }else { if (DDSConfiguration::debugLevel>0) ACS_SHORT_LOG((LM_DEBUG, "We are about to remove QoS profile: %s.", cfg.stringProfileQoS.c_str())); }//if-else }//for factory_qos.profile.string_profile = newQoSprofiles; if (DDSConfiguration::debugLevel>=2) { printf("QoS profiles just before setting to DDS factory (removeDDSQoSProfile):\n"); int u=factory_qos.profile.string_profile.length(); for (int j=0;j<u;j++) printf("=>\t %d: %s \n", j, factory_qos.profile.string_profile[j] ); } ret = factory_m->set_qos(factory_qos); if (ret!=DDS::RETCODE_OK) { DDSQoSSetProblemExImpl ex(__FILE__, __LINE__, __PRETTY_FUNCTION__); ex.setDDSTypeCode(ret); std::string com("factory_m->set_qos: "); com+=cfg.libraryQos; com+=" : "; com+=cfg.profileQos; ex.setQoS(com.c_str()); throw ex; }//if } else { // it should be at least one profile ??? } }//removeDDSQoSProfile
int OSPL_MAIN ( int argc, char *argv[]) { /* Generic DDS entities */ DomainParticipantFactory_var dpf; DomainParticipant_var participant; Topic_var chatMessageTopic; Subscriber_var chatSubscriber; DataReader_ptr parentReader; /* Type-specific DDS entities */ ChatMessageTypeSupport_var chatMessageTS; ChatMessageDataReader_var chatAdmin; ChatMessageSeq_var msgSeq = new ChatMessageSeq(); SampleInfoSeq_var infoSeq = new SampleInfoSeq(); /* QosPolicy holders */ TopicQos reliable_topic_qos; SubscriberQos sub_qos; DDS::StringSeq parameterList; /* DDS Identifiers */ DomainId_t domain = 0; ReturnCode_t status; /* Others */ bool terminated = false; const char * partitionName = "ChatRoom1"; char * chatMessageTypeName = NULL; /* Options: MessageBoard [ownID] */ /* Messages having owner ownID will be ignored */ parameterList.length(1); if (argc > 1) { parameterList[0] = string_dup(argv[1]); } else { parameterList[0] = "0"; } /* Create a DomainParticipantFactory and a DomainParticipant (using Default QoS settings. */ dpf = DomainParticipantFactory::get_instance(); checkHandle(dpf.in(), "DDS::DomainParticipantFactory::get_instance"); participant = dpf->create_participant ( domain, PARTICIPANT_QOS_DEFAULT, NULL, STATUS_MASK_NONE); checkHandle(participant, "DDS::DomainParticipantFactory::create_participant"); /* Register the required datatype for ChatMessage. */ chatMessageTS = new ChatMessageTypeSupport(); checkHandle(chatMessageTS.in(), "new ChatMessageTypeSupport"); chatMessageTypeName = chatMessageTS->get_type_name(); status = chatMessageTS->register_type( participant.in(), chatMessageTypeName); checkStatus(status, "NetworkPartitionsData::ChatMessageTypeSupport::register_type"); /* Set the ReliabilityQosPolicy to RELIABLE. */ status = participant->get_default_topic_qos(reliable_topic_qos); checkStatus(status, "DDS::DomainParticipant::get_default_topic_qos"); reliable_topic_qos.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS; /* Make the tailored QoS the new default. */ status = participant->set_default_topic_qos(reliable_topic_qos); checkStatus(status, "DDS::DomainParticipant::set_default_topic_qos"); /* Use the changed policy when defining the ChatMessage topic */ chatMessageTopic = participant->create_topic( "Chat_ChatMessage", chatMessageTypeName, reliable_topic_qos, NULL, STATUS_MASK_NONE); checkHandle(chatMessageTopic.in(), "DDS::DomainParticipant::create_topic (ChatMessage)"); /* Adapt the default SubscriberQos to read from the "ChatRoom1" Partition. */ status = participant->get_default_subscriber_qos (sub_qos); checkStatus(status, "DDS::DomainParticipant::get_default_subscriber_qos"); sub_qos.partition.name.length(1); sub_qos.partition.name[0] = partitionName; /* Create a Subscriber for the MessageBoard application. */ chatSubscriber = participant->create_subscriber(sub_qos, NULL, STATUS_MASK_NONE); checkHandle(chatSubscriber.in(), "DDS::DomainParticipant::create_subscriber"); /* Create a DataReader for the NamedMessage Topic (using the appropriate QoS). */ parentReader = chatSubscriber->create_datareader( chatMessageTopic.in(), DATAREADER_QOS_USE_TOPIC_QOS, NULL, STATUS_MASK_NONE); checkHandle(parentReader, "DDS::Subscriber::create_datareader"); /* Narrow the abstract parent into its typed representative. */ chatAdmin = ChatMessageDataReader::_narrow(parentReader); checkHandle(chatAdmin.in(), "NetworkPartitionsData::ChatMessageDataReader::_narrow"); /* Print a message that the MessageBoard has opened. */ cout << "MessageBoard has opened: send a ChatMessage with userID = -1 to close it...." << endl << endl; while (!terminated) { /* Note: using read does not remove the samples from unregistered instances from the DataReader. This means that the DataRase would use more and more resources. That's why we use take here instead. */ status = chatAdmin->take( msgSeq, infoSeq, LENGTH_UNLIMITED, ANY_SAMPLE_STATE, ANY_VIEW_STATE, ALIVE_INSTANCE_STATE ); checkStatus(status, "NetworkPartitionsData::ChatMessageDataReader::take"); for (ULong i = 0; i < msgSeq->length(); i++) { ChatMessage *msg = &(msgSeq[i]); if (msg->userID == TERMINATION_MESSAGE) { cout << "Termination message received: exiting..." << endl; terminated = true; } else { cout << msg->userID << ": " << msg->content << endl; } } status = chatAdmin->return_loan(msgSeq, infoSeq); checkStatus(status, "NetworkPartitionsData::ChatMessageDataReader::return_loan"); /* Sleep for some amount of time, so as not to consume too many CPU cycles. */ sleep(1); } /* Remove the DataReader */ status = chatSubscriber->delete_datareader(chatAdmin.in()); checkStatus(status, "DDS::Subscriber::delete_datareader"); /* Remove the Subscriber. */ status = participant->delete_subscriber(chatSubscriber.in()); checkStatus(status, "DDS::DomainParticipant::delete_subscriber"); /* Remove the Topic. */ status = participant->delete_topic(chatMessageTopic.in()); checkStatus(status, "DDS::DomainParticipant::delete_topic (chatMessageTopic)"); /* De-allocate the type-names. */ string_free(chatMessageTypeName); /* Remove the DomainParticipant. */ status = dpf->delete_participant(participant.in()); checkStatus(status, "DDS::DomainParticipantFactory::delete_participant"); return 0; }