Urbi SDK Remote for C++  2.7.5
machine.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009-2011, Gostai S.A.S.
00003  *
00004  * This software is provided "as is" without warranty of any kind,
00005  * either expressed or implied, including but not limited to the
00006  * implied warranties of fitness for a particular purpose.
00007  *
00008  * See the LICENSE file for more information.
00009  */
00010 
00011 // A wrapper around Boost.Foreach.
00012 #include <libport/foreach.hh>
00013 
00014 #include "machine.hh"
00015 
00016 Machine::Machine(float d)
00017   : duration(d)
00018 {
00019   assert(0 <= d);
00020 }
00021 
00022 std::string
00023 Machine::operator()(const strings& components) const
00024 {
00025   // Waiting for duration seconds.
00026   useconds_t one_second = 1000 * 1000;
00027   usleep(useconds_t(duration * one_second));
00028 
00029   // Iterate over the list of strings (using Boost.Foreach), and
00030   // concatenate them in res.
00031   std::string res;
00032   foreach (const std::string& s, components)
00033     res += s;
00034   return res;
00035 }