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


C++ Bottle::addString方法代码示例

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


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

示例1: respond

    /*
    * Message handler. Just echo all received messages.
    */
    bool respond(const Bottle& command, Bottle& reply) 
    {
        cout<<"Got "<<command.toString().c_str()<<endl;

        if(command.size() < 3) {
            reply.addString("Command error! example: 'sum 3 4'");
            return true;
        }
        int a = command.get(1).asInt();
        int b = command.get(2).asInt();

        if( command.get(0).asString() == "sum") {
           int c = sum(a, b);
            reply.addInt(c);
            return true;
        }

        if( command.get(0).asString() == "sub") {
            int c = sub(a, b);
            reply.addInt(c);
            return true;
        }

        reply.addString("Unknown command");
        reply.addString(command.get(0).asString().c_str());
        return true;
    }
开发者ID:iron76,项目名称:Teaching,代码行数:30,代码来源:module.cpp

示例2: respond

bool PARTICLEModule::respond(const Bottle& command, Bottle& reply) 
{
    string helpMessage =  string(getName().c_str()) + 
                        " commands are: \n" +  
                        "help \n" + 
                        "quit \n";

    reply.clear(); 

    if (command.get(0).asString()=="quit") 
    {
        reply.addString("quitting");
        return false;     
    }
    else if (command.get(0).asString()=="help") 
    {
        cout << helpMessage;
        reply.addString("ok");
    }
    else if (command.get(0).asString()=="reset") 
    {
        cout << "reset has been asked "<< endl;
        particleManager->shouldSend=false;
        reply.addString("ok");
    }
    else
    {
		cout << "command not known - type help for more info" << endl;
	}
    return true;
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:31,代码来源:particleFilter.cpp

示例3: DumpHumanObject

/*
*   Dump in the port DumperPort the human skeleton, and the object of the OPC: sObjectToDump
*
*/
void humanRobotDump::DumpHumanObject()
{
    Agent* ag = iCub->opc->addOrRetrieveEntity<Agent>(sAgentName);

    Bottle bDump;
    bDump.addString(sActionName);
    bDump.addString(sObjectToDump);
    bDump.addList() = ag->m_body.asBottle();

    iCub->opc->checkout();
    list<Entity*> lEntity = iCub->opc->EntitiesCacheCopy();
    for (list<Entity*>::iterator itEnt = lEntity.begin(); itEnt != lEntity.end(); itEnt++)
    {
        if ((*itEnt)->entity_type() == EFAA_OPC_ENTITY_AGENT ||
            (*itEnt)->entity_type() == EFAA_OPC_ENTITY_OBJECT ||
            (*itEnt)->entity_type() == EFAA_OPC_ENTITY_RTOBJECT)
        {
            if ((*itEnt)->name() != "icub")
            {
                Object* ob = iCub->opc->addOrRetrieveEntity<Object>((*itEnt)->name());
                Bottle bObject;
                bObject.addString(ob->name());
                bObject.addDouble(ob->m_ego_position[0]);
                bObject.addDouble(ob->m_ego_position[1]);
                bObject.addDouble(ob->m_ego_position[2]);
                bObject.addInt(ob->m_present);
                bDump.addList() = bObject;
            }
        }
    }

    bDump.addInt(m_iterator);
    
    DumperPort.write(bDump);
}
开发者ID:GunnyPong,项目名称:wysiwyd,代码行数:39,代码来源:humanRobotDump.cpp

示例4: respond

    // rpcPort commands handler
    bool respond(const Bottle &      command,
                 Bottle &      reply)
    {
        // This method is called when a command string is sent via RPC

        // Get command string
        string receivedCmd = command.get(0).asString().c_str();
        reply.clear();  // Clear reply bottle
        
        if (receivedCmd == "help")
        {
            reply.addVocab(Vocab::encode("many"));
            reply.addString("Available commands are:");
            reply.addString("help");
            reply.addString("quit");
        }
        else if (receivedCmd == "quit")
        {
            reply.addString("Quitting.");
            return false; //note also this
        }
        else
            reply.addString("Invalid command, type [help] for a list of accepted commands.");

        return true;
    }
开发者ID:GiuliaP,项目名称:iRRLS,代码行数:27,代码来源:parametricEstimator.cpp

示例5: asBottle

Bottle Action::asBottle()
{
    Bottle b = this->Entity::asBottle();
    Bottle bSub;
    bSub.addString("description");
    bSub.addList() = initialDescription.asBottle();
    b.addList() = bSub;
    bSub.clear();
    bSub.addString("subactions");
    Bottle& subs = bSub.addList();
    for(list<Action>::iterator sIt = subActions.begin() ; sIt != subActions.end(); sIt++)
    {
        subs.addList()=sIt->asBottle();
    }
    b.addList() = bSub;
        
    bSub.clear();
    bSub.addString("estimatedDriveEffects");
    Bottle &subss = bSub.addList();
    for(map<string, double>::iterator sIt = estimatedDriveEffects.begin() ; sIt != estimatedDriveEffects.end(); sIt++)
    {
        Bottle &ss = subss.addList();
        ss.addString(sIt->first.c_str());
        ss.addDouble(sIt->second);
    }
    b.addList() = bSub;
    return b;
}
开发者ID:caomw,项目名称:wysiwyd,代码行数:28,代码来源:action.cpp

示例6: connectOPC

Bottle abmReasoning::connectOPC(Bottle bInput)
{
    Bottle bOutput;

    if (bInput.size() != 2)
    {
        bOutput.addString("Error in connect, wrong number of input");
    }

    if (!bInput.get(1).isString())
    {
        bOutput.addString("Error in connect, wrong format of input");
    }

    string sPortTemp = moduleName + "/" + abmReasoningFunction::s_realOPC;
    realOPC = new OPCClient(sPortTemp.c_str());
    int iTry = 0;
    while (!realOPC->isConnected())
    {
        yInfo() << "\t" << "abmReasoning Connecting to " << abmReasoningFunction::s_realOPC << "..." << realOPC->connect(abmReasoningFunction::s_realOPC);
        if (!realOPC->isConnected())
            Time::delay(0.5);
        iTry++;
        if (iTry > 1)
        {
            yInfo() << "\t" << "abmReasoning failed to connect to " << abmReasoningFunction::s_realOPC;
            bOutput.addString("Connection failed, please check your port");
            break;
        }
    }

    if (realOPC->isConnected())
    {
        realOPC->checkout();
        realOPC->update();
    }

    sPortTemp = moduleName + "/" + abmReasoningFunction::s_mentalOPC;
    mentalOPC = new OPCClient(sPortTemp.c_str());
    iTry = 0;
    while (!mentalOPC->isConnected())
    {
        yInfo() << "\t" << "abmReasoning Connecting to " << abmReasoningFunction::s_mentalOPC << "..." << mentalOPC->connect(abmReasoningFunction::s_mentalOPC);
        if (!mentalOPC->isConnected())
            Time::delay(0.5);
        iTry++;
        if (iTry > 1)
        {
            yInfo() << "\t" << "abmReasoning failed to connect to " << abmReasoningFunction::s_mentalOPC;
            bOutput.addString("Connection failed, please check your port");
            return bOutput;
        }
        mentalOPC->isVerbose = false;
    }
    mentalOPC->checkout();
    mentalOPC->update();

    bOutput.addString("Connection done");
    return bOutput;
}
开发者ID:GunnyPong,项目名称:wysiwyd,代码行数:60,代码来源:abmReasoning.cpp

示例7: initHead

Bottle PMPthread::initHead(Bottle angles)
{
	Bottle reply;
	reply.clear();

	string msg;

	//check if the connection is established. If not, try to connect to DevDriver input ports
	if (!Network::exists(("/" + rpcServerName + "/rpc").c_str()) )
	{
		//printf("Error: device ports not active\n");
		reply.addString("Error: device ports not active");
		return reply;
	}
	if( !Network::isConnected(rpcPort.getName().c_str(), ("/" + rpcServerName + "/rpc").c_str()) )
	{
		if(!Network::connect(rpcPort.getName().c_str(), ("/" + rpcServerName + "/rpc").c_str()) )
		{
			//printf("Error: unable to connect to device port %s\n", ("/" + rpcServerName + "/head:i").c_str());
			msg = "Error: unable to connect to device port /" + rpcServerName + "/rpc";
			reply.addString(msg.c_str());
			return reply;
		}
	}

	//cout << "thread: " << angles.toString() << endl;

	updateSem.wait();
	rpcPort.write(angles,reply);
	//cout << "out of thread!!!!!!!" << endl;

	updateSem.post();
	return reply;
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:34,代码来源:PMPthread.cpp

示例8: respond

bool ImageSource::respond(const Bottle& command, Bottle& reply) 
{
  string helpMessage =  string(getName().c_str()) + 
                        " commands are: \n" +  
                        "help \n" + 
                        "quit \n" + 
                        "set noise <n> ... set the noise level \n" + 
                        "(where <n> is an integer number in the range 0-255) \n";

  reply.clear(); 

  if (command.get(0).asString()=="quit") {
       reply.addString("quitting");
       return false;     
   }
   else if (command.get(0).asString()=="help") {
      cout << helpMessage;
      reply.addString("ok");
   }
   else if (command.get(0).asString()=="set") {
      if (command.get(1).asString()=="noise") {
         noiseLevel = command.get(2).asInt(); // set parameter value
         reply.addString("ok");
      }
   }
   return true;
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:27,代码来源:imageSource.cpp

示例9: makeObjectBottle

Bottle SimSBox::makeObjectBottle(vector<int>& ind, bool collision) {

    Bottle cmd;
    cmd.addString("world");
    cmd.addString("mk");
    cmd.addString("sbox");
    cmd.addDouble(sizeX);
    cmd.addDouble(sizeY);
    cmd.addDouble(sizeZ);
    cmd.addDouble(positionX);
    cmd.addDouble(positionY);
    cmd.addDouble(positionZ);
    cmd.addDouble(colorR);
    cmd.addDouble(colorG);
    cmd.addDouble(colorB);
    if (collision == false) {
        cmd.addString("false");
	cout << "Collision with Static box set to False" <<  endl;
    }

    ind[SBOX]++;
    objSubIndex=ind[SBOX];

    return cmd;
}
开发者ID:tanismar,项目名称:affordances,代码行数:25,代码来源:simtoolloader.cpp

示例10: requestTopic

    void requestTopic(NodeArgs& na)
    {
        std::string topic = na.args.get(0).asString();
        topic = fromRosName(topic);
        std::vector<Contact> contacts = query(topic, "+");
        if (contacts.size() < 1) {
            na.fail("Cannot find topic");
            return;
        }
        for (std::vector<Contact>::iterator it = contacts.begin(); it != contacts.end(); ++it) {
            Contact &c = *it;

            if (!c.isValid()) {
                continue;
            }
            Value v;
            Bottle* lst = v.asList();
            lst->addString("TCPROS");
            lst->addString(c.getHost());
            lst->addInt32(c.getPort());
            na.reply = v;
            na.success();
            return;
        }
        na.fail("Cannot find topic");
    }
开发者ID:claudiofantacci,项目名称:yarp,代码行数:26,代码来源:Node.cpp

示例11: respond

bool demoModule::respond(const Bottle& command, Bottle& reply) {
  string helpMessage =  string(getName().c_str()) + 
                        " commands are: \n" +  
                        "help \n" + 
                        "quit \n" + 
                        "set thr <n> ... set the threshold \n" + 
                        "(where <n> is an integer number) \n";

  reply.clear(); 

  if (command.get(0).asString()=="quit") {
       reply.addString("quitting");
       return false;     
   }
   else if (command.get(0).asString()=="help") {
      cout << helpMessage;
      reply.addString("ok");
   }
   else if (command.get(0).asString()=="set") {
      if (command.get(1).asString()=="thr") {
         thresholdValue = command.get(2).asInt(); // set parameter value
         reply.addString("ok");
      }
   }
   return true;
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:26,代码来源:demoModule.cpp

示例12: respond

    bool respond(const Bottle &command, Bottle &reply)
    {
        int cmd0=command.get(0).asVocab();
        if (cmd0==Vocab::encode("stat"))
        {
            reply.addString(speaker.isSpeaking()?"speaking":"quiet");
            return true;
        }

        if (command.size()>1)
        {
            int cmd1=command.get(1).asVocab();
            if (cmd1==Vocab::encode("opt"))
            {
                if (cmd0==Vocab::encode("get"))
                {
                    reply.addString(speaker.get_package_options().c_str());
                    return true;
                }

                if (cmd0==Vocab::encode("set"))
                {
                    string cmd2=command.get(2).asString().c_str();
                    speaker.set_package_options(cmd2);
                    reply.addString("ack");
                    return true;
                }
            }
        }

        return RFModule::respond(command,reply);
    }
开发者ID:francesco-romano,项目名称:icub-main,代码行数:32,代码来源:main.cpp

示例13: addObject

void GuiUpdaterModule::addObject(Object* o, const string &opcTag)
{
    //Get the position of the object in the current reference frame of the robot (not the initial one)
    Vector inCurrentRootReference = iCub->getSelfRelativePosition(o->m_ego_position);
    //cout<<o->name()<<" init Root: \t \t"<<o->m_ego_position.toString(3,3)<<endl
    //    <<o->name()<<" current Root: \t \t"<<inCurrentRootReference.toString(3,3)<<endl;

    Bottle cmd;
    cmd.addString("object");
    cmd.addString(opcTag.c_str());
                                
    cmd.addDouble(o->m_dimensions[0] *1000.0);    // dimX in [mm]
    cmd.addDouble(o->m_dimensions[1] *1000.0);    // dimY in [mm]
    cmd.addDouble(o->m_dimensions[2] *1000.0);    // dimZ in [mm]
    cmd.addDouble(inCurrentRootReference[0] *1000.0);        // posX in [mm]
    cmd.addDouble(inCurrentRootReference[1] *1000.0);        // posY in [mm]
    cmd.addDouble(inCurrentRootReference[2] *1000.0);        // posZ in [mm]
    cmd.addDouble(o->m_ego_orientation[0] - iCub->m_ego_orientation[0]);             // Deal with the object orientation that is moving with the base
    cmd.addDouble(o->m_ego_orientation[1] - iCub->m_ego_orientation[1]);             // "
    cmd.addDouble(o->m_ego_orientation[2] - iCub->m_ego_orientation[2]);              // "
    cmd.addInt((int)o->m_color[0]);            // color R
    cmd.addInt((int)o->m_color[1]);            // color G
    cmd.addInt((int)o->m_color[2]);            // color B
    cmd.addDouble(1);                     // alpha coefficient [0,1]
    toGui.write(cmd);
}
开发者ID:MagnusJohnsson,项目名称:wysiwyd,代码行数:26,代码来源:world.cpp

示例14: sendGuiTarget

void utManagerThread::sendGuiTarget()
{
    if (outPortGui.getOutputCount()>0)
    {
        Bottle obj;
        obj.addString("object");
        obj.addString("utTarget");
     
        // size 
        obj.addDouble(50.0);
        obj.addDouble(50.0);
        obj.addDouble(50.0);
    
        // positions
        obj.addDouble(1000.0*kalOut[0]);
        obj.addDouble(1000.0*kalOut[1]);
        obj.addDouble(1000.0*kalOut[2]);
    
        // orientation
        obj.addDouble(0.0);
        obj.addDouble(0.0);
        obj.addDouble(0.0);
    
        // color
        obj.addInt(255);
        obj.addInt(125);
        obj.addInt(125);
    
        // transparency
        obj.addDouble(0.9);
    
        outPortGui.write(obj);
    }
}
开发者ID:towardthesea,项目名称:peripersonal-space,代码行数:34,代码来源:utManagerThread.cpp

示例15: respond

bool visualFilterModule::respond(const Bottle& command, Bottle& reply) 
{
    string helpMessage =  string(getName().c_str()) + 
                        " commands are: \n" +  
                        "help \n" + 
                        "quit \n" + 
                        "par  <n> <d> ... set parameter's value \n" + 
                        "(where <n> and <d> are an integer and a double respectively) \n";

    reply.clear(); 

    if (command.get(0).asString()=="quit") {
        reply.addString("quitting");
        return false;     
    }
    else if (command.get(0).asString()=="help") {
        cout << helpMessage;
        reply.addString("ok");
    }
	else if (command.get(0).asString()=="par") {
		int p = command.get(1).asInt();
		double v = command.get(2).asDouble();
		if(p>0 && p<8 && v>=0){
			vfThread->setPar(p,v);
			reply.addString("New kernel generated with updated parameters.");
		}
		else {
			reply.addString("Invalid values");
		}
    	}
    return true;
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:32,代码来源:visualFilterModule.cpp


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