RTXI 1.3
plugins/include/generator.cpp
Go to the documentation of this file.
00001 /*
00002  Copyright (C) 2011 Georgia Institute of Technology
00003 
00004  This program is free software: you can redistribute it and/or modify
00005  it under the terms of the GNU General Public License as published by
00006  the Free Software Foundation, either version 3 of the License, or
00007  (at your option) any later version.
00008 
00009  This program is distributed in the hope that it will be useful,
00010  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  GNU General Public License for more details.
00013 
00014  You should have received a copy of the GNU General Public License
00015  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017  */
00018 
00019 #include "generator.h"
00020 
00021 Generator::Generator() :
00022   index(0), numsamples(1), dt(1e-3)
00023 {
00024   wave.clear();
00025   wave.push_back(0);
00026 }
00027 
00028 Generator::~Generator()
00029 {
00030 }
00031 
00032 void
00033 Generator::clear()
00034 {
00035   wave.clear();
00036   wave.push_back(0);
00037   index = 0;
00038   numsamples = wave.size();
00039 }
00040 
00041 void
00042 Generator::init()
00043 {
00044   wave.clear();
00045   wave.push_back(0);
00046   index = 0;
00047   numsamples = wave.size();
00048 }
00049 
00050 double
00051 Generator::get()
00052 {
00053   double value = wave[index];
00054   index++;
00055   if (index >= numsamples)
00056     index = 0;
00057   return value;
00058 
00059 }
00060 
00061 double
00062 Generator::getOne()
00063 {
00064   double value = wave[index];
00065   index++;
00066   if (index >= numsamples)
00067     value = 0;
00068   return value;
00069 
00070 }
00071 int
00072 Generator::numSamples() const
00073 {
00074   return numsamples;
00075 }
00076 
00077 int
00078 Generator::getIndex() const
00079 {
00080   return index;
00081 }
00082 
00083 void
00084 Generator::setIndex(int value)
00085 {
00086   index = value;
00087 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines