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 
32 namespace armarx
33 {
35  {
36  public:
38  {
39  defineOptionalProperty<std::string>(
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 
79  {
82  }
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
armarx::SpeechObserver::reportTextWithParams
virtual void reportTextWithParams(const std::string &text, const Ice::StringSeq &params, const Ice::Current &=Ice::emptyCurrent) override
Definition: SpeechObserver.cpp:107
armarx::SpeechObserver::onConnectObserver
void onConnectObserver() override
Framework hook.
Definition: SpeechObserver.cpp:44
armarx::SpeechListenerImpl::reportTextWithParams
void reportTextWithParams(const std::string &, const Ice::StringSeq &, const Ice::Current &) override
Definition: SpeechObserver.cpp:129
armarx::SpeechListenerImpl::reportText
void reportText(const std::string &, const Ice::Current &) override
Definition: SpeechObserver.cpp:120
armarx::Observer
Baseclass for all ArmarX Observers.
Definition: Observer.h:84
armarx::SpeechListenerImpl::SpeechListenerImpl
SpeechListenerImpl(SpeechObserver *obs)
Definition: SpeechObserver.cpp:115
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
Observer.h
armarx::SpeechObserver::onInitObserver
void onInitObserver() override
Framework hook.
Definition: SpeechObserver.cpp:37
armarx::SpeechListenerImpl::obs
SpeechObserver * obs
Definition: SpeechObserver.h:54
armarx::SpeechObserverPropertyDefinitions
Definition: SpeechObserver.h:34
armarx::SpeechObserver::reportState
virtual void reportState(armarx::TextToSpeechStateType state, const Ice::Current &=Ice::emptyCurrent) override
Definition: SpeechObserver.cpp:87
armarx::SpeechListenerImpl
Definition: SpeechObserver.h:48
armarx::SpeechObserver::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: SpeechObserver.h:72
armarx::SpeechListenerImpl::dataMutex
std::mutex dataMutex
Definition: SpeechObserver.h:55
armarx::SpeechObserver::SpeechObserver
SpeechObserver()
Definition: SpeechObserver.cpp:32
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:79
armarx::SpeechObserver::SpeechStateToString
static std::string SpeechStateToString(TextToSpeechStateType state)
Definition: SpeechObserver.cpp:70
armarx::SpeechObserverPropertyDefinitions::SpeechObserverPropertyDefinitions
SpeechObserverPropertyDefinitions(std::string prefix)
Definition: SpeechObserver.h:37
IceUtil::Handle
Definition: forward_declarations.h:30
armarx::SpeechObserver::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: SpeechObserver.h:78
armarx::SpeechObserver::reportText
virtual void reportText(const std::string &text, const Ice::Current &=Ice::emptyCurrent) override
Definition: SpeechObserver.cpp:97
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:35
armarx::SpeechObserver
Definition: SpeechObserver.h:64
armarx::ObserverPropertyDefinitions
Definition: Observer.h:49
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27