• R/O
  • SSH
  • HTTPS

hands-free: 提交


Commit MetaInfo

修订版65 (tree)
时间2011-05-22 14:24:24
作者(del#42492)

Log Message

StdoutView を使うのではなく、サンプルとしては専用の View を作ることにした。

更改概述

差异

--- trunk/main/app/sample/helloworld/main.cpp (revision 64)
+++ trunk/main/app/sample/helloworld/main.cpp (revision 65)
@@ -2,12 +2,16 @@
22 #include <spcf/core/Engine.hpp>
33 #include <spcf/core/GrammarPhrase.hpp>
44 #include <spcf/core/GrammarTransition.hpp>
5+#include <spcf/core/Recognition.hpp>
56 #include <spcf/engine-factory/EngineFactory.hpp>
67 #include <spcf/grammar/GrammarCommonImpl.hpp>
78 #include <spcf/processor/DefaultProcessor.hpp>
8-#include <spcf/view/StdoutView.hpp>
9+#include <spcf/view/DefaultView.hpp>
910
11+#include <iostream>
12+
1013 using namespace spcf;
14+using namespace std;
1115
1216 class HelloWorldGrammar : public GrammarCommonImpl {
1317 public:
@@ -27,11 +31,18 @@
2731 }
2832 };
2933
34+class HelloWorldView : public DefaultView {
35+public:
36+ void recognized(Context& context, Recognition& recognition) {
37+ cout << recognition.getText() << endl;
38+ }
39+};
40+
3041 int main() {
3142 Controller controller;
3243 controller.setEngine(EngineFactory::getEngine(EngineFactory::SAPI_ENGINE));
3344 controller.setProcessor(ProcessorPtr(new HelloWorldProcessor()));
34- controller.setView(ViewPtr(new StdoutView()));
45+ controller.setView(ViewPtr(new HelloWorldView()));
3546 controller.start();
3647
3748 return 0;
Show on old repository browser