本文整理汇总了C++中Bottle::read方法的典型用法代码示例。如果您正苦于以下问题:C++ Bottle::read方法的具体用法?C++ Bottle::read怎么用?C++ Bottle::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bottle
的用法示例。
在下文中一共展示了Bottle::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_surface_mesh
bool test_surface_mesh() {
printf("\n*** test_surface_mesh()\n");
SurfaceMesh mesh;
Box3D bb;
mesh.meshName = "testing";
bb.corners.push_back(PointXYZ(1,2,3));
SurfaceMeshWithBoundingBox obj(mesh,bb);
Bottle bot;
bot.read(obj);
SurfaceMeshWithBoundingBox obj2;
bot.write(obj2);
Bottle bot2;
bot2.read(obj2);
printf("mesh copy: %s -> %s\n", bot.toString().c_str(),
bot2.toString().c_str());
if (obj2.mesh.meshName!=obj.mesh.meshName) {
printf("mesh name not copied correctly\n");
return false;
}
if (obj2.boundingBox.corners.size()!=obj.boundingBox.corners.size()) {
printf("corners not copied correctly\n");
return false;
}
if (bot!=bot2) {
printf("not copied correctly\n");
return false;
}
return true;
}
示例2: read
//********************************************
bool read(ConnectionReader &connection)
{
Bottle input;
input.read(connection);
if (input.size()>=7)
{
string arm=input.get(0).asString().c_str();
transform(arm.begin(),arm.end(),arm.begin(),::tolower);
mutex.lock();
map<string,Data>::iterator it=data.find(arm);
if (it!=data.end())
{
Data &d=it->second;
d.point[0]=input.get(1).asDouble();
d.point[1]=input.get(2).asDouble();
d.point[2]=input.get(3).asDouble();
d.dir[0]=input.get(4).asDouble();
d.dir[1]=input.get(5).asDouble();
d.dir[2]=input.get(6).asDouble();
d.persistence=PPS_AVOIDANCE_PERSISTENCE;
d.timeout=PPS_AVOIDANCE_TIMEOUT;
}
mutex.unlock();
}
return true;
}
示例3: read
virtual bool read(ConnectionReader& connection) {
Bottle b;
b.read(connection);
// process data in b
printf("Got %s\n", b.toString().c_str());
if(waitForFirst) {
xKeep = b.get(0).asInt();
yKeep = b.get(1).asInt();
waitForFirst = false;
} else {
if((b.get(0).asInt()<xKeep)||(b.get(1).asInt()<yKeep)){
x = 0;
y = 0;
w = 0;
h = 0;
} else {
x = xKeep;
y = yKeep;
w = b.get(0).asInt() - x;
h = b.get(1).asInt() - y;
}
waitForFirst = true;
}
return true;
}
示例4: read
virtual bool read(ConnectionReader& reader) override {
go.wait();
mutex.lock();
bool ok = last.read(reader);
mutex.unlock();
gone.post();
return ok;
}
示例5: read
virtual bool read(ConnectionReader& reader) {
go.wait();
mutex.wait();
bool ok = last.read(reader);
mutex.post();
gone.post();
return ok;
}
示例6: read
virtual bool read(ConnectionReader& connection) {
Bottle receive;
receive.read(connection);
receive.addInt(5);
ConnectionWriter *writer = connection.getWriter();
if (writer!=NULL) {
receive.write(*writer);
}
return true;
}
示例7: testSerialCopy
void testSerialCopy() {
report(0,"test serialization by copy");
Value v(3.14);
Bottle b;
b.read(v);
checkEqualish(b.get(0).asDouble(),3.14,"copy to bottle succeeded");
Bottle b2;
b.write(b2);
checkEqualish(b2.get(0).asDouble(),3.14,"copy from bottle succeeded");
}
示例8: checkReadWrite
void checkReadWrite() {
report(0,"check read/write");
Value v(4.2);
Bottle b;
b.read(v);
checkTrue(b.get(0).isFloat64(),"structure ok");
checkEqualish(b.get(0).asFloat64(),4.2,"value ok");
Value v2;
b.write(v2);
checkEqualish(v2.asFloat64(),4.2,"value reread ok");
}
示例9: read
bool read(ConnectionReader &connection)
{
Bottle data; data.read(connection);
if (data.size()>=2)
{
LockGuard lg(mutex);
cv::Point point(data.get(0).asInt(),data.get(1).asInt());
contour.push_back(point);
}
return true;
}
示例10: read
virtual bool read(ConnectionReader& con) {
Bottle b;
if (!b.read(con)) {
return false;
}
ConstString src = con.getRemoteContact().getName();
ConstString txt = b.get(0).asString();
printf("Reading [%s] from [%s]\n", txt.c_str(), src.c_str());
if (src!=txt) {
printf("YIKES!!!\n");
exit(1);
}
return true;
}
示例11: convertTextMode
bool StreamConnectionReader::convertTextMode() {
if (isTextMode()) {
if (!convertedTextMode) {
Bottle bot;
bot.read(*this);
BufferedConnectionWriter writer;
bot.write(writer);
String s = writer.toString();
altStream.reset(s);
in = &altStream;
convertedTextMode = true;
}
}
return true;
}
示例12: read
//********************************************
bool read(ConnectionReader &connection)
{
Bottle in;
in.read(connection);
if (in.size()>=1)
{
Bottle input;
input=*(in.get(0).asList());
if (input.size()>=7)
{
yDebug("[demoAvoidance] got command (%s)",input.toString().c_str());
string arm=iCub::skinDynLib::SkinPart_s[input.get(0).asInt()];
if (arm == "r_hand" || arm == "r_forearm")
{
arm = "right";
}
else if (arm == "l_hand" || arm == "l_forearm")
{
arm = "left";
}
transform(arm.begin(),arm.end(),arm.begin(),::tolower);
mutex.lock();
map<string,Data>::iterator it=data.find(arm);
if (it!=data.end())
{
Data &d=it->second;
d.point[0]=input.get(7).asDouble();
d.point[1]=input.get(8).asDouble();
d.point[2]=input.get(9).asDouble();
d.dir[0]=input.get(10).asDouble();
d.dir[1]=input.get(11).asDouble();
d.dir[2]=input.get(12).asDouble();
d.persistence=PPS_AVOIDANCE_PERSISTENCE;
d.timeout=PPS_AVOIDANCE_TIMEOUT;
}
mutex.unlock();
}
}
return true;
}
示例13: read
bool NetworkClock::read(ConnectionReader& reader) {
Bottle bot;
bool ok = bot.read(reader);
if(closing)
{
_time = -1;
return false;
}
if (!ok && !closing)
{
YARP_ERROR(Logger::get(), "Error reading clock port");
return false;
}
timeMutex.lock();
sec = bot.get(0).asInt32();
nsec = bot.get(1).asInt32();
_time = sec + (nsec*1e-9);
initted = true;
timeMutex.unlock();
listMutex.lock();
Waiters* waiters = static_cast<Waiters*>(pwaiters);
Waiters::iterator waiter_i;
waiter_i = waiters->begin();
while (waiter_i != waiters->end())
{
if (waiter_i->first - _time < 1E-12 )
{
Semaphore *waiterSemaphore = waiter_i->second;
waiter_i = waiters->erase(waiter_i);
if (waiterSemaphore)
waiterSemaphore->post();
}
else
++waiter_i;
}
listMutex.unlock();
return true;
}
示例14: load
bool CalibModule::load()
{
string fileName=rf->findFile("calibrationFile").c_str();
if (fileName.empty())
{
yWarning("calibration file not found");
return false;
}
Property data; data.fromConfigFile(fileName.c_str());
Bottle b; b.read(data);
mutex.lock();
yInfo("loading experts from file: %s",fileName.c_str());
for (int i=0; i<b.size(); i++)
factory(b.get(i));
mutex.unlock();
return true;
}
示例15: read
virtual bool read(ConnectionReader& connection) {
double now = Time::now();
Bottle b;
bool ok = b.read(connection);
if (ok) {
mutex.wait();
ct++;
if (ct>1) {
double dt = now - lastTime;
period.add(dt);
}
lastTime = now;
printf("Period is %g +/- %g (%d)\n",
period.mean(),
period.deviation(),
ct);
mutex.post();
}
return ok;
}