diff --git a/doc/release/master.md b/doc/release/master.md index ebf9850dc1..7e6da71490 100644 --- a/doc/release/master.md +++ b/doc/release/master.md @@ -35,3 +35,12 @@ New Features * added new datatype `yarp::sig::LayeredImage` * added `yarp::sig::utils::sum()` to transform `yarp::sig::LayeredImage` to `yarp::sig::Image` + +#### `libYARP_dev` + +* added new class `yarp::dev::ReturnValue` +* modified interfaces `yarp::dev::ISpeechSynthesizer`,`yarp::dev::ISpeechTranscription` to use the new class ReturnValue. + +#### `devices` + +* modified devices implementing `yarp::dev::ISpeechSynthesizer`,`yarp::dev::ISpeechTranscription` to use the new class ReturnValue. diff --git a/src/devices/fake/fakeSpeechSynthesizer/FakeSpeechSynthesizer.cpp b/src/devices/fake/fakeSpeechSynthesizer/FakeSpeechSynthesizer.cpp index b2689ccbcb..6470545660 100644 --- a/src/devices/fake/fakeSpeechSynthesizer/FakeSpeechSynthesizer.cpp +++ b/src/devices/fake/fakeSpeechSynthesizer/FakeSpeechSynthesizer.cpp @@ -40,67 +40,67 @@ bool FakeSpeechSynthesizer::close() return true; } -yarp_ret_value FakeSpeechSynthesizer::setLanguage(const std::string& language) +ReturnValue FakeSpeechSynthesizer::setLanguage(const std::string& language) { m_language=language; yCInfo(FAKE_SPEECHSYN) << "Language set to" << language; - return yarp_ret_value_ok; + return ReturnValue_ok; } -yarp_ret_value FakeSpeechSynthesizer::getLanguage(std::string& language) +ReturnValue FakeSpeechSynthesizer::getLanguage(std::string& language) { language = m_language; - return yarp_ret_value_ok; + return ReturnValue_ok; } -yarp_ret_value FakeSpeechSynthesizer::setVoice(const std::string& voice) +ReturnValue FakeSpeechSynthesizer::setVoice(const std::string& voice) { m_voice = voice; yCInfo(FAKE_SPEECHSYN) << "Voice set to" << voice; - return yarp_ret_value_ok; + return ReturnValue_ok; } -yarp_ret_value FakeSpeechSynthesizer::getVoice(std::string& voice) +ReturnValue FakeSpeechSynthesizer::getVoice(std::string& voice) { voice = m_voice; - return yarp_ret_value_ok; + return ReturnValue_ok; } -yarp_ret_value FakeSpeechSynthesizer::setSpeed(const double speed) +ReturnValue FakeSpeechSynthesizer::setSpeed(const double speed) { m_speed = speed; yCInfo(FAKE_SPEECHSYN) << "Speed set to" << speed; - return yarp_ret_value_ok; + return ReturnValue_ok; } -yarp_ret_value FakeSpeechSynthesizer::getSpeed(double& speed) +ReturnValue FakeSpeechSynthesizer::getSpeed(double& speed) { speed = m_speed; - return yarp_ret_value_ok; + return ReturnValue_ok; } -yarp_ret_value FakeSpeechSynthesizer::setPitch(const double pitch) +ReturnValue FakeSpeechSynthesizer::setPitch(const double pitch) { m_pitch = pitch; yCInfo(FAKE_SPEECHSYN) << "Pitch set to" << pitch; - return yarp_ret_value_ok; + return ReturnValue_ok; } -yarp_ret_value FakeSpeechSynthesizer::getPitch(double& pitch) +ReturnValue FakeSpeechSynthesizer::getPitch(double& pitch) { pitch = m_pitch; - return yarp_ret_value_ok; + return ReturnValue_ok; } -yarp_ret_value FakeSpeechSynthesizer::synthesize(const std::string& text, yarp::sig::Sound& sound) +ReturnValue FakeSpeechSynthesizer::synthesize(const std::string& text, yarp::sig::Sound& sound) { if (text == "") { yCError(FAKE_SPEECHSYN) << "Text is empty"; - return yarp_ret_value::return_code::return_value_error_method_failed; + return ReturnValue::return_code::return_value_error_method_failed; } sound.resize(100,2); - return yarp_ret_value_ok; + return ReturnValue_ok; } diff --git a/src/devices/fake/fakeSpeechSynthesizer/FakeSpeechSynthesizer.h b/src/devices/fake/fakeSpeechSynthesizer/FakeSpeechSynthesizer.h index ea640ee930..e62c9611c6 100644 --- a/src/devices/fake/fakeSpeechSynthesizer/FakeSpeechSynthesizer.h +++ b/src/devices/fake/fakeSpeechSynthesizer/FakeSpeechSynthesizer.h @@ -41,15 +41,15 @@ class FakeSpeechSynthesizer : bool open(yarp::os::Searchable& config) override; bool close() override; - virtual yarp::dev::yarp_ret_value setLanguage(const std::string& language) override; - virtual yarp::dev::yarp_ret_value getLanguage(std::string& language) override; - virtual yarp::dev::yarp_ret_value setVoice(const std::string& voice) override; - virtual yarp::dev::yarp_ret_value getVoice(std::string& voice) override; - virtual yarp::dev::yarp_ret_value setSpeed(const double speed) override; - virtual yarp::dev::yarp_ret_value getSpeed(double& voice) override; - virtual yarp::dev::yarp_ret_value setPitch(const double pitch) override; - virtual yarp::dev::yarp_ret_value getPitch(double& voice) override; - virtual yarp::dev::yarp_ret_value synthesize(const std::string& text, yarp::sig::Sound& sound) override; + virtual yarp::dev::ReturnValue setLanguage(const std::string& language) override; + virtual yarp::dev::ReturnValue getLanguage(std::string& language) override; + virtual yarp::dev::ReturnValue setVoice(const std::string& voice) override; + virtual yarp::dev::ReturnValue getVoice(std::string& voice) override; + virtual yarp::dev::ReturnValue setSpeed(const double speed) override; + virtual yarp::dev::ReturnValue getSpeed(double& voice) override; + virtual yarp::dev::ReturnValue setPitch(const double pitch) override; + virtual yarp::dev::ReturnValue getPitch(double& voice) override; + virtual yarp::dev::ReturnValue synthesize(const std::string& text, yarp::sig::Sound& sound) override; }; #endif diff --git a/src/devices/fake/fakeSpeechTranscription/FakeSpeechTranscription.cpp b/src/devices/fake/fakeSpeechTranscription/FakeSpeechTranscription.cpp index 52a9d84243..b207d264fe 100644 --- a/src/devices/fake/fakeSpeechTranscription/FakeSpeechTranscription.cpp +++ b/src/devices/fake/fakeSpeechTranscription/FakeSpeechTranscription.cpp @@ -40,20 +40,20 @@ bool FakeSpeechTranscription::close() return true; } -yarp::dev::yarp_ret_value FakeSpeechTranscription::setLanguage(const std::string& language) +yarp::dev::ReturnValue FakeSpeechTranscription::setLanguage(const std::string& language) { m_language=language; yCInfo(FAKE_SPEECHTR) << "Language set to" << language; - return yarp_ret_value_ok; + return ReturnValue_ok; } -yarp::dev::yarp_ret_value FakeSpeechTranscription::getLanguage(std::string& language) +yarp::dev::ReturnValue FakeSpeechTranscription::getLanguage(std::string& language) { language = m_language; - return yarp_ret_value_ok; + return ReturnValue_ok; } -yarp::dev::yarp_ret_value FakeSpeechTranscription::transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) +yarp::dev::ReturnValue FakeSpeechTranscription::transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) { if (sound.getSamples() == 0 || sound.getChannels() == 0) @@ -61,10 +61,10 @@ yarp::dev::yarp_ret_value FakeSpeechTranscription::transcribe(const yarp::sig::S yCError(FAKE_SPEECHTR) << "Invalid Sound sample received"; transcription = ""; score = 0.0; - return yarp_ret_value::return_code::return_value_error_method_failed; + return ReturnValue::return_code::return_value_error_method_failed; } transcription = "hello world"; score = 1.0; - return yarp_ret_value_ok; + return ReturnValue_ok; } diff --git a/src/devices/fake/fakeSpeechTranscription/FakeSpeechTranscription.h b/src/devices/fake/fakeSpeechTranscription/FakeSpeechTranscription.h index 9bf12b1f53..1d30a24ee8 100644 --- a/src/devices/fake/fakeSpeechTranscription/FakeSpeechTranscription.h +++ b/src/devices/fake/fakeSpeechTranscription/FakeSpeechTranscription.h @@ -41,9 +41,9 @@ class FakeSpeechTranscription : bool open(yarp::os::Searchable& config) override; bool close() override; - virtual yarp::dev::yarp_ret_value setLanguage(const std::string& language) override; - virtual yarp::dev::yarp_ret_value getLanguage(std::string& language) override; - virtual yarp::dev::yarp_ret_value transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) override; + virtual yarp::dev::ReturnValue setLanguage(const std::string& language) override; + virtual yarp::dev::ReturnValue getLanguage(std::string& language) override; + virtual yarp::dev::ReturnValue transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) override; }; #endif diff --git a/src/devices/networkWrappers/speechSynthesizer_nwc_yarp/SpeechSynthesizer_nwc_yarp.cpp b/src/devices/networkWrappers/speechSynthesizer_nwc_yarp/SpeechSynthesizer_nwc_yarp.cpp index bddeda4a94..775aea174d 100644 --- a/src/devices/networkWrappers/speechSynthesizer_nwc_yarp/SpeechSynthesizer_nwc_yarp.cpp +++ b/src/devices/networkWrappers/speechSynthesizer_nwc_yarp/SpeechSynthesizer_nwc_yarp.cpp @@ -64,7 +64,7 @@ bool SpeechSynthesizer_nwc_yarp::closeMain() return true; } -yarp_ret_value SpeechSynthesizer_nwc_yarp::setLanguage(const std::string& language) +ReturnValue SpeechSynthesizer_nwc_yarp::setLanguage(const std::string& language) { auto result = m_thriftClient.set_language(language); if(!result.ret) @@ -76,7 +76,7 @@ yarp_ret_value SpeechSynthesizer_nwc_yarp::setLanguage(const std::string& langua return result.ret; } -yarp_ret_value SpeechSynthesizer_nwc_yarp::getLanguage(std::string& language) +ReturnValue SpeechSynthesizer_nwc_yarp::getLanguage(std::string& language) { auto result = m_thriftClient.get_language(); if(!result.ret) @@ -90,7 +90,7 @@ yarp_ret_value SpeechSynthesizer_nwc_yarp::getLanguage(std::string& language) return result.ret; } -yarp_ret_value SpeechSynthesizer_nwc_yarp::setVoice(const std::string& voice_name) +ReturnValue SpeechSynthesizer_nwc_yarp::setVoice(const std::string& voice_name) { auto result = m_thriftClient.set_voice(voice_name); if(!result.ret) @@ -102,7 +102,7 @@ yarp_ret_value SpeechSynthesizer_nwc_yarp::setVoice(const std::string& voice_nam return result.ret; } -yarp_ret_value SpeechSynthesizer_nwc_yarp::getVoice(std::string& voice_name) +ReturnValue SpeechSynthesizer_nwc_yarp::getVoice(std::string& voice_name) { auto result = m_thriftClient.get_voice(); if(!result.ret) @@ -116,7 +116,7 @@ yarp_ret_value SpeechSynthesizer_nwc_yarp::getVoice(std::string& voice_name) return result.ret; } -yarp_ret_value SpeechSynthesizer_nwc_yarp::setSpeed(const double speed) +ReturnValue SpeechSynthesizer_nwc_yarp::setSpeed(const double speed) { auto result = m_thriftClient.set_speed(speed); if(!result.ret) @@ -128,7 +128,7 @@ yarp_ret_value SpeechSynthesizer_nwc_yarp::setSpeed(const double speed) return result.ret; } -yarp_ret_value SpeechSynthesizer_nwc_yarp::getSpeed(double& speed) +ReturnValue SpeechSynthesizer_nwc_yarp::getSpeed(double& speed) { auto result = m_thriftClient.get_speed(); if(!result.ret) @@ -142,7 +142,7 @@ yarp_ret_value SpeechSynthesizer_nwc_yarp::getSpeed(double& speed) return result.ret; } -yarp_ret_value SpeechSynthesizer_nwc_yarp::setPitch(const double pitch) +ReturnValue SpeechSynthesizer_nwc_yarp::setPitch(const double pitch) { auto result = m_thriftClient.set_pitch(pitch); if(!result.ret) @@ -154,7 +154,7 @@ yarp_ret_value SpeechSynthesizer_nwc_yarp::setPitch(const double pitch) return result.ret; } -yarp_ret_value SpeechSynthesizer_nwc_yarp::getPitch(double& pitch) +ReturnValue SpeechSynthesizer_nwc_yarp::getPitch(double& pitch) { auto result = m_thriftClient.get_pitch(); if(!result.ret) @@ -168,7 +168,7 @@ yarp_ret_value SpeechSynthesizer_nwc_yarp::getPitch(double& pitch) return result.ret; } -yarp_ret_value SpeechSynthesizer_nwc_yarp::synthesize(const std::string& text, yarp::sig::Sound& sound) +ReturnValue SpeechSynthesizer_nwc_yarp::synthesize(const std::string& text, yarp::sig::Sound& sound) { auto result = m_thriftClient.synthesize(text); if(!result.ret) diff --git a/src/devices/networkWrappers/speechSynthesizer_nwc_yarp/SpeechSynthesizer_nwc_yarp.h b/src/devices/networkWrappers/speechSynthesizer_nwc_yarp/SpeechSynthesizer_nwc_yarp.h index 714283b41a..4b1c6160a8 100644 --- a/src/devices/networkWrappers/speechSynthesizer_nwc_yarp/SpeechSynthesizer_nwc_yarp.h +++ b/src/devices/networkWrappers/speechSynthesizer_nwc_yarp/SpeechSynthesizer_nwc_yarp.h @@ -57,15 +57,15 @@ class SpeechSynthesizer_nwc_yarp : bool close() override; // yarp::dev::ISpeechSynthesizer - yarp::dev::yarp_ret_value setLanguage(const std::string& language="auto") override; - yarp::dev::yarp_ret_value getLanguage(std::string& language) override; - yarp::dev::yarp_ret_value setVoice(const std::string& voice_name = "auto") override; - yarp::dev::yarp_ret_value getVoice(std::string& voice_name) override; - yarp::dev::yarp_ret_value setSpeed(const double speed=0) override; - yarp::dev::yarp_ret_value getSpeed(double& speed) override; - yarp::dev::yarp_ret_value setPitch(const double pitch) override; - yarp::dev::yarp_ret_value getPitch(double& pitch) override; - yarp::dev::yarp_ret_value synthesize(const std::string& text, yarp::sig::Sound& sound) override; + yarp::dev::ReturnValue setLanguage(const std::string& language="auto") override; + yarp::dev::ReturnValue getLanguage(std::string& language) override; + yarp::dev::ReturnValue setVoice(const std::string& voice_name = "auto") override; + yarp::dev::ReturnValue getVoice(std::string& voice_name) override; + yarp::dev::ReturnValue setSpeed(const double speed=0) override; + yarp::dev::ReturnValue getSpeed(double& speed) override; + yarp::dev::ReturnValue setPitch(const double pitch) override; + yarp::dev::ReturnValue getPitch(double& pitch) override; + yarp::dev::ReturnValue synthesize(const std::string& text, yarp::sig::Sound& sound) override; // Parameters private: diff --git a/src/devices/networkWrappers/speechSynthesizer_nws_yarp/SpeechSynthesizer_nws_yarp.cpp b/src/devices/networkWrappers/speechSynthesizer_nws_yarp/SpeechSynthesizer_nws_yarp.cpp index c6986871b5..8f5156e4cb 100644 --- a/src/devices/networkWrappers/speechSynthesizer_nws_yarp/SpeechSynthesizer_nws_yarp.cpp +++ b/src/devices/networkWrappers/speechSynthesizer_nws_yarp/SpeechSynthesizer_nws_yarp.cpp @@ -122,7 +122,7 @@ return_set_language ISpeechSynthesizerMsgsd::set_language(const std::string& lan return m_isptr->setLanguage(language); } yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); - ret.ret = yarp_ret_value::return_code::return_value_error_generic; + ret.ret = ReturnValue::return_code::return_value_error_generic; return ret; } @@ -133,13 +133,13 @@ return_get_language ISpeechSynthesizerMsgsd::get_language() if (m_isptr) { std::string language; - yarp_ret_value b = m_isptr->getLanguage(language); + ReturnValue b = m_isptr->getLanguage(language); ret.ret = b; ret.language = language; return ret; } yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); - ret.ret = yarp_ret_value::return_code::return_value_error_generic; + ret.ret = ReturnValue::return_code::return_value_error_generic; return ret; } @@ -162,13 +162,13 @@ return_get_voice ISpeechSynthesizerMsgsd::get_voice() if (m_isptr) { std::string voice; - yarp_ret_value b = m_isptr->getVoice(voice); + ReturnValue b = m_isptr->getVoice(voice); ret.ret = b; ret.voice = voice; return ret; } yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); - ret.ret = yarp_ret_value::return_code::return_value_error_generic; + ret.ret = ReturnValue::return_code::return_value_error_generic; return ret; } @@ -181,7 +181,7 @@ return_set_pitch ISpeechSynthesizerMsgsd::set_pitch(double pitch) return m_isptr->setPitch(pitch); } yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); - ret.ret = yarp_ret_value::return_code::return_value_error_generic; + ret.ret = ReturnValue::return_code::return_value_error_generic; return ret; } @@ -192,7 +192,7 @@ return_get_pitch ISpeechSynthesizerMsgsd::get_pitch() if (m_isptr) { double pitch; - yarp_ret_value b = m_isptr->getPitch(pitch); + ReturnValue b = m_isptr->getPitch(pitch); ret.ret = b; ret.pitch = pitch; return ret; @@ -210,7 +210,7 @@ return_set_speed ISpeechSynthesizerMsgsd::set_speed(double speed) return m_isptr->setSpeed(speed); } yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); - ret.ret = yarp_ret_value::return_code::return_value_error_generic; + ret.ret = ReturnValue::return_code::return_value_error_generic; return ret; } @@ -221,13 +221,13 @@ return_get_speed ISpeechSynthesizerMsgsd::get_speed() if (m_isptr) { double speed; - yarp_ret_value b = m_isptr->getSpeed(speed); + ReturnValue b = m_isptr->getSpeed(speed); ret.ret = b; ret.speed = speed; return ret; } yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); - ret.ret = yarp_ret_value::return_code::return_value_error_generic; + ret.ret = ReturnValue::return_code::return_value_error_generic; return ret; } @@ -239,7 +239,7 @@ return_synthesize ISpeechSynthesizerMsgsd::synthesize(const std::string& text) { yarp::sig::Sound snd; double score; - yarp_ret_value b = m_isptr->synthesize(text, snd); + ReturnValue b = m_isptr->synthesize(text, snd); ret.ret = b; ret.sound = snd; @@ -251,7 +251,7 @@ return_synthesize ISpeechSynthesizerMsgsd::synthesize(const std::string& text) return ret; } yCError(SPEECHSYNTH_NWS, "ISpeechSynthesizer interface was not set"); - ret.ret = yarp_ret_value::return_code::return_value_error_generic; + ret.ret = ReturnValue::return_code::return_value_error_generic; return ret; } diff --git a/src/devices/networkWrappers/speechTranscription_nwc_yarp/SpeechTranscription_nwc_yarp.cpp b/src/devices/networkWrappers/speechTranscription_nwc_yarp/SpeechTranscription_nwc_yarp.cpp index 9735f48bef..8d1ed2fb66 100644 --- a/src/devices/networkWrappers/speechTranscription_nwc_yarp/SpeechTranscription_nwc_yarp.cpp +++ b/src/devices/networkWrappers/speechTranscription_nwc_yarp/SpeechTranscription_nwc_yarp.cpp @@ -62,7 +62,7 @@ bool SpeechTranscription_nwc_yarp::closeMain() return true; } -yarp::dev::yarp_ret_value SpeechTranscription_nwc_yarp::setLanguage(const std::string& language) +yarp::dev::ReturnValue SpeechTranscription_nwc_yarp::setLanguage(const std::string& language) { return_set_language result = m_thriftClient.set_language(language); if(!result.ret) @@ -75,7 +75,7 @@ yarp::dev::yarp_ret_value SpeechTranscription_nwc_yarp::setLanguage(const std::s return result.ret; } -yarp::dev::yarp_ret_value SpeechTranscription_nwc_yarp::getLanguage(std::string& language) +yarp::dev::ReturnValue SpeechTranscription_nwc_yarp::getLanguage(std::string& language) { return_get_language result = m_thriftClient.get_language(); if(!result.ret) @@ -89,7 +89,7 @@ yarp::dev::yarp_ret_value SpeechTranscription_nwc_yarp::getLanguage(std::string& return result.ret; } -yarp::dev::yarp_ret_value SpeechTranscription_nwc_yarp::transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) +yarp::dev::ReturnValue SpeechTranscription_nwc_yarp::transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) { YARP_UNUSED(sound); YARP_UNUSED(transcription); diff --git a/src/devices/networkWrappers/speechTranscription_nwc_yarp/SpeechTranscription_nwc_yarp.h b/src/devices/networkWrappers/speechTranscription_nwc_yarp/SpeechTranscription_nwc_yarp.h index cfcfa2683e..cbd4595443 100644 --- a/src/devices/networkWrappers/speechTranscription_nwc_yarp/SpeechTranscription_nwc_yarp.h +++ b/src/devices/networkWrappers/speechTranscription_nwc_yarp/SpeechTranscription_nwc_yarp.h @@ -55,9 +55,9 @@ class SpeechTranscription_nwc_yarp : bool close() override; //yarp::dev::ISpeechTranscription - yarp::dev::yarp_ret_value setLanguage(const std::string& language="auto") override; - yarp::dev::yarp_ret_value getLanguage(std::string& language) override; - yarp::dev::yarp_ret_value transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) override; + yarp::dev::ReturnValue setLanguage(const std::string& language="auto") override; + yarp::dev::ReturnValue getLanguage(std::string& language) override; + yarp::dev::ReturnValue transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) override; // Parameters private: diff --git a/src/devices/networkWrappers/speechTranscription_nws_yarp/SpeechTranscription_nws_yarp.cpp b/src/devices/networkWrappers/speechTranscription_nws_yarp/SpeechTranscription_nws_yarp.cpp index b6669e2550..baffea356e 100644 --- a/src/devices/networkWrappers/speechTranscription_nws_yarp/SpeechTranscription_nws_yarp.cpp +++ b/src/devices/networkWrappers/speechTranscription_nws_yarp/SpeechTranscription_nws_yarp.cpp @@ -122,7 +122,7 @@ return_set_language ISpeechTranscriptionMsgsd::set_language(const std::string& l return m_isptr->setLanguage(language); } yCError(SPEECHTR_NWS, "ISpeechTranscription interface was not set"); - ret.ret = yarp_ret_value::return_code::return_value_error_generic; + ret.ret = ReturnValue::return_code::return_value_error_generic; return ret; } @@ -133,13 +133,13 @@ return_get_language ISpeechTranscriptionMsgsd::get_language() if (m_isptr) { std::string language; - yarp_ret_value b = m_isptr->getLanguage(language); + ReturnValue b = m_isptr->getLanguage(language); ret.ret = b; ret.language = language; return ret; } yCError(SPEECHTR_NWS, "ISpeechTranscription interface was not set"); - ret.ret = yarp_ret_value::return_code::return_value_error_generic; + ret.ret = ReturnValue::return_code::return_value_error_generic; return ret; } @@ -151,7 +151,7 @@ return_transcribe ISpeechTranscriptionMsgsd::transcribe(const yarp::sig::Sound& { std::string transcription; double score; - yarp_ret_value b = m_isptr->transcribe(sound, transcription, score); + ReturnValue b = m_isptr->transcribe(sound, transcription, score); ret.ret = b; ret.transcription = transcription; ret.score = score; @@ -167,7 +167,7 @@ return_transcribe ISpeechTranscriptionMsgsd::transcribe(const yarp::sig::Sound& return ret; } yCError(SPEECHTR_NWS, "ISpeechTranscription interface was not set"); - ret.ret = yarp_ret_value::return_code::return_value_error_generic; + ret.ret = ReturnValue::return_code::return_value_error_generic; return ret; } diff --git a/src/libYARP_dev/src/yarp/dev/ISpeechSynthesizer.h b/src/libYARP_dev/src/yarp/dev/ISpeechSynthesizer.h index 0bf7ad48a0..7ecd28f281 100644 --- a/src/libYARP_dev/src/yarp/dev/ISpeechSynthesizer.h +++ b/src/libYARP_dev/src/yarp/dev/ISpeechSynthesizer.h @@ -27,56 +27,56 @@ class YARP_dev_API ISpeechSynthesizer * \param language a string (code) representing the speech language (e.g. ita, eng...). Default value is "auto". * \return true on success */ - virtual yarp::dev::yarp_ret_value setLanguage(const std::string& language="auto") = 0; + virtual yarp::dev::ReturnValue setLanguage(const std::string& language="auto") = 0; /** * Gets the current language set for speech synthesis. * \param language the returned string (code) representing the speech language (e.g. ita, eng...). Default value is "auto". * \return true on success */ - virtual yarp::dev::yarp_ret_value getLanguage(std::string& language) = 0; + virtual yarp::dev::ReturnValue getLanguage(std::string& language) = 0; /** * Sets the voice set for speech synthesis. * \param voice_name the name of of the voice (device dependent). * \return true on success */ - virtual yarp::dev::yarp_ret_value setVoice(const std::string& voice_name = "auto") = 0; + virtual yarp::dev::ReturnValue setVoice(const std::string& voice_name = "auto") = 0; /** * Gets the current voice set for speech synthesis. * \param voice_name the currently used voice (device dependent). * \return true on success */ - virtual yarp::dev::yarp_ret_value getVoice(std::string& voice_name) = 0; + virtual yarp::dev::ReturnValue getVoice(std::string& voice_name) = 0; /** * Sets the voice speed for speech synthesis. * \param speed the voice speed. * \return true on success */ - virtual yarp::dev::yarp_ret_value setSpeed(const double speed=0) = 0; + virtual yarp::dev::ReturnValue setSpeed(const double speed=0) = 0; /** * Gets the current voice speed. * \param speed the current voice speed. * \return true on success */ - virtual yarp::dev::yarp_ret_value getSpeed(double& speed) = 0; + virtual yarp::dev::ReturnValue getSpeed(double& speed) = 0; /** * Sets the pitch for speech synthesis. * \param pitch the voice pitch. * \return true on success */ - virtual yarp::dev::yarp_ret_value setPitch(const double pitch) = 0; + virtual yarp::dev::ReturnValue setPitch(const double pitch) = 0; /** * Gets the current pitch set for speech synthesis. * \param pitch the current voice pitch. * \return true on success */ - virtual yarp::dev::yarp_ret_value getPitch(double& voice) = 0; + virtual yarp::dev::ReturnValue getPitch(double& voice) = 0; /** * Performs the speech synthesis. @@ -84,7 +84,7 @@ class YARP_dev_API ISpeechSynthesizer * \param sound the synthesized audio stream * \return true on success */ - virtual yarp::dev::yarp_ret_value synthesize(const std::string& text, yarp::sig::Sound& sound) = 0; + virtual yarp::dev::ReturnValue synthesize(const std::string& text, yarp::sig::Sound& sound) = 0; }; } // namespace yarp::dev diff --git a/src/libYARP_dev/src/yarp/dev/ISpeechTranscription.h b/src/libYARP_dev/src/yarp/dev/ISpeechTranscription.h index f51accec80..6f15abd737 100644 --- a/src/libYARP_dev/src/yarp/dev/ISpeechTranscription.h +++ b/src/libYARP_dev/src/yarp/dev/ISpeechTranscription.h @@ -27,14 +27,14 @@ class YARP_dev_API ISpeechTranscription * \param language a string (code) representing the speech language (e.g. ita, eng...). Default value is "auto". * \return true on success */ - virtual yarp::dev::yarp_ret_value setLanguage(const std::string& language="auto") = 0; + virtual yarp::dev::ReturnValue setLanguage(const std::string& language="auto") = 0; /** * Gets the current language set for speech transcription. * \param language the returned string (code) representing the speech language (e.g. ita, eng...). Default value is "auto". * \return true on success */ - virtual yarp::dev::yarp_ret_value getLanguage(std::string& language) = 0; + virtual yarp::dev::ReturnValue getLanguage(std::string& language) = 0; /** * Performs the speech transcription. @@ -43,7 +43,7 @@ class YARP_dev_API ISpeechTranscription * \param score the returned score/confidence value in the range (0-1.0). It may be not implemented. * \return true on success */ - virtual yarp::dev::yarp_ret_value transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) = 0; + virtual yarp::dev::ReturnValue transcribe(const yarp::sig::Sound& sound, std::string& transcription, double& score) = 0; }; } // namespace yarp::dev diff --git a/src/libYARP_dev/src/yarp/dev/ReturnValue.cpp b/src/libYARP_dev/src/yarp/dev/ReturnValue.cpp index f24b6ad9dd..19fc1a8638 100644 --- a/src/libYARP_dev/src/yarp/dev/ReturnValue.cpp +++ b/src/libYARP_dev/src/yarp/dev/ReturnValue.cpp @@ -10,12 +10,12 @@ using namespace yarp::dev; using namespace yarp::os; -yarp_ret_value::yarp_ret_value() +ReturnValue::ReturnValue() { } #ifndef DISABLE_BOOL_INPUT -yarp_ret_value::yarp_ret_value(const bool& val) +ReturnValue::ReturnValue(const bool& val) { if (val) { @@ -28,7 +28,7 @@ yarp_ret_value::yarp_ret_value(const bool& val) } #endif -yarp_ret_value& yarp_ret_value::operator && (const yarp_ret_value& other) +ReturnValue& ReturnValue::operator && (const ReturnValue& other) { // THIS IS THE IMPLEMENTATION RULE: // OP1 OP2 RESULT @@ -48,7 +48,7 @@ yarp_ret_value& yarp_ret_value::operator && (const yarp_ret_value& other) return *this; } -yarp_ret_value& yarp_ret_value::operator &= (const yarp_ret_value& other) +ReturnValue& ReturnValue::operator &= (const ReturnValue& other) { // THIS IS THE IMPLEMENTATION RULE: // OP1 OP2 RESULT @@ -69,7 +69,7 @@ yarp_ret_value& yarp_ret_value::operator &= (const yarp_ret_value& other) } #ifndef DISABLE_BOOL_INPUT -yarp_ret_value& yarp_ret_value::operator=(const bool& bool_val) +ReturnValue& ReturnValue::operator=(const bool& bool_val) { if (bool_val) { @@ -83,14 +83,14 @@ yarp_ret_value& yarp_ret_value::operator=(const bool& bool_val) } #endif -std::string yarp_ret_value::toString() +std::string ReturnValue::toString() { switch (value_b) { case return_code::return_value_ok: return std::string("ok"); - case return_code::return_value_unitialized: - return std::string("return_value_unitialized"); + case return_code::return_value_uninitialized: + return std::string("return_value_uninitialized"); case return_code::return_value_error_deprecated: return std::string("return_value_error_deprecated"); case return_code::return_value_error_generic: @@ -106,30 +106,30 @@ std::string yarp_ret_value::toString() } } -yarp_ret_value::operator bool() const +ReturnValue::operator bool() const { return value_b == return_code::return_value_ok; } -yarp_ret_value::yarp_ret_value(return_code code) +ReturnValue::ReturnValue(return_code code) { value_b = code; } -bool yarp_ret_value::operator == (const return_code& code) const +bool ReturnValue::operator == (const return_code& code) const { if (code == this->value_b) return true; return false; } -bool yarp_ret_value::read(yarp::os::ConnectionReader& connection) +bool ReturnValue::read(yarp::os::ConnectionReader& connection) { connection.convertTextMode(); - this->value_b = (yarp_ret_value::return_code)(connection.expectInt64()); + this->value_b = (ReturnValue::return_code)(connection.expectInt64()); return true; } -bool yarp_ret_value::write(yarp::os::ConnectionWriter& connection) const +bool ReturnValue::write(yarp::os::ConnectionWriter& connection) const { connection.convertTextMode(); connection.appendInt64((int64_t)(this->value_b)); diff --git a/src/libYARP_dev/src/yarp/dev/ReturnValue.h b/src/libYARP_dev/src/yarp/dev/ReturnValue.h index 6c536e9b43..3e4eba585a 100644 --- a/src/libYARP_dev/src/yarp/dev/ReturnValue.h +++ b/src/libYARP_dev/src/yarp/dev/ReturnValue.h @@ -3,8 +3,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef YARP_RET_VALUE_H -#define YARP_RET_VALUE_H +#ifndef ReturnValue_H +#define ReturnValue_H #include #include @@ -13,20 +13,20 @@ #include // The following macro is used for testing/development purposes only, but it must be generally not enabled. -// If enabled, a bool value cannot be automatically converted to yarp_ret_value +// If enabled, a bool value cannot be automatically converted to ReturnValue // In this way, the developer can check if some old devices/interfaces do unwanted automatic // conversions and fix them. #define DISABLE_BOOL_INPUT // The following macro is used for testing/development purposes only, but it must be generally not enabled. -// If enabled, a yarp_ret_value cannot be automatically converted to bool unless explicitly requested +// If enabled, a ReturnValue cannot be automatically converted to bool unless explicitly requested // using the bool() operator. // If enabled, it will break backward compatibility with user-application code. // #define DISABLE_BOOL_OUTPUT namespace yarp::dev { -class YARP_dev_API yarp_ret_value : public yarp::os::Portable +class YARP_dev_API ReturnValue : public yarp::os::Portable { public: enum class YARP_dev_API return_code @@ -37,24 +37,24 @@ class YARP_dev_API yarp_ret_value : public yarp::os::Portable return_value_error_nws_nwc_communication_error = 3, /// Command answer lost during network transmission. Status unknown. return_value_error_deprecated = 4, /// Method is deprecated return_value_error_method_failed = 5, /// Method failed due to invalid internal status/invalid request - return_value_unitialized = 100 /// Default value, should never be explicitly assigned + return_value_uninitialized = 100 /// Default value, should never be explicitly assigned }; private: - return_code value_b = return_code::return_value_unitialized; + return_code value_b = return_code::return_value_uninitialized; public: - yarp_ret_value(); - ~yarp_ret_value() = default; + ReturnValue(); + ~ReturnValue() = default; #ifndef DISABLE_BOOL_INPUT - yarp_ret_value(const bool& val); + ReturnValue(const bool& val); #endif - yarp_ret_value(return_code code); - yarp_ret_value(const yarp_ret_value& other) = default; - yarp_ret_value& operator && (const yarp_ret_value& other); - yarp_ret_value& operator &= (const yarp_ret_value& other); + ReturnValue(return_code code); + ReturnValue(const ReturnValue& other) = default; + ReturnValue& operator && (const ReturnValue& other); + ReturnValue& operator &= (const ReturnValue& other); #ifndef DISABLE_BOOL_INPUT - yarp_ret_value& operator=(const bool& bool_val); + ReturnValue& operator=(const bool& bool_val); #endif bool operator == (const return_code& code) const; std::string toString(); @@ -69,30 +69,30 @@ class YARP_dev_API yarp_ret_value : public yarp::os::Portable bool write(yarp::os::ConnectionWriter& connection) const override; }; -#define yarp_ret_value_ok yarp_ret_value(yarp::dev::yarp_ret_value::return_code::return_value_ok) +#define ReturnValue_ok ReturnValue(yarp::dev::ReturnValue::return_code::return_value_ok) #if __cplusplus >= 202002L -inline yarp_ret_value YARP_METHOD_NOT_YET_IMPLEMENTED(const std::source_location& location = std::source_location::current()) +inline ReturnValue YARP_METHOD_NOT_YET_IMPLEMENTED(const std::source_location& location = std::source_location::current()) { yError("Method %s not yet implemented\n", location.function_name()); - return yarp_ret_value(yarp::dev::yarp_ret_value::return_code::return_value_error_not_implemented_by_device); + return ReturnValue(yarp::dev::ReturnValue::return_code::return_value_error_not_implemented_by_device); } -inline yarp_ret_value YARP_METHOD_DEPRECATED(const std::source_location& location = std::source_location::current()) +inline ReturnValue YARP_METHOD_DEPRECATED(const std::source_location& location = std::source_location::current()) { yError("Method %s has been deprecated\n", location.function_name()); - return yarp_ret_value(yarp::dev::yarp_ret_value::return_code::return_value_error_deprecated); + return ReturnValue(yarp::dev::ReturnValue::return_code::return_value_error_deprecated); } #else -inline yarp_ret_value yarp_method_not_implemented(const char* location) +inline ReturnValue yarp_method_not_implemented(const char* location) { yError("Method %s not yet implemented\n", location); - return yarp_ret_value(yarp::dev::yarp_ret_value::return_code::return_value_error_not_implemented_by_device); + return ReturnValue(yarp::dev::ReturnValue::return_code::return_value_error_not_implemented_by_device); } #define YARP_METHOD_NOT_YET_IMPLEMENTED() yarp_method_not_implemented(__func__) -inline yarp_ret_value yarp_method_deprecated(const char* location) +inline ReturnValue yarp_method_deprecated(const char* location) { yError("Method %s has been deprecated\n", location); - return yarp_ret_value(yarp::dev::yarp_ret_value::return_code::return_value_error_deprecated); + return ReturnValue(yarp::dev::ReturnValue::return_code::return_value_error_deprecated); } #define YARP_METHOD_DEPRECATED() yarp_method_deprecated(__func__) #endif @@ -100,4 +100,4 @@ inline yarp_ret_value yarp_method_deprecated(const char* location) } -#endif // YARP_RET_VALUE_H +#endif // ReturnValue_H diff --git a/src/libYARP_dev/tests/ReturnValueTest.cpp b/src/libYARP_dev/tests/ReturnValueTest.cpp index 491e547398..910e43fbf8 100644 --- a/src/libYARP_dev/tests/ReturnValueTest.cpp +++ b/src/libYARP_dev/tests/ReturnValueTest.cpp @@ -11,12 +11,12 @@ using namespace yarp::dev; -yarp_ret_value test_method1() +ReturnValue test_method1() { return YARP_METHOD_NOT_YET_IMPLEMENTED(); } -yarp_ret_value test_method2() +ReturnValue test_method2() { return YARP_METHOD_DEPRECATED(); } @@ -26,11 +26,11 @@ TEST_CASE("dev::ReturnValue", "[yarp::dev]") #ifndef DISABLE_BOOL_INPUT SECTION("test block 1") { - yarp_ret_value val_f1(false); - yarp_ret_value val_f2(false); + ReturnValue val_f1(false); + ReturnValue val_f2(false); - yarp_ret_value val_t1(true); - yarp_ret_value val_t2(true); + ReturnValue val_t1(true); + ReturnValue val_t2(true); CHECK(val_f1 == val_f2); CHECK(val_t1 == val_t2); @@ -45,36 +45,36 @@ TEST_CASE("dev::ReturnValue", "[yarp::dev]") SECTION("test block 2") { - yarp_ret_value val1; - CHECK(val1 == yarp_ret_value::return_code::return_value_unitialized); + ReturnValue val1; + CHECK(val1 == ReturnValue::return_code::return_value_unitialized); std::string s; - val1 = yarp_ret_value::return_code::return_value_ok; + val1 = ReturnValue::return_code::return_value_ok; s = val1.toString(); CHECK(val1); CHECK(s!="unknown"); - val1 = yarp_ret_value::return_code::return_value_error_generic; + val1 = ReturnValue::return_code::return_value_error_generic; s = val1.toString(); CHECK(!val1); CHECK(s != "unknown"); - val1 = yarp_ret_value::return_code::return_value_error_method_failed; + val1 = ReturnValue::return_code::return_value_error_method_failed; s = val1.toString(); CHECK(!val1); CHECK(s != "unknown"); - val1 = yarp_ret_value::return_code::return_value_error_not_implemented_by_device; + val1 = ReturnValue::return_code::return_value_error_not_implemented_by_device; s = val1.toString(); CHECK(!val1); CHECK(s != "unknown"); - val1 = yarp_ret_value::return_code::return_value_error_nws_nwc_communication_error; + val1 = ReturnValue::return_code::return_value_error_nws_nwc_communication_error; s = val1.toString(); CHECK(!val1); CHECK(s != "unknown"); - val1 = yarp_ret_value::return_code::return_value_unitialized; + val1 = ReturnValue::return_code::return_value_unitialized; s = val1.toString(); CHECK(!val1); CHECK(s != "unknown"); @@ -82,23 +82,23 @@ TEST_CASE("dev::ReturnValue", "[yarp::dev]") SECTION("test block 3") { - yarp_ret_value val1; - val1 = yarp_ret_value::return_code::return_value_ok; - yarp_ret_value val2(val1); + ReturnValue val1; + val1 = ReturnValue::return_code::return_value_ok; + ReturnValue val2(val1); CHECK(val2); - CHECK(val2 == yarp_ret_value::return_code::return_value_ok); + CHECK(val2 == ReturnValue::return_code::return_value_ok); - val1 = yarp_ret_value::return_code::return_value_error_method_failed; - yarp_ret_value val3 = val1; + val1 = ReturnValue::return_code::return_value_error_method_failed; + ReturnValue val3 = val1; CHECK(!val3); - CHECK(val3 == yarp_ret_value::return_code::return_value_error_method_failed); + CHECK(val3 == ReturnValue::return_code::return_value_error_method_failed); } #ifndef DISABLE_BOOL_INPUT SECTION("test block 4a") { - yarp_ret_value val_f1(false); - yarp_ret_value val_t1(true); + ReturnValue val_f1(false); + ReturnValue val_t1(true); bool bool_f1 = val_f1; bool bool_t1 = val_t1; CHECK (bool_f1 == false); @@ -108,8 +108,8 @@ TEST_CASE("dev::ReturnValue", "[yarp::dev]") SECTION("test block 4b") { - yarp_ret_value val_f2(yarp_ret_value::return_code::return_value_error_method_failed); - yarp_ret_value val_t2(yarp_ret_value::return_code::return_value_ok); + ReturnValue val_f2(ReturnValue::return_code::return_value_error_method_failed); + ReturnValue val_t2(ReturnValue::return_code::return_value_ok); bool bool_f2 = val_f2; bool bool_t2 = val_t2; CHECK(bool_f2 == false); @@ -118,74 +118,74 @@ TEST_CASE("dev::ReturnValue", "[yarp::dev]") SECTION("test block 5") { - yarp_ret_value val_f(yarp_ret_value::return_code::return_value_error_method_failed); - yarp_ret_value val_t(yarp_ret_value::return_code::return_value_ok); + ReturnValue val_f(ReturnValue::return_code::return_value_error_method_failed); + ReturnValue val_t(ReturnValue::return_code::return_value_ok); { - yarp_ret_value ret(yarp_ret_value::return_code::return_value_ok); + ReturnValue ret(ReturnValue::return_code::return_value_ok); ret&= val_t; - CHECK(ret == yarp_ret_value::return_code::return_value_ok); + CHECK(ret == ReturnValue::return_code::return_value_ok); } { - yarp_ret_value ret(yarp_ret_value::return_code::return_value_ok); + ReturnValue ret(ReturnValue::return_code::return_value_ok); ret &= val_f; - CHECK(ret == yarp_ret_value::return_code::return_value_error_generic); + CHECK(ret == ReturnValue::return_code::return_value_error_generic); } { - yarp_ret_value ret(yarp_ret_value::return_code::return_value_error_not_implemented_by_device); + ReturnValue ret(ReturnValue::return_code::return_value_error_not_implemented_by_device); ret &= val_t; - CHECK(ret == yarp_ret_value::return_code::return_value_error_generic); + CHECK(ret == ReturnValue::return_code::return_value_error_generic); } { - yarp_ret_value ret(yarp_ret_value::return_code::return_value_error_not_implemented_by_device); + ReturnValue ret(ReturnValue::return_code::return_value_error_not_implemented_by_device); ret &= val_f; - CHECK(ret == yarp_ret_value::return_code::return_value_error_generic); + CHECK(ret == ReturnValue::return_code::return_value_error_generic); } } SECTION("test block 5b") { - yarp_ret_value val_f1(yarp_ret_value::return_code::return_value_error_method_failed); - yarp_ret_value val_f2(yarp_ret_value::return_code::return_value_error_not_implemented_by_device); - yarp_ret_value val_t(yarp_ret_value::return_code::return_value_ok); + ReturnValue val_f1(ReturnValue::return_code::return_value_error_method_failed); + ReturnValue val_f2(ReturnValue::return_code::return_value_error_not_implemented_by_device); + ReturnValue val_t(ReturnValue::return_code::return_value_ok); { - yarp_ret_value ret; + ReturnValue ret; ret = val_t && val_t; - CHECK(ret == yarp_ret_value::return_code::return_value_ok); + CHECK(ret == ReturnValue::return_code::return_value_ok); } { - yarp_ret_value ret; + ReturnValue ret; ret = val_f1 && val_f1; - CHECK(ret == yarp_ret_value::return_code::return_value_error_method_failed); + CHECK(ret == ReturnValue::return_code::return_value_error_method_failed); } { - yarp_ret_value ret; + ReturnValue ret; ret = val_f2 && val_f2; - CHECK(ret == yarp_ret_value::return_code::return_value_error_not_implemented_by_device); + CHECK(ret == ReturnValue::return_code::return_value_error_not_implemented_by_device); } { - yarp_ret_value ret(yarp_ret_value::return_code::return_value_ok); + ReturnValue ret(ReturnValue::return_code::return_value_ok); ret &= val_f1 && val_f2; - CHECK(ret == yarp_ret_value::return_code::return_value_error_generic); + CHECK(ret == ReturnValue::return_code::return_value_error_generic); } { - yarp_ret_value ret(yarp_ret_value::return_code::return_value_ok); + ReturnValue ret(ReturnValue::return_code::return_value_ok); ret &= val_t && val_f1 ; - CHECK(ret == yarp_ret_value::return_code::return_value_error_generic); + CHECK(ret == ReturnValue::return_code::return_value_error_generic); } { - yarp_ret_value ret(yarp_ret_value::return_code::return_value_ok); + ReturnValue ret(ReturnValue::return_code::return_value_ok); ret &= val_f1 && val_f2; - CHECK(ret == yarp_ret_value::return_code::return_value_error_generic); + CHECK(ret == ReturnValue::return_code::return_value_error_generic); } } SECTION("test block 6") { bool ok; - yarp_ret_value val_fi(yarp_ret_value::return_code::return_value_error_method_failed); - yarp_ret_value val_ti(yarp_ret_value::return_code::return_value_ok); - yarp_ret_value val_fo; - yarp_ret_value val_to; + ReturnValue val_fi(ReturnValue::return_code::return_value_error_method_failed); + ReturnValue val_ti(ReturnValue::return_code::return_value_ok); + ReturnValue val_fo; + ReturnValue val_to; ok = yarp::os::Portable::copyPortable(val_fi,val_fo); CHECK(ok); @@ -199,11 +199,11 @@ TEST_CASE("dev::ReturnValue", "[yarp::dev]") SECTION("test block 7") { auto ret1 = test_method1(); - CHECK(ret1 == yarp_ret_value::return_code::return_value_error_not_implemented_by_device); - CHECK(!(ret1 == yarp_ret_value::return_code::return_value_ok)); + CHECK(ret1 == ReturnValue::return_code::return_value_error_not_implemented_by_device); + CHECK(!(ret1 == ReturnValue::return_code::return_value_ok)); auto ret2 = test_method2(); - CHECK(ret2 == yarp_ret_value::return_code::return_value_error_deprecated); - CHECK(!(ret2 == yarp_ret_value::return_code::return_value_ok)); + CHECK(ret2 == ReturnValue::return_code::return_value_error_deprecated); + CHECK(!(ret2 == ReturnValue::return_code::return_value_ok)); } }