1 /* Copyright (C) 2012  Olga Yakovleva <yakovleva.o.v@gmail.com> */
2 
3 /* This program is free software: you can redistribute it and/or modify */
4 /* it under the terms of the GNU Lesser General Public License as published by */
5 /* the Free Software Foundation, either version 2.1 of the License, or */
6 /* (at your option) any later version. */
7 
8 /* This program is distributed in the hope that it will be useful, */
9 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
10 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
11 /* GNU Lesser General Public License for more details. */
12 
13 /* You should have received a copy of the GNU Lesser General Public License */
14 /* along with this program.  If not, see <http://www.gnu.org/licenses/>. */
15 
16 #ifndef RHVOICE_HTS_INPUT_HPP
17 #define RHVOICE_HTS_INPUT_HPP
18 
19 #include "item.hpp"
20 #include "hts_label.hpp"
21 #include "events.hpp"
22 
23 namespace RHVoice
24 {
25   class hts_input
26   {
27   public:
hts_input()28     hts_input()
29     {
30     }
31 
lbegin()32     label_sequence::iterator lbegin()
33     {
34       return labels.begin();
35     }
36 
lbegin() const37     label_sequence::const_iterator lbegin() const
38     {
39       return labels.begin();
40     }
41 
lend()42     label_sequence::iterator lend()
43     {
44       return labels.end();
45     }
46 
lend() const47     label_sequence::const_iterator lend() const
48     {
49       return labels.end();
50     }
51 
ebegin()52     event_sequence::iterator ebegin()
53     {
54       return events.begin();
55     }
56 
ebegin() const57     event_sequence::const_iterator ebegin() const
58     {
59       return events.begin();
60     }
61 
eend()62     event_sequence::iterator eend()
63     {
64       return events.end();
65     }
66 
eend() const67     event_sequence::const_iterator eend() const
68     {
69       return events.end();
70     }
71 
add_label(const item & seg)72     hts_label& add_label(const item& seg)
73     {
74       hts_label lab(seg);
75       labels.push_back(lab);
76       return labels.back();
77     }
78 
79     template<class T>
add_event()80     void add_event()
81     {
82       event::pointer p(new T);
83       do_add_event(p);
84     }
85 
86     template<class T,typename A>
add_event(const A & a)87     void add_event(const A& a)
88     {
89       event::pointer p(new T(a));
90       do_add_event(p);
91     }
92 
93   private:
94     hts_input(const hts_input&);
95     hts_input& operator=(const hts_input&);
96 
do_add_event(event::pointer & p)97     void do_add_event(event::pointer& p)
98     {
99       events.push_back(p);
100       if(!labels.empty())
101         {
102           event::position pos=labels.end();
103           --pos;
104           p->set_position(pos);
105         }
106     }
107 
108     label_sequence labels;
109     event_sequence events;
110   };
111 }
112 #endif
113