Manual
18
Developer’s guide - C++, Urbi, Flex, Java - V2.0
robopec
This document is the property of Robopec. The information contained herein may not be used, reproduced or
communicated without its prior written consent.
Ma_classe(const string &n);
// ‘‘Real’’ constructor URBI taking an int and a string
int init(string _IP, int _port);
//A declared function to URBI
int play(string _str);
private:
// client to send orders to URBI
UClient * client;
//Classical function
void do();
// UVar declared to URBI
UVar something;
// Callback function on « something » changes
int somethingChange(UVar& var) ;
};
#endif
Source file: Ma_classe.cpp
#include"Ma_classe.h"
//Declaring our class to URBI
UStart(Ma_classe);
//constructeur declaring init to URBI
Ma_classe::Ma_classe(const string &n):UObject(n
{
UBindFunction(Ma_classe, init) ;
}
//Init function
int Ma_classe::init(string _IP, int _port)
{
// client initialization
client=new urbi::UClient(_IP.c_str(), _port);
//Declaring play to URBI
UBindFunction(Ma_classe, play) ;
//Declare something to URBI
UBindVar(Ma_classe, something) ;
//Création d’une callback sur la variable something
UNotifyChange(something, &Ma_classe::somethingChange);
}
// play function binded to URBI
int Ma_classe ::play(string _str)
{
if(_str==””) do;
else cout<<_str<<endl;
return 1;