RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
generator.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Georgia Institute of Technology
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the Free
6  * Software Foundation, either version 3 of the License, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "generator.h"
19 
21  : index(0)
22  , numsamples(1)
23  , dt(1e-3)
24 {
25  wave.clear();
26  wave.push_back(0);
27 }
28 
30 {
31 }
32 
33 void
35 {
36  wave.clear();
37  wave.push_back(0);
38  index = 0;
39  numsamples = wave.size();
40 }
41 
42 void
44 {
45  wave.clear();
46  wave.push_back(0);
47  index = 0;
48  numsamples = wave.size();
49 }
50 
51 double
53 {
54  double value = wave[index];
55  index++;
56  if (index >= numsamples)
57  index = 0;
58  return value;
59 }
60 
61 double
63 {
64  double value = wave[index];
65  index++;
66  if (index >= numsamples)
67  value = 0;
68  return value;
69 }
70 
71 int
73 {
74  return numsamples;
75 }
76 
77 int
79 {
80  return index;
81 }
82 
83 void
85 {
86  index = value;
87 }
int numsamples
Definition: generator.h:56
int getIndex() const
Definition: generator.cpp:78
double getOne()
Definition: generator.cpp:62
double get()
Definition: generator.cpp:52
int numSamples() const
Definition: generator.cpp:72
int index
Definition: generator.h:55
void setIndex(int value)
Definition: generator.cpp:84
std::vector< double > wave
Definition: generator.h:54
void clear()
Definition: generator.cpp:34
void init()
Definition: generator.cpp:43