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


C++ Computer::addPeripheral方法代码示例

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


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

示例1: updateResources

bool Manager::updateResources(void)
{
    YarpBroker broker;
    broker.init();

    // finding all available yarp ports
    vector<string> ports;
    broker.getAllPorts(ports);

    ResourcePContainer allresources = knowledge.getResources();
    for(unsigned int i=0; i<allresources.size(); i++)
    {
        Computer* comp = dynamic_cast<Computer*>(allresources[i]);
        if(updateResource(comp))
        {
            //set all as unavailable
            for(int i=0; i<comp->peripheralCount(); i++)
            {
                ResYarpPort* res =
                    dynamic_cast<ResYarpPort*>(&comp->getPeripheralAt(i));
                if(res)
                    res->setAvailability(false);
            }

            // adding all available yarp ports as peripherals
            for(unsigned int i=0; i<ports.size(); i++)
            {
                ResYarpPort resport;
                resport.setName(ports[i].c_str());
                resport.setPort(ports[i].c_str());

                bool bfound = false;
                for(int i=0; i<comp->peripheralCount(); i++)
                {
                    ResYarpPort* res =
                        dynamic_cast<ResYarpPort*>(&comp->getPeripheralAt(i));
                    if(res && (string(res->getName()) == string(resport.getName())))
                    {
                        res->setAvailability(true);
                        bfound = true;
                        break;
                    }
                }
                if(!bfound)
                    comp->addPeripheral(resport);
            }
        }
    } // end of for

    return true;
}
开发者ID:lessc0de,项目名称:yarp,代码行数:51,代码来源:manager.cpp

示例2: parsXml


//.........这里部分代码省略.........
                        if((element = (TiXmlElement*) comptag->FirstChild("cores")))
                            proc.setCores((size_t)atoi(parser->parseText(element->GetText()).c_str()));
                        if((element = (TiXmlElement*) comptag->FirstChild("siblings")))
                            proc.setSiblings((size_t)atoi(parser->parseText(element->GetText()).c_str()));
                        if((element = (TiXmlElement*) comptag->FirstChild("frequency")))
                            proc.setFrequency(atof(parser->parseText(element->GetText()).c_str()));
                        computer.setProcessor(proc);
                    } // end of processor tag

                    // network
                    if(compareString(comptag->Value(), "network"))
                    {
                        Network net;
                        TiXmlElement* element;
                        if((element = (TiXmlElement*) comptag->FirstChild("ip4")))
                            net.setIP4(parser->parseText(element->GetText()).c_str());
                        if((element = (TiXmlElement*) comptag->FirstChild("ip6")))
                            net.setIP6(parser->parseText(element->GetText()).c_str());
                        if((element = (TiXmlElement*) comptag->FirstChild("mac")))
                            net.setMAC(parser->parseText(element->GetText()).c_str());
                        module.addResource(net);
                        computer.setNetwork(net);
                    } // end of network tag

                    // yarp_port
                    if(compareString(comptag->Value(), "yarp_port"))
                    {
                        ResYarpPort yport;
                        auto* element = (TiXmlElement*) comptag->FirstChild("name");
                        if(element && element->GetText())
                        {
                            yport.setName(parser->parseText(element->GetText()).c_str());
                            yport.setPort(parser->parseText(element->GetText()).c_str());
                            computer.addPeripheral(yport);
                        }
                        else
                        {
                            OSTRINGSTREAM war;
                            war<<"yarp_port from "<<szFile<<" at line " <<comptag->Row()<<" has no name.";
                            logger->addWarning(war);
                        }
                    }

                    // gpu
                    if(compareString(comptag->Value(), "gpu"))
                    {
                        GPU gpu;
                        TiXmlElement* element;
                        if((element = (TiXmlElement*) comptag->FirstChild("name")))
                            gpu.setName(parser->parseText(element->GetText()).c_str());
                        if((element = (TiXmlElement*) comptag->FirstChild("capability")))
                            gpu.setCompCompatibility(parser->parseText(element->GetText()).c_str());
                        if((element = (TiXmlElement*) comptag->FirstChild("cores")))
                            gpu.setCores((size_t)atoi(parser->parseText(element->GetText()).c_str()));
                        if((element = (TiXmlElement*) comptag->FirstChild("frequency")))
                            gpu.setFrequency(atof(parser->parseText(element->GetText()).c_str()));
                        if((element = (TiXmlElement*) comptag->FirstChild("register_block")))
                            gpu.setResgisterPerBlock((size_t)atoi(parser->parseText(element->GetText()).c_str()));
                        if((element = (TiXmlElement*) comptag->FirstChild("thread_block")))
                            gpu.setThreadPerBlock((size_t)atoi(parser->parseText(element->GetText()).c_str()));
                        if((element = (TiXmlElement*) comptag->FirstChild("overlap")))
                        {
                            if(compareString(parser->parseText(element->GetText()).c_str(), "yes"))
                                gpu.setOverlap(true);
                            else
                                gpu.setOverlap(false);
开发者ID:robotology,项目名称:yarp,代码行数:67,代码来源:xmlmodloader.cpp

示例3: parsXml


//.........这里部分代码省略.........
                {
                    Storage stg;
                    TiXmlElement* element;
                    if((element = (TiXmlElement*) comptag->FirstChild("total_space")))
                        stg.setTotalSpace((Capacity)atol(element->GetText()));               
                   computer.setStorage(stg);
                } // end of storage tag

                // processor
                if(compareString(comptag->Value(), "processor"))
                {
                    Processor proc;
                    TiXmlElement* element;
                    if((element = (TiXmlElement*) comptag->FirstChild("architecture")))
                        proc.setArchitecture(element->GetText());
                    if((element = (TiXmlElement*) comptag->FirstChild("model")))
                        proc.setModel(element->GetText());
                    if((element = (TiXmlElement*) comptag->FirstChild("cores")))
                        proc.setCores((size_t)atoi(element->GetText()));               
                    if((element = (TiXmlElement*) comptag->FirstChild("frequency")))
                        proc.setFrequency(atof(element->GetText()));
                   computer.setProcessor(proc);
                } // end of processor tag

                // network
                if(compareString(comptag->Value(), "network"))
                {
                    Network net;
                    TiXmlElement* element;
                    if((element = (TiXmlElement*) comptag->FirstChild("ip4")))
                        net.setIP4(element->GetText());
                    if((element = (TiXmlElement*) comptag->FirstChild("ip6")))
                        net.setIP6(element->GetText());
                    if((element = (TiXmlElement*) comptag->FirstChild("mac")))
                        net.setMAC(element->GetText());
                    computer.setNetwork(net);
                } // end of network tag


                // gpu
                if(compareString(comptag->Value(), "gpu"))
                {
                    GPU gpu;
                    TiXmlElement* element;
                    if((element = (TiXmlElement*) comptag->FirstChild("name")))
                        gpu.setName(element->GetText());
                    if((element = (TiXmlElement*) comptag->FirstChild("capability")))
                        gpu.setCompCompatibility(element->GetText());
                    if((element = (TiXmlElement*) comptag->FirstChild("cores")))
                        gpu.setCores((size_t)atoi(element->GetText()));
                    if((element = (TiXmlElement*) comptag->FirstChild("frequency")))
                        gpu.setFrequency(atof(element->GetText()));
                    if((element = (TiXmlElement*) comptag->FirstChild("register_block")))
                        gpu.setResgisterPerBlock((size_t)atoi(element->GetText()));
                    if((element = (TiXmlElement*) comptag->FirstChild("thread_block")))
                        gpu.setThreadPerBlock((size_t)atoi(element->GetText()));
                    if((element = (TiXmlElement*) comptag->FirstChild("overlap")))
                    {
                        if(compareString(element->GetText(), "yes"))
                            gpu.setOverlap(true);
                        else
                            gpu.setOverlap(false);
                    }
                 
                    // global memory
                    if(comptag->FirstChild("global_memory"))
                    {
                        TiXmlElement* element;
                        element = (TiXmlElement*) comptag->FirstChild("global_memory");
                        if((element = (TiXmlElement*) element->FirstChild("total_space")))
                            gpu.setGlobalMemory((Capacity)atol(element->GetText()));            
                    } // end of global memory tag

                    // shared memory
                    if(comptag->FirstChild("shared_memory"))
                    {
                        TiXmlElement* element;
                        element = (TiXmlElement*) comptag->FirstChild("shared_memory");
                        if((element = (TiXmlElement*) element->FirstChild("total_space")))
                            gpu.setSharedMemory((Capacity)atol(element->GetText()));            
                    } // end of shared memory tag

                    // constant memory
                    if(comptag->FirstChild("constant_memory"))
                    {
                        TiXmlElement* element;
                        element = (TiXmlElement*) comptag->FirstChild("constant_memory");
                        if((element = (TiXmlElement*) element->FirstChild("total_space")))
                            gpu.setConstantMemory((Capacity)atol(element->GetText()));            
                    } // end of shared memory tag

                   computer.addPeripheral(gpu);
                } // end of gpu tag
            } // end of computer loop 

            computers.push_back(computer);
        } // end of if computer
    } // end of resources 
    return true;
}
开发者ID:SibghatullahSheikh,项目名称:yarp,代码行数:101,代码来源:xmlresloader.cpp


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