当前位置: 首页>>代码示例>>C++>>正文


C++ PropertyBase::getType方法代码示例

本文整理汇总了C++中PropertyBase::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyBase::getType方法的具体用法?C++ PropertyBase::getType怎么用?C++ PropertyBase::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PropertyBase的用法示例。


在下文中一共展示了PropertyBase::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createText

char* tlp_cc tpGetPropertyType(TELHandle handle)
{
    start_try
        PropertyBase* para = castHandle<PropertyBase>(handle, __FUNC__);
        return tlp::createText(para->getType());
    catch_ptr_macro
}
开发者ID:alexdarling,项目名称:telPlugins,代码行数:7,代码来源:telplugins_properties_api.cpp

示例2: composeProperty

    bool composeProperty(const PropertyBag& bag, WeightedSample<T>& weightedSample)
    {
        //log(Debug) << "composeProperty of WeightedSample " << endlog();
        std::string tname = detail::DataSourceTypeInfo<T>::getType();
        if ( bag.getType() == std::string("WeightedSample") ) {
            // Get values of sample
            Property<PropertyBag>* el_bag =  bag.getProperty<PropertyBag>("WeightedSampleValue");

            if(el_bag==NULL){
                // Works for properties in WeightedSample
                PropertyBase* element = bag.getItem( 0 );
                //log(Debug)<<element->getName()<<", "<< element->getDescription()<<endlog();
                Property<T> my_property_t (element->getName(),element->getDescription());
                if(my_property_t.getType()!=element->getType())
                {
                    log(Error)<< "Type of "<< element->getName() << " does not match type of WeightedSample"<< "OR "<<"Could not read WeightedSample Value "<<endlog();
                    return false;
                }
                else{
                    my_property_t.getTypeInfo()->composeType(element->getDataSource(),my_property_t.getDataSource());
                    weightedSample.ValueSet( my_property_t.get());
                }
            }
            else{
                // Works for propertybags in WeightedSample
                const std::string el_bagType = el_bag->getType();
                Property<T > el_p(el_bag->getName(),el_bag->getDescription());
                if(!(el_p.getDataSource()->composeType(el_bag->getDataSource()))){
                    log(Error)<<"Could not compose WeightedSampleValue "<<endlog();
                    return false;
                }
                if(el_p.ready()){
                    weightedSample.ValueSet( el_p.get());
                }else{
                    log(Error)<<"Property of WeightedSampleValue was not ready for use"<<endlog();
                    return false;
                }
            }
            // Get weight of sample
            Property<double>* weightProp =  bag.getProperty<double>("WeightedSampleWeight");

            if(!weightProp)
            {
                log(Error)<< "Error reading weight of WeightedSample"<<endlog();
                return false;
            }
            else{
                weightedSample.WeightSet( weightProp->get());
            }
        }
        else {
            Logger::log() << Logger::Error << "Composing Property< WeightedSample<T> > :"
                          << " type mismatch, got type '"<< bag.getType()
                          << "', expected type "<<tname<<"."<<Logger::endl;
            return false;
        }
        return true;
    };
开发者ID:jeljaik,项目名称:orocos-bfl-berdy,代码行数:58,代码来源:SampleComposition.hpp

示例3: setPropertyValue

void Plugin::setPropertyValue(const string& nameOf, const void* value)
{
    PropertyBase* property = mProperties.getProperty(nameOf);
    if(property)
    {
        string type = property->getType();
        if(type == "bool")
        {
            Property<bool>* prop = dynamic_cast< Property<bool>* >(property);
            const bool* theData = (bool*) value;
            prop->setValue(*theData);
            return;
        }

        if(type == "int")
        {
            Property<int>* prop = dynamic_cast< Property<int>* >(property);
            const int* theData = (int*) value;
            prop->setValue(*theData);
            return;
        }

        if(type == "double")
        {
            Property<double>* prop = dynamic_cast< Property<double>* >(property);
            const double* theData = (double*) value;
            prop->setValue(*theData);
            return;
        }

        if(type == "std::string")
        {
            Property<string>* prop = dynamic_cast< Property<string>* >(property);
            const string* theData = (string*) value;
            prop->setValue(*theData);
            return;
        }

        if(type == "telluriumData")
        {
            Property<TelluriumData>* prop = dynamic_cast< Property<TelluriumData>* >(property);
            const TelluriumData* theData = (TelluriumData*) value;
            prop->setValue(*theData);
            return;
        }

        if(type == "listOfProperties")
        {
            Property<Properties>* props = dynamic_cast< Property<Properties>* >(property);
            const Properties* theData = (Properties*) value;
            props->setValue(*theData);
            return;
        }

        stringstream msg;
        msg<<"Conversion of property of type: \""<<type<<" is not implemented";
        throw(Exception(msg.str()));
    }

    stringstream msg;
    msg<<"Failed setting property value; No property with name: "<<nameOf;
    throw(Exception(msg.str()));
}
开发者ID:alexdarling,项目名称:telPlugins,代码行数:63,代码来源:telPlugin.cpp


注:本文中的PropertyBase::getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。