Example #1
0
    void setValue(const QString &value)
    {
        //parse to data type
        Pothos::DType dtype;
        try
        {
            dtype = Pothos::DType(unQuote(value).toStdString());
        }
        catch(...){}
        const auto name = QString("\"%1\"").arg(QString::fromStdString(dtype.name()));

        //set combo box with type name
        int index = -1;
        for (int i = 0; i < _comboBox->count(); i++)
        {
            if (_comboBox->itemData(i).toString() == name) index = i;
        }
        if (index < 0) _comboBox->setEditText(name);
        else _comboBox->setCurrentIndex(index);

        //set spin box with vector size
        if (_spinBox != nullptr)
        {
            _spinBox->setValue(dtype.dimension());
        }
    }
Example #2
0
// Copyright (c) 2014-2014 Josh Blum
// SPDX-License-Identifier: BSL-1.0

#include <Pothos/Testing.hpp>
#include <Pothos/Object.hpp>
#include <Pothos/Framework/DType.hpp>
#include <Pothos/Framework/Exception.hpp>
#include <iostream>

POTHOS_TEST_BLOCK("/framework/tests", test_dtype)
{
    Pothos::DType nullType;
    POTHOS_TEST_EQUAL(nullType.name(), std::string());
    POTHOS_TEST_EQUAL(nullType.shape().size(), 0);
    POTHOS_TEST_EQUAL(nullType.size(), 0);
    POTHOS_TEST_TRUE(nullType == Pothos::DType());

    Pothos::DType intType("int");
    std::cout << intType.toString() << std::endl;
    POTHOS_TEST_EQUAL(intType.size(), sizeof(int));

    Pothos::DType anotherIntType("signed int");
    std::cout << anotherIntType.toString() << std::endl;
    POTHOS_TEST_TRUE(anotherIntType == intType);

    Pothos::DType anotherOtherIntType(typeid(int));
    std::cout << anotherOtherIntType.toString() << std::endl;
    POTHOS_TEST_TRUE(anotherOtherIntType == intType);

    Pothos::Object justAnotherStringInt("int");
    POTHOS_TEST_TRUE(justAnotherStringInt.convert<Pothos::DType>() == intType);
Example #3
0
/***********************************************************************
 * bound conversions
 **********************************************************************/
static int dtypeIOToHash(const Pothos::DType &in, const Pothos::DType &out)
{
    return in.elemType() | (out.elemType() << 16); //safe assumption, elem type uses only first few bits
}