Fawkes API  Fawkes Development Version
SpeechSynthInterface.h
1 
2 /***************************************************************************
3  * SpeechSynthInterface.h - Fawkes BlackBoard Interface - SpeechSynthInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2008 Tim Niemueller
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __INTERFACES_SPEECHSYNTHINTERFACE_H_
25 #define __INTERFACES_SPEECHSYNTHINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(SpeechSynthInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  private:
42  /** Internal data storage, do NOT modify! */
43  typedef struct __attribute__((packed)) {
44  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
45  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
46  char text[1024]; /**<
47  Last spoken string. Must be properly null-terminated.
48  */
49  uint32_t msgid; /**<
50  The ID of the message that is currently being processed,
51  or 0 if no message is being processed.
52  */
53  bool final; /**<
54  True, if the last text has been spoken, false if it is still running.
55  */
56  float duration; /**<
57  Length in seconds that it takes to speek the current text, -1 if
58  unknown. This is the total duration of the current string, *not* the
59  duration of already spoken or yet to speak text!
60  */
61  } SpeechSynthInterface_data_t;
62 
63  SpeechSynthInterface_data_t *data;
64 
65  public:
66  /* messages */
67  class SayMessage : public Message
68  {
69  private:
70  /** Internal data storage, do NOT modify! */
71  typedef struct __attribute__((packed)) {
72  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
73  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
74  char text[1024]; /**<
75  Last spoken string. Must be properly null-terminated.
76  */
77  } SayMessage_data_t;
78 
79  SayMessage_data_t *data;
80 
81  public:
82  SayMessage(const char * ini_text);
83  SayMessage();
84  ~SayMessage();
85 
86  SayMessage(const SayMessage *m);
87  /* Methods */
88  char * text() const;
89  void set_text(const char * new_text);
90  size_t maxlenof_text() const;
91  virtual Message * clone() const;
92  };
93 
94  virtual bool message_valid(const Message *message) const;
95  private:
98 
99  public:
100  /* Methods */
101  char * text() const;
102  void set_text(const char * new_text);
103  size_t maxlenof_text() const;
104  uint32_t msgid() const;
105  void set_msgid(const uint32_t new_msgid);
106  size_t maxlenof_msgid() const;
107  bool is_final() const;
108  void set_final(const bool new_final);
109  size_t maxlenof_final() const;
110  float duration() const;
111  void set_duration(const float new_duration);
112  size_t maxlenof_duration() const;
113  virtual Message * create_message(const char *type) const;
114 
115  virtual void copy_values(const Interface *other);
116  virtual const char * enum_tostring(const char *enumtype, int val) const;
117 
118 };
119 
120 } // end namespace fawkes
121 
122 #endif
size_t maxlenof_final() const
Get maximum length of final value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
void set_duration(const float new_duration)
Set duration value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
void set_final(const bool new_final)
Set final value.
uint32_t msgid() const
Get msgid value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
virtual Message * create_message(const char *type) const
Create message based on type name.
Fawkes library namespace.
char * text() const
Get text value.
SayMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_msgid() const
Get maximum length of msgid value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
void set_msgid(const uint32_t new_msgid)
Set msgid value.
const char * type() const
Get type of interface.
Definition: interface.cpp:651
size_t maxlenof_text() const
Get maximum length of text value.
void set_text(const char *new_text)
Set text value.
bool is_final() const
Get final value.
float duration() const
Get duration value.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
size_t maxlenof_duration() const
Get maximum length of duration value.
SpeechSynthInterface Fawkes BlackBoard Interface.