bool operator==(const TestType& lhs, const TestType& rhs)
{
    ASSERT(isalpha(lhs.datum()));
    ASSERT(isalpha(rhs.datum()));

    return lhs.datum() == rhs.datum();
}
Example #2
0
static int dumpStdMapStringString()
{
    typedef std::map<std::string,std::string> TestType;
    TestType test;
    const TestType::value_type entry("K", "V");
    if (!optEmptyContainers) {
        test.insert(entry);
    }
    const int valueOffset = (char*)&(entry.second) - (char*)&entry;
    prepareInBuffer("std::map", "local.stdmapstringstring", "local.stdmapstringstring",
                    "std::basic_string<char,std::char_traits<char>,std::allocator<char> >@std::basic_string<char,std::char_traits<char>,std::allocator<char> >@std::less<int>@std::allocator<std::pair<const std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >");
    qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::string), sizeof(std::string), valueOffset, 0);
    fputs(qDumpOutBuffer, stdout);
    fputc('\n', stdout);
    return 0;
}
//
// FREE OPERATORS
bool operator==(const TestType& lhs, const TestType& rhs)
{
    return lhs.datum() == rhs.datum();
}
void swap(TestType<Alloc, Prefix>& a, TestType<Alloc, Prefix>& b) noexcept
{
    a.swap(b);
}
bool operator!=(const TestType<Alloc, Prefix>& a,
                const TestType<Alloc, Prefix>& b)
{
    return a.value() != b.value();
}
Example #6
0
int main(int argc, char** argv)
{
	RTPSLog::setVerbosity(EPROSIMA_DEBUGINFO_VERB_LEVEL);
	int type;
	if(argc > 1)
	{
//		RTPSLog::Info << "Parsing arguments: " << argv[1] << endl;
//		RTPSLog::printInfo();
		if(strcmp(argv[1],"1")==0)
			type = 1;
		else if(strcmp(argv[1],"2")==0)
			type = 2;
		else if(strcmp(argv[1],"3")==0)
			type = 3;
	}
	else
		type = WR;

	TestTypeDataType TestTypeData;
	DomainRTPSParticipant::registerType((DDSTopicDataType*)&TestTypeData);

	RTPSParticipantAttributes PParam;
	PParam.defaultSendPort = 10042;
	PParam.discovery.use_SIMPLE_RTPSParticipantDiscoveryProtocol = false;
	RTPSParticipant* p = DomainRTPSParticipant::createRTPSParticipant(PParam);

	switch(type)
	{
	case 1:
	{
		PublisherAttributes PParam;
		PParam.historyMaxSize = 20;
		PParam.topic.topicKind = WITH_KEY;
		PParam.topic.topicDataType = "TestType";
		PParam.topic.topicName = "Test_topic";
		Publisher* pub1 = DomainRTPSParticipant::createPublisher(p,PParam);
		Publisher* pub2 = DomainRTPSParticipant::createPublisher(p,PParam);
		SubscriberAttributes Sparam;
		Sparam.historyMaxSize = 50;
		Sparam.topic.topicDataType = std::string("TestType");
		Sparam.topic.topicName = std::string("Test_topic");
		Sparam.topic.topicKind = NO_KEY;
		Locator_t loc;
		loc.kind = 1;
		loc.port = 10467;
		Sparam.unicastLocatorList.push_back(loc); //Listen in the 10469 port
		Subscriber* sub = DomainRTPSParticipant::createSubscriber(p,Sparam);

		loc.set_IP4_address(127,0,0,1);
		loc.port = 10466;
		pub1->addReaderLocator(loc,true);
		pub2->addReaderLocator(loc,true);
		TestType tp1,tp2,tp_in;
		SampleInfo_t info;
		COPYSTR(tp1.name,"Obje1");
		COPYSTR(tp2.name,"Obje2");
		tp1.value = 0;
		tp1.price = 1.3;
		tp2.value = 0;
		tp2.price = -1.3;
		int n;
		cout << "Enter number to start: ";
		cin >> n;
		for(uint i = 0;i<10;i++)
		{
			tp1.value++;
			tp1.price *= (i+1);
			tp2.value++;
			tp2.price *= (i+1);
			pub1->write((void*)&tp1);
			pub2->write((void*)&tp2);
			if(pub1->getHistoryElementsNumber() >= 0.8*Sparam.historyMaxSize)
				pub1->removeMinSeqChange();
			if(pub2->getHistoryElementsNumber() >= 0.8*Sparam.historyMaxSize)
				pub2->removeMinSeqChange();
			if(i==8)
			{
				pub1->dispose((void*)&tp1);
				pub1->unregister((void*)&tp1);
				pub2->dispose((void*)&tp2);
				pub2->unregister((void*)&tp2);
				COPYSTR(tp1.name,"Obje3");
				tp1.value = 0;
				tp1.price = 1.5;
				COPYSTR(tp2.name,"Obje4");
				tp2.value = 0;
				tp2.price = 1.5;
			}
			if(sub->getHistoryElementsNumber() >= 1)
			{
				cout << "Taking from subscriber" <<endl;
				if(sub->readNextData((void*)&tp_in,&info))
					tp_in.print();
				cout << "Subscriber History has now: " << sub->getHistoryElementsNumber() << " elements "<<endl;
			}
		}
		cout << "Sleeping 3 seconds"<<endl;
		my_sleep(3);
		cout << "Slept for 3 seconds"<< endl;
		while(sub->takeNextData((void*)&tp_in,&info))
		{
			if(info.sampleKind == ALIVE)
				tp_in.print();
			else
				cout << "NOT ALIVE SAMPLE"<< endl;
		}
		break;
	}
	case 2:
	{
		SubscriberAttributes Rparam;
		Rparam.historyMaxSize = 50;
		Rparam.topic.topicDataType = std::string("TestType");
		Rparam.topic.topicName = std::string("Test_topic");
		Rparam.topic.topicKind = WITH_KEY;
		Locator_t loc;
		loc.kind = 1;
		loc.port = 10469;
		Rparam.unicastLocatorList.push_back(loc); //Listen in port 10469
		Subscriber* sub = DomainRTPSParticipant::createSubscriber(p,Rparam);
		TestTypeListener listener;
		sub->assignListener((SubscriberListener*)&listener);
		PublisherAttributes WParam;
		WParam.historyMaxSize = 50;
		WParam.topic.topicKind = NO_KEY;
		WParam.topic.topicDataType = "TestType";
		WParam.topic.topicName = "Test_topic";
		Publisher* pub1 = DomainRTPSParticipant::createPublisher(p,WParam);
		loc.set_IP4_address(192,168,1,IPTEST0);
		pub1->addReaderLocator(loc,false);
		while(1)
		{
			cout << "Blocking until new message arrives " << endl;
			sub->waitForUnreadMessage();
			//cout << "After new message block " << sub->getHistory_n() << endl;
			TestType tp;
			SampleInfo_t info;
			while(sub->readNextData((void*)&tp,&info))
			{
				tp.print();
				pub1->write((void*)&tp);
				cout << "Write OK"<< endl;
				tp.value = -1;
				tp.price = 0;
				COPYSTR(tp.name,"UNDEF");
			}
			if(sub->getHistoryElementsNumber() >= 0.5*Rparam.historyMaxSize)
			{
				cout << "Taking all" <<endl;
				while(sub->takeNextData((void*)&tp,&info))
					tp.print();
			}
		}
		break;
	}
	default:
		break;
	}


	cout << "Enter numer "<< endl;
	int n;
	cin >> n;
	DomainRTPSParticipant::stopAll();



	return 0;

}
Example #7
0
inline int testAll( const typename TestType::Scalar tolerance = 1e-6 )
{
    TestType test;
    auto uniformTab = test.createUniformTabulatedFunction(TestType::testFn1);
    auto uniformXTab = test.createUniformXTabulatedFunction(TestType::testFn1);
    if (!test.compareTables(uniformTab, uniformXTab, TestType::testFn1, tolerance))
        return 1;

    uniformTab = test.createUniformTabulatedFunction(TestType::testFn2);
    uniformXTab = test.createUniformXTabulatedFunction(TestType::testFn2);
    if (!test.compareTables(uniformTab, uniformXTab, TestType::testFn2, tolerance))
        return 1;

    uniformTab = test.createUniformTabulatedFunction(TestType::testFn3);
    uniformXTab = test.createUniformXTabulatedFunction(TestType::testFn3);
    if (!test.compareTables(uniformTab, uniformXTab, TestType::testFn3, /*tolerance=*/1e-2))
        return 1;

    uniformXTab = test.createUniformXTabulatedFunction2(TestType::testFn3);
    if (!test.compareTableWithAnalyticFn(uniformXTab,
                                    -2.0, 3.0, 100,
                                    -4.0, 5.0, 100,
                                    TestType::testFn3,
                                    /*tolerance=*/1e-2))
        return 1;

    // CSV output for debugging
#if 0
    int m = 100;
    int n = 100;
    Scalar xMin = -3.0;
    Scalar xMax = 4.0;

    Scalar yMin = -1;
    Scalar yMax = 1;
    for (int i = 0; i < m; ++i) {
        Scalar x = xMin + Scalar(i)/m * (xMax - xMin);

        for (int j = 0; j < n; ++j) {
            Scalar y = yMin + Scalar(j)/n * (yMax - yMin);

            std::cout << x << " "
                      << y << " "
                      << uniformXTab->eval(x,y,true) << "\n";
        }
        std::cout << "\n";
    }
#endif
    return 0;
}
bool checkConstructionEquiv(TestType& T, TestType& U)
    // check that 'T' and 'U' where initialized in the exact same manner.
{
    return T.checkConstructEquiv(U);
}