Exemplo n.º 1
0
std::shared_ptr< ConfigValue > TypelibConfiguration::getFromContainer(Typelib::Value& value)
{
    const Typelib::Container &cont = static_cast<const Typelib::Container &>(value.getType());
    const size_t size = cont.getElementCount(value.getData());
    
    if(cont.kind() == "/std/string")
    {
        const std::string *content = static_cast<const std::string *>(value.getData());

        std::shared_ptr<SimpleConfigValue> config(new SimpleConfigValue(*content));
        config->setCxxTypeName(value.getType().getName());
        return config;
    }
    
    //std::vector
    std::shared_ptr<ArrayConfigValue> array(new ArrayConfigValue());
    array->setCxxTypeName(value.getType().getName());
    for(size_t i = 0; i < size; i++)
    {
        Typelib::Value elem = cont.getElement(value.getData(), i);
        array->addValue(getFromValue(elem));
    }

    return array;
}
Exemplo n.º 2
0
std::shared_ptr< ConfigValue > TypelibConfiguration::getFromArray(Typelib::Value& value)
{
    std::shared_ptr<ArrayConfigValue> config(new ArrayConfigValue());

    const Typelib::Array &array = static_cast<const Typelib::Array &>(value.getType());
    config->setCxxTypeName(array.getName());
    
    void *data = value.getData();
    
    const Typelib::Type &indirect(array.getIndirection());
    
    for(size_t i = 0; i < array.getDimension(); i++)
    {
        Typelib::Value arrayV(static_cast<uint8_t *>(data) + i * indirect.getSize(), indirect);
        config->addValue(getFromValue(arrayV));
    }
    
    return config;
}
Exemplo n.º 3
0
std::shared_ptr< ConfigValue > TypelibConfiguration::getFromCompound(Typelib::Value& value)
{
    std::shared_ptr<ComplexConfigValue> config(new ComplexConfigValue());
    
    config->setCxxTypeName(value.getType().getName());
    
    const Typelib::Compound &comp = static_cast<const Typelib::Compound &>(value.getType());
     
    uint8_t *data = static_cast<uint8_t *>( value.getData());
    
    for(const Typelib::Field &field: comp.getFields())
    {
        Typelib::Value fieldV(data + field.getOffset(), field.getType());
        std::shared_ptr< ConfigValue > convV = getFromValue(fieldV);
        convV->setName(field.getName());
        config->addValue(field.getName(), convV);
    }
    
    return config;
}
Exemplo n.º 4
0
std::string getValue(const Typelib::Value& value)
{
    T *val = static_cast<T *>(value.getData());
    return  boost::lexical_cast<std::string>(*val);
}
Exemplo n.º 5
0
std::shared_ptr< ConfigValue > TypelibConfiguration::getFromEnum(Typelib::Value& value)
{
    const Typelib::Enum &enumT = static_cast<const Typelib::Enum &>(value.getType());
    
    Typelib::Enum::integral_type *intVal = (static_cast<Typelib::Enum::integral_type *>(value.getData()));
    
    std::shared_ptr<SimpleConfigValue> config(new SimpleConfigValue(enumT.get(*intVal)));
    config->setCxxTypeName(enumT.getName());
    
    return config;
}
void TypelibMarshallerBase::setTypelibSample(Handle* data, Typelib::Value typelib_data, bool refresh_orocos)
{ return setTypelibSample(data, reinterpret_cast<uint8_t*>(typelib_data.getData()), refresh_orocos); }