SpeechSynthInterface.h

00001
00002 /***************************************************************************
00003  *  SpeechSynthInterface.h - Fawkes BlackBoard Interface - SpeechSynthInterface
00004  *
00005  *  Templated created:   Thu Oct 12 10:49:19 2006
00006  *  Copyright  2008  Tim Niemueller
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023
00024 #ifndef __INTERFACES_SPEECHSYNTHINTERFACE_H_
00025 #define __INTERFACES_SPEECHSYNTHINTERFACE_H_
00026 
00027 #include <interface/interface.h>
00028 #include <interface/message.h>
00029 #include <interface/field_iterator.h>
00030
00031 namespace fawkes {
00032
00033 class SpeechSynthInterface : public Interface
00034 {
00035  /// @cond INTERNALS
00036  INTERFACE_MGMT_FRIENDS(SpeechSynthInterface)
00037  /// @endcond
00038  public:
00039   /* constants */
00040
00041  private:
00042   /** Internal data storage, do NOT modify! */
00043   typedef struct {
00044     unsigned int msgid; /**< 
00045       The ID of the message that is currently being processed,
00046       or 0 if no message is being processed.
00047      */
00048     float duration; /**< 
00049       Length in seconds that it takes to speek the current text, -1 if
00050       unknown. This is the total duration of the current string, *not* the
00051       duration of already spoken or yet to speak text!
00052      */
00053     bool final; /**< 
00054       True, if the last text has been spoken, false if it is still running.
00055      */
00056     char text[1024]; /**< 
00057       Last spoken string. Must be properly null-terminated.
00058      */
00059   } SpeechSynthInterface_data_t;
00060
00061   SpeechSynthInterface_data_t *data;
00062
00063  public:
00064   /* messages */
00065   class SayMessage : public Message
00066   {
00067    private:
00068     /** Internal data storage, do NOT modify! */
00069     typedef struct {
00070       char text[1024]; /**< 
00071       Last spoken string. Must be properly null-terminated.
00072      */
00073     } SayMessage_data_t;
00074
00075     SayMessage_data_t *data;
00076
00077    public:
00078     SayMessage(const char * ini_text);
00079     SayMessage();
00080     ~SayMessage();
00081
00082     SayMessage(const SayMessage *m);
00083     /* Methods */
00084     char * text() const;
00085     void set_text(const char * new_text);
00086     size_t maxlenof_text() const;
00087     virtual Message * clone() const;
00088   };
00089
00090   virtual bool message_valid(const Message *message) const;
00091  private:
00092   SpeechSynthInterface();
00093   ~SpeechSynthInterface();
00094
00095  public:
00096   /* Methods */
00097   char * text() const;
00098   void set_text(const char * new_text);
00099   size_t maxlenof_text() const;
00100   unsigned int msgid() const;
00101   void set_msgid(const unsigned int new_msgid);
00102   size_t maxlenof_msgid() const;
00103   bool is_final() const;
00104   void set_final(const bool new_final);
00105   size_t maxlenof_final() const;
00106   float duration() const;
00107   void set_duration(const float new_duration);
00108   size_t maxlenof_duration() const;
00109   virtual Message * create_message(const char *type) const;
00110
00111   virtual void copy_values(const Interface *other);
00112
00113 };
00114
00115 } // end namespace fawkes
00116
00117 #endif