Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SpeechRecognitionInterface.h
1 
2 /***************************************************************************
3  * SpeechRecognitionInterface.h - Fawkes BlackBoard Interface - SpeechRecognitionInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2009 Tim Niemueller and Masrur Doostdar
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_SPEECHRECOGNITIONINTERFACE_H_
25 #define __INTERFACES_SPEECHRECOGNITIONINTERFACE_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(SpeechRecognitionInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  private:
42 #pragma pack(push,4)
43  /** Internal data storage, do NOT modify! */
44  typedef struct {
45  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
46  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
47  char text[1024]; /**<
48  Last spoken string. Must be properly null-terminated.
49  */
50  uint32_t counter; /**<
51  Counter for messages. Increased after each new recognized string.
52  */
53  bool processing; /**<
54  True, if the the speech recognition is currently processing.
55  */
56  bool enabled; /**<
57  True, if speech processing is currently enabled, false otherwise.
58  */
59  } SpeechRecognitionInterface_data_t;
60 #pragma pack(pop)
61 
62  SpeechRecognitionInterface_data_t *data;
63 
64  public:
65  /* messages */
66  class ResetMessage : public Message
67  {
68  private:
69 #pragma pack(push,4)
70  /** Internal data storage, do NOT modify! */
71  typedef struct {
72  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
73  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
74  } ResetMessage_data_t;
75 #pragma pack(pop)
76 
77  ResetMessage_data_t *data;
78 
79  public:
80  ResetMessage();
81  ~ResetMessage();
82 
83  ResetMessage(const ResetMessage *m);
84  /* Methods */
85  virtual Message * clone() const;
86  };
87 
88  class SetEnabledMessage : public Message
89  {
90  private:
91 #pragma pack(push,4)
92  /** Internal data storage, do NOT modify! */
93  typedef struct {
94  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
95  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
96  bool enabled; /**<
97  True, if speech processing is currently enabled, false otherwise.
98  */
99  } SetEnabledMessage_data_t;
100 #pragma pack(pop)
101 
102  SetEnabledMessage_data_t *data;
103 
104  public:
105  SetEnabledMessage(const bool ini_enabled);
108 
110  /* Methods */
111  bool is_enabled() const;
112  void set_enabled(const bool new_enabled);
113  size_t maxlenof_enabled() const;
114  virtual Message * clone() const;
115  };
116 
117  virtual bool message_valid(const Message *message) const;
118  private:
121 
122  public:
123  /* Methods */
124  char * text() const;
125  void set_text(const char * new_text);
126  size_t maxlenof_text() const;
127  uint32_t counter() const;
128  void set_counter(const uint32_t new_counter);
129  size_t maxlenof_counter() const;
130  bool is_processing() const;
131  void set_processing(const bool new_processing);
132  size_t maxlenof_processing() const;
133  bool is_enabled() const;
134  void set_enabled(const bool new_enabled);
135  size_t maxlenof_enabled() const;
136  virtual Message * create_message(const char *type) const;
137 
138  virtual void copy_values(const Interface *other);
139  virtual const char * enum_tostring(const char *enumtype, int val) const;
140 
141 };
142 
143 } // end namespace fawkes
144 
145 #endif
size_t maxlenof_text() const
Get maximum length of text value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:43
virtual Message * clone() const
Clone this message.
SetEnabledMessage Fawkes BlackBoard Interface Message.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
void set_processing(const bool new_processing)
Set processing value.
bool is_processing() const
Get processing value.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
void set_counter(const uint32_t new_counter)
Set counter value.
void set_text(const char *new_text)
Set text value.
size_t maxlenof_processing() const
Get maximum length of processing value.
bool is_enabled() const
Get enabled value.
void set_enabled(const bool new_enabled)
Set enabled value.
void set_enabled(const bool new_enabled)
Set enabled value.
size_t maxlenof_counter() const
Get maximum length of counter value.
SpeechRecognitionInterface Fawkes BlackBoard Interface.
virtual Message * clone() const
Clone this message.
size_t maxlenof_enabled() const
Get maximum length of enabled value.
virtual Message * create_message(const char *type) const
Create message based on type name.
ResetMessage Fawkes BlackBoard Interface Message.
virtual void copy_values(const Interface *other)
Copy values from other interface.
const char * type() const
Get type of interface.
Definition: interface.cpp:635
uint32_t counter() const
Get counter value.
size_t maxlenof_enabled() const
Get maximum length of enabled value.