SpeechObserver.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5 * Karlsruhe Institute of Technology (KIT), all rights reserved.
6 *
7 * ArmarX is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * ArmarX is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu)
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24#pragma once
25
26#include <mutex>
27
29
30#include <RobotAPI/interface/observers/SpeechObserverInterface.h>
31
32namespace armarx
33{
35 {
36 public:
38 {
40 "TextToSpeechTopicName", "TextToSpeech", "Name of the TextToSpeechTopic");
41 defineOptionalProperty<std::string>("TextToSpeechStateTopicName",
42 "TextToSpeechState",
43 "Name of the TextToSpeechStateTopic");
44 }
45 };
46 class SpeechObserver;
47
48 class SpeechListenerImpl : public TextListenerInterface
49 {
50 public:
52
53 protected:
55 std::mutex dataMutex;
56 // TextListenerInterface interface
57 public:
58 void reportText(const std::string&, const Ice::Current&) override;
59 void reportTextWithParams(const std::string&,
60 const Ice::StringSeq&,
61 const Ice::Current&) override;
62 };
63
64 class SpeechObserver : virtual public Observer, virtual public SpeechObserverInterface
65 {
66 friend class SpeechListenerImpl;
67
68 public:
70
71 std::string
72 getDefaultName() const override
73 {
74 return "SpeechObserver";
75 }
76
83
84 void onInitObserver() override;
85 void onConnectObserver() override;
86 virtual void reportState(armarx::TextToSpeechStateType state,
87 const Ice::Current& = Ice::emptyCurrent) override;
88 virtual void reportText(const std::string& text,
89 const Ice::Current& = Ice::emptyCurrent) override;
90 virtual void reportTextWithParams(const std::string& text,
91 const Ice::StringSeq& params,
92 const Ice::Current& = Ice::emptyCurrent) override;
93
94 static std::string SpeechStateToString(TextToSpeechStateType state);
95
96 private:
97 std::mutex dataMutex;
98 int reportTextCounter = 0;
99 int reportStateCounter = 0;
100 };
101} // namespace armarx
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
ObserverPropertyDefinitions(std::string prefix)
Definition Observer.h:52
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
void reportText(const std::string &, const Ice::Current &) override
SpeechListenerImpl(SpeechObserver *obs)
void reportTextWithParams(const std::string &, const Ice::StringSeq &, const Ice::Current &) override
SpeechObserverPropertyDefinitions(std::string prefix)
void onConnectObserver() override
Framework hook.
virtual void reportTextWithParams(const std::string &text, const Ice::StringSeq &params, const Ice::Current &=Ice::emptyCurrent) override
virtual void reportText(const std::string &text, const Ice::Current &=Ice::emptyCurrent) override
friend class SpeechListenerImpl
PropertyDefinitionsPtr createPropertyDefinitions() override
static std::string SpeechStateToString(TextToSpeechStateType state)
void onInitObserver() override
Framework hook.
virtual void reportState(armarx::TextToSpeechStateType state, const Ice::Current &=Ice::emptyCurrent) override
std::string getDefaultName() const override
Retrieve default name of component.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.