Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SpeechNode Class Reference

A StateNode that speaks text upon startup and posts a status event on completion. More...

#include <SpeechNode.h>

Inheritance diagram for SpeechNode:

Detailed Description

A StateNode that speaks text upon startup and posts a status event on completion.

Speech text comes from three places: the text argument, a DataEvent<string>, and anything the user writes to textstream, in that order. By default, sound playback will continue even after this node has been deactivated. If this is not the desired behavior, set the autostop flag (through setAutoStop())

Definition at line 16 of file SpeechNode.h.

List of all members.

Public Member Functions

 SpeechNode (const std::string &nodename, const std::string &text="")
 constructor, specify instance name and string to speak
virtual void preStart ()
 activate the node, starts playing the text
virtual void postStart ()
 Called by start() after the doStart(), allows superclasses to complete initialization.
virtual void stop ()
 deactivate the node, doesn't stop the sound playback unless the autostop flag has been set
virtual void doEvent ()
 receive audioEGID status event and post stateMachineEGID status event
void stopPlay ()
 interrupts playing of the current sound
const std::string getText () const
 returns the stored text associated with this node
void setText (const std::string &text)
 sets the stored text associated with this node
void setShowText (bool s)
 controls whether the text will be printed as well as spoken
bool getAutoStop () const
 returns the current status of the autostop flag
void setAutoStop (bool astop)
 sets the autostop flag

Protected Attributes

std::string storedText
 text to speak, accessed through setText() and getText()
std::ostringstream textstream
 An ostringstream which the doStart can manipulate (normally by adding text).
bool showText
 flag controlling whether spoken text should also be displayed on the console
SoundManager::Play_ID curplay_id
 holds the playback identification so it can be halted any time
bool autostop
 if set to true by setAutoStop(), when this node is deactivated, playback will be halted. Otherwise, playback will continue even after the node is deactivated

Private Attributes

std::string savedText
 caches text between preStart() and postStart()
std::streampos pos
 caches stream size between preStart() and postStart()

Constructor & Destructor Documentation

SpeechNode::SpeechNode ( const std::string &  nodename,
const std::string &  text = "" 
)

constructor, specify instance name and string to speak

Definition at line 19 of file SpeechNode.h.


Member Function Documentation

virtual void SpeechNode::doEvent (  )  [virtual]

receive audioEGID status event and post stateMachineEGID status event

Reimplemented from BehaviorBase.

Definition at line 62 of file SpeechNode.h.

bool SpeechNode::getAutoStop (  )  const

returns the current status of the autostop flag

Definition at line 83 of file SpeechNode.h.

const std::string SpeechNode::getText (  )  const

returns the stored text associated with this node

Definition at line 74 of file SpeechNode.h.

virtual void SpeechNode::postStart (  )  [virtual]

Called by start() after the doStart(), allows superclasses to complete initialization.

For robustness to future change, subclasses should be sure to call the superclass implementation.

Reimplemented from BehaviorBase.

Definition at line 41 of file SpeechNode.h.

virtual void SpeechNode::preStart (  )  [virtual]

activate the node, starts playing the text

Reimplemented from BehaviorBase.

Definition at line 25 of file SpeechNode.h.

void SpeechNode::setAutoStop ( bool  astop  ) 

sets the autostop flag

Definition at line 86 of file SpeechNode.h.

void SpeechNode::setShowText ( bool  s  ) 

controls whether the text will be printed as well as spoken

Definition at line 80 of file SpeechNode.h.

void SpeechNode::setText ( const std::string &  text  ) 

sets the stored text associated with this node

Definition at line 77 of file SpeechNode.h.

virtual void SpeechNode::stop (  )  [virtual]

deactivate the node, doesn't stop the sound playback unless the autostop flag has been set

Reimplemented from StateNode.

Definition at line 55 of file SpeechNode.h.

void SpeechNode::stopPlay (  ) 

interrupts playing of the current sound

Definition at line 68 of file SpeechNode.h.

Referenced by stop().


Member Data Documentation

bool SpeechNode::autostop [protected]

if set to true by setAutoStop(), when this node is deactivated, playback will be halted. Otherwise, playback will continue even after the node is deactivated

Definition at line 93 of file SpeechNode.h.

Referenced by getAutoStop(), setAutoStop(), and stop().

holds the playback identification so it can be halted any time

Definition at line 92 of file SpeechNode.h.

Referenced by doEvent(), postStart(), and stopPlay().

std::streampos SpeechNode::pos [private]

caches stream size between preStart() and postStart()

Definition at line 97 of file SpeechNode.h.

Referenced by postStart(), and preStart().

std::string SpeechNode::savedText [private]

caches text between preStart() and postStart()

Definition at line 96 of file SpeechNode.h.

Referenced by postStart(), and preStart().

bool SpeechNode::showText [protected]

flag controlling whether spoken text should also be displayed on the console

Definition at line 91 of file SpeechNode.h.

Referenced by postStart(), and setShowText().

std::string SpeechNode::storedText [protected]

text to speak, accessed through setText() and getText()

Definition at line 89 of file SpeechNode.h.

Referenced by getText(), preStart(), and setText().

std::ostringstream SpeechNode::textstream [protected]

An ostringstream which the doStart can manipulate (normally by adding text).

Definition at line 90 of file SpeechNode.h.

Referenced by postStart(), and preStart().


The documentation for this class was generated from the following file:

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:17 2016 by Doxygen 1.6.3