annotate trunk/doc/ModuleTemplate.cc @ 283:ef14c9f2c1d2

-Added modules template -Changed header guard style to be more consistent with the Google style guide -Added Doyxfile to generate doxygen documentation -Added structure diagram -Updated swig script to reflect new modules -Changes Gaussians back to using floats and changed tolerance on tests - doubles are unnecessary here
author tomwalters
date Fri, 19 Feb 2010 12:15:56 +0000
parents
children fb52ca0e6339
rev   line source
tomwalters@283 1 // Copyright #YEAR#, #AUTHOR_NAME#
tomwalters@283 2 //
tomwalters@283 3 // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@283 4 // http://www.acousticscale.org/AIMC
tomwalters@283 5 //
tomwalters@283 6 // This program is free software: you can redistribute it and/or modify
tomwalters@283 7 // it under the terms of the GNU General Public License as published by
tomwalters@283 8 // the Free Software Foundation, either version 3 of the License, or
tomwalters@283 9 // (at your option) any later version.
tomwalters@283 10 //
tomwalters@283 11 // This program is distributed in the hope that it will be useful,
tomwalters@283 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@283 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@283 14 // GNU General Public License for more details.
tomwalters@283 15 //
tomwalters@283 16 // You should have received a copy of the GNU General Public License
tomwalters@283 17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
tomwalters@283 18
tomwalters@283 19 /*!
tomwalters@283 20 * \author #AUTHOR_NAME# <#AUTHOR_EMAIL_ADDRESS#>
tomwalters@283 21 * \date created #TODAYS_DATE#
tomwalters@283 22 * \version \$Id$
tomwalters@283 23 */
tomwalters@283 24
tomwalters@283 25 #include "Modules/#MODULE_TYPE#/#MODULE_NAME#.h"
tomwalters@283 26
tomwalters@283 27 namespace aimc {
tomwalters@283 28 #MODULE_NAME#::#MODULE_NAME#(Parameters *params) : Module(params) {
tomwalters@283 29 module_description_ = "TODO: Short Description of the module";
tomwalters@283 30 module_identifier_ = "TODO: one-word id for the module";
tomwalters@283 31 module_type_ = "TODO: type code eg. bmm, sai";
tomwalters@283 32 module_version_ = "$Id$";
tomwalters@283 33
tomwalters@283 34 // Read parameter values from the parameter store. Setting any default
tomwalters@283 35 // values as necessary. The module should set defaults for all parameters
tomwalters@283 36 // that is uses here. The parameters_->DefaultType() methods look for a
tomwalters@283 37 // parameter with a given name. If it already exists in the parameter
tomwalters@283 38 // store, they return the current value. If the parameter doesn't already
tomwalters@283 39 // exist, it is added, set to the default value given, and that value is
tomwalters@283 40 // returned.
tomwalters@283 41 // Examples:
tomwalters@283 42 // integer_param_ = parameters_->DefaultInt("module.param_name", 4);
tomwalters@283 43 // boolean_param_ = parameters_->DefaultBool("module.param_name", True);
tomwalters@283 44 // float_param_ = parameters_->DefaultFloat("module.param_name", 4.4f);
tomwalters@283 45 }
tomwalters@283 46
tomwalters@283 47 #MODULE_NAME#::~#MODULE_NAME#() {
tomwalters@283 48 }
tomwalters@283 49
tomwalters@283 50 bool #MODULE_NAME#::InitializeInternal(const SignalBank &input) {
tomwalters@283 51 // Copy the parameters of the input signal bank into internal variables, so
tomwalters@283 52 // that they can be checked later.
tomwalters@283 53 sample_rate_ = input.sample_rate();
tomwalters@283 54 buffer_length_ = input.buffer_length();
tomwalters@283 55 channel_count_ = input.channel_count();
tomwalters@283 56
tomwalters@283 57 // If this module produces any output, then the output signal bank needs to
tomwalters@283 58 // be initialized here.
tomwalters@283 59 // Example:
tomwalters@283 60 // output_.Initialize(channel_count, buffer_length, sample_rate);
tomwalters@283 61 return true;
tomwalters@283 62 }
tomwalters@283 63
tomwalters@283 64 void #MODULE_NAME#::ResetInternal() {
tomwalters@283 65 // Reset any internal state variables to their default values here. After a
tomwalters@283 66 // call to ResetInternal(), the module should be in the same state as it is
tomwalters@283 67 // just after a call to InitializeInternal().
tomwalters@283 68 }
tomwalters@283 69
tomwalters@283 70 void #MODULE_NAME#::Process(const SignalBank &input) {
tomwalters@283 71 // Check to see if the module has been initialized. If not, processing
tomwalters@283 72 // should not continue.
tomwalters@283 73 if (!initialized_) {
tomwalters@283 74 LOG_ERROR(_T("Module #MODULE_NAME# not initialized."));
tomwalters@283 75 return;
tomwalters@283 76 }
tomwalters@283 77
tomwalters@283 78 // Check that ths input this time is the same as the input passed to
tomwalters@283 79 // Initialize()
tomwalters@283 80 if (buffer_length_ != input.buffer_length()
tomwalters@283 81 || channel_count_ != input.channel_count()) {
tomwalters@283 82 LOG_ERROR(_T("Mismatch between input to Initialize() and input to "
tomwalters@283 83 "Process() in module %s", module_identifier_));
tomwalters@283 84 return;
tomwalters@283 85 }
tomwalters@283 86
tomwalters@283 87 // Input is read from the input signal bank using calls like
tomwalters@283 88 // float value = input_.sample(channel_number, sample_index);
tomwalters@283 89
tomwalters@283 90 // Output is fed into the output signal bank (assuming that it was
tomwalters@283 91 // initialized during the call to InitializeInternal()) like this:
tomwalters@283 92 // output_.set_sample(channel_number, sample_index, sample_value);
tomwalters@283 93
tomwalters@283 94 // If the output bank is set up, a call to PushOutput() will pass the output
tomwalters@283 95 // on to all the target modules of this module. PushOutput() can be called
tomwalters@283 96 // multiple times within each call to Process().
tomwalters@283 97 // Example:
tomwalters@283 98 // PushOutput();
tomwalters@283 99 }
tomwalters@283 100 } // namespace aimc
tomwalters@283 101