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 
27 #include <RobotAPI/interface/observers/SpeechObserverInterface.h>
28 #include <mutex>
29 
30 namespace armarx
31 {
34  {
35  public:
38  {
39  defineOptionalProperty<std::string>("TextToSpeechTopicName", "TextToSpeech", "Name of the TextToSpeechTopic");
40  defineOptionalProperty<std::string>("TextToSpeechStateTopicName", "TextToSpeechState", "Name of the TextToSpeechStateTopic");
41  }
42  };
43  class SpeechObserver;
44  class SpeechListenerImpl : public TextListenerInterface
45  {
46  public:
48  protected:
50  std::mutex dataMutex;
51  // TextListenerInterface interface
52  public:
53  void reportText(const std::string&, const Ice::Current&) override;
54  void reportTextWithParams(const std::string&, const Ice::StringSeq&, const Ice::Current&) override;
55  };
56 
58  virtual public Observer,
59  virtual public SpeechObserverInterface
60  {
61  friend class SpeechListenerImpl;
62  public:
64 
65  std::string getDefaultName() const override
66  {
67  return "SpeechObserver";
68  }
69 
71  {
73  }
74 
75  void onInitObserver() override;
76  void onConnectObserver() override;
77  virtual void reportState(armarx::TextToSpeechStateType state, const Ice::Current& = Ice::emptyCurrent) override;
78  virtual void reportText(const std::string& text, const Ice::Current& = Ice::emptyCurrent) override;
79  virtual void reportTextWithParams(const std::string& text, const Ice::StringSeq& params, const Ice::Current& = Ice::emptyCurrent) override;
80 
81  static std::string SpeechStateToString(TextToSpeechStateType state);
82  private:
83  std::mutex dataMutex;
84  int reportTextCounter = 0;
85  int reportStateCounter = 0;
86  };
87 }
armarx::SpeechObserver::reportTextWithParams
virtual void reportTextWithParams(const std::string &text, const Ice::StringSeq &params, const Ice::Current &=Ice::emptyCurrent) override
Definition: SpeechObserver.cpp:91
armarx::SpeechObserver::onConnectObserver
void onConnectObserver() override
Framework hook.
Definition: SpeechObserver.cpp:41
armarx::SpeechListenerImpl::reportTextWithParams
void reportTextWithParams(const std::string &, const Ice::StringSeq &, const Ice::Current &) override
Definition: SpeechObserver.cpp:112
armarx::SpeechListenerImpl::reportText
void reportText(const std::string &, const Ice::Current &) override
Definition: SpeechObserver.cpp:104
armarx::Observer
Baseclass for all ArmarX Observers.
Definition: Observer.h:80
armarx::SpeechListenerImpl::SpeechListenerImpl
SpeechListenerImpl(SpeechObserver *obs)
Definition: SpeechObserver.cpp:97
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
Observer.h
armarx::SpeechObserver::onInitObserver
void onInitObserver() override
Framework hook.
Definition: SpeechObserver.cpp:35
armarx::SpeechListenerImpl::obs
SpeechObserver * obs
Definition: SpeechObserver.h:49
armarx::SpeechObserverPropertyDefinitions
Definition: SpeechObserver.h:32
armarx::SpeechObserver::reportState
virtual void reportState(armarx::TextToSpeechStateType state, const Ice::Current &=Ice::emptyCurrent) override
Definition: SpeechObserver.cpp:73
armarx::SpeechListenerImpl
Definition: SpeechObserver.h:44
armarx::SpeechObserver::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: SpeechObserver.h:65
armarx::SpeechListenerImpl::dataMutex
std::mutex dataMutex
Definition: SpeechObserver.h:50
armarx::SpeechObserver::SpeechObserver
SpeechObserver()
Definition: SpeechObserver.cpp:31
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
armarx::SpeechObserver::SpeechStateToString
static std::string SpeechStateToString(TextToSpeechStateType state)
Definition: SpeechObserver.cpp:57
armarx::SpeechObserverPropertyDefinitions::SpeechObserverPropertyDefinitions
SpeechObserverPropertyDefinitions(std::string prefix)
Definition: SpeechObserver.h:36
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::SpeechObserver::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: SpeechObserver.h:70
armarx::SpeechObserver::reportText
virtual void reportText(const std::string &text, const Ice::Current &=Ice::emptyCurrent) override
Definition: SpeechObserver.cpp:82
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
armarx::SpeechObserver
Definition: SpeechObserver.h:57
armarx::ObserverPropertyDefinitions
Definition: Observer.h:50
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28