Exemplo n.º 1
0
bool parseRange(TNum & beginPos, TNum & endPos, seqan::CharString const & rangeStr)
{
    seqan::DirectionIterator<seqan::CharString const, seqan::Input>::Type reader = directionIterator(rangeStr, seqan::Input());

    // Parse out begin position.
    seqan::CharString buffer;
    readUntil(buffer, reader, seqan::EqualsChar<'-'>(), seqan::EqualsChar<','>());
    if (!lexicalCast(beginPos, buffer))
        return false;

    if (atEnd(reader))
        return false;

    skipOne(reader);    // Skip '-'.

    // Parse out end position.
    clear(buffer);
    readUntil(buffer, reader, seqan::False(), seqan::EqualsChar<','>());

    if (empty(buffer))
    {
        endPos = seqan::maxValue<TNum>();
        return true;
    }

    if (!lexicalCast(endPos, buffer))
        return false;

    return (beginPos <= endPos);
}
Exemplo n.º 2
0
    void testEntireRange ()
    {
        testcase ("entire range");

        std::int32_t i = std::numeric_limits<std::int16_t>::min();
        std::string const empty("");

        while (i <= std::numeric_limits<std::int16_t>::max())
        {
            std::int16_t j = static_cast<std::int16_t>(i);

            auto actual = std::to_string (j);

            auto result = lexicalCast (j, empty);

            expect (result == actual, actual + " (string to integer)");

            if (result == actual)
            {
                auto number = lexicalCast <std::int16_t> (result);

                if (number != j)
                    expect (false, actual + " (integer to string)");
            }

            i++;
        }
    }
Exemplo n.º 3
0
void
ShapesDialog::onSubscribeButtonClicked()
{
    dds::topic::qos::TopicQos topicQos = dp_.default_topic_qos()
                                         << dds::core::policy::Durability::Persistent()
                                         << dds::core::policy::DurabilityService(
                                                    dds::core::Duration(3600,0),
                                                    dds::core::policy::HistoryKind::KEEP_LAST,
                                                    100,
                                                    8192,
                                                    4196,
                                                    8192);

    dds::sub::qos::SubscriberQos SQos = dp_.default_subscriber_qos() << gQos_;
    dds::sub::Subscriber sub(dp_, SQos);
    int d = mainWidget.sizeSlider->value();
    QRect rect(0, 0, d, d);
    QRect constr(0, 0, IS_WIDTH, IS_HEIGHT);
    int x = static_cast<int>(constr.width() * ((float)rand() / RAND_MAX)*0.9F);
    int y = static_cast<int>(constr.height() * ((float)rand() / RAND_MAX)*0.9F);
    int sIdx = mainWidget.rShapeList->currentIndex();

    QColor gray = QColor(0x99, 0x99, 0x99);
    QBrush brush(gray, Qt::SolidPattern);

    QPen pen(QColor(0xff,0xff,0xff), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    std::vector<std::string> empty;
    filterParams_ = empty;
    std::string filterS;
    if (filterDialog_->isEnabled())
    {
        QRect rect =  filterDialog_->getFilterBounds();
        std::string x0 = lexicalCast(rect.x());
        std::string x1 = lexicalCast(rect.x() + rect.width() -d);
        std::string y0 = lexicalCast(rect.y());
        std::string y1 = lexicalCast(rect.y() + rect.height() -d);
        filterParams_.push_back(x0);
        filterParams_.push_back(x1);
        filterParams_.push_back(y0);
        filterParams_.push_back(y1);
        filterS = "(x BETWEEN "
            + filterParams_[0]
            + " AND "
            + filterParams_[1]
            + ") AND (y BETWEEN "
            + filterParams_[2]
            + " AND "
            + filterParams_[3]
            + ")";

        if (filterDialog_->filterOutside() == false)
        {
             filterS = "(x < "
                 + filterParams_[0]
                 + " ) OR ( x > "
                 + filterParams_[1]
                 + " ) OR (y < "
                 + filterParams_[2]
                 + ") OR ( y > "
                 + filterParams_[3]
                 + ")";
        }
    }

    switch (sIdx)
    {

        case CIRCLE:
        {
            dds::topic::Topic<ShapeType> circle_(dp_, circleTopicName, topicQos);
	        dds::topic::ContentFilteredTopic<ShapeType> cfcircle_(dds::core::null);
            dds::sub::DataReader<ShapeType> dr(sub, circle_, readerQos_.get_qos());

            if (filterDialog_->isEnabled())
            {
                std::string tname = "CFCircle";
                const dds::topic::Filter filter(filterS);
                std::cout << filterS << std::endl;
                dds::topic::ContentFilteredTopic<ShapeType> cfcircle_(circle_, "CFCircle", filter);
	            dds::sub::DataReader<ShapeType> dr2(sub, cfcircle_, readerQos_.get_qos());
                dr = dr2;
            }
            for (int i = 0; i < CN; ++i)
            {
                std::string colorStr(colorString_[i]);

                DDSShapeDynamics::ref_type
                dynamics(new DDSShapeDynamics(x, y, dr, colorStr, i));

                Shape::ref_type
                circle(new Circle(rect, dynamics, pen, brush, true));

                dynamics->setShape(circle);
                shapesWidget->addShape(circle);
            }
            break;
        }

        case SQUARE:
        {
            dds::topic::Topic<ShapeType> square_(dp_, squareTopicName, topicQos);
            dds::sub::LoanedSamples<ShapeType>::iterator si;
	        dds::topic::ContentFilteredTopic<ShapeType> cfsquare_(dds::core::null);
            dds::sub::DataReader<ShapeType> dr(sub, square_, readerQos_.get_qos());

            if (filterDialog_->isEnabled())
            {
                std::string tname = "CFSquare";
                const dds::topic::Filter filter(filterS);
                std::cout << filterS << std::endl;
                dds::topic::ContentFilteredTopic<ShapeType> cfsquare_(square_, "CFSquare", filter);
	            dds::sub::DataReader<ShapeType> dr2(sub, cfsquare_, readerQos_.get_qos());
                dr = dr2;
            }

            for (int i = 0; i < CN; ++i)
            {
                std::string colorStr(colorString_[i]);

                DDSShapeDynamics::ref_type
                dynamics(new DDSShapeDynamics(x, y, dr, colorStr, i));

                Shape::ref_type
                square(new Square(rect, dynamics, pen, brush, true));

                dynamics->setShape(square);
                shapesWidget->addShape(square);
            }
            break;
        }

        case TRIANGLE:
        {
            dds::topic::Topic<ShapeType> triangle_(dp_, triangleTopicName, topicQos);
            dds::sub::LoanedSamples<ShapeType>::iterator si;
	        dds::topic::ContentFilteredTopic<ShapeType> cftriangle_(dds::core::null);
            dds::sub::DataReader<ShapeType> dr(sub, triangle_, readerQos_.get_qos());

            if (filterDialog_->isEnabled())
            {
                std::string tname = "CFTriangle";
                const dds::topic::Filter filter(filterS);
                std::cout << filterS << std::endl;
                dds::topic::ContentFilteredTopic<ShapeType> cftriangle_(triangle_, "CFTriangle", filter);
	            dds::sub::DataReader<ShapeType> dr2(sub, cftriangle_, readerQos_.get_qos());
                dr = dr2;
            }

            for (int i = 0; i < CN; ++i)
            {
                std::string colorStr(colorString_[i]);

                DDSShapeDynamics::ref_type
                dynamics(new DDSShapeDynamics(x, y, dr, colorStr, i));

                Shape::ref_type
                triangle(new Triangle(rect, dynamics, pen, brush, true));

                dynamics->setShape(triangle);
                shapesWidget->addShape(triangle);
            }
        break;
        }

        default:
            break;
    }
}