annotate doc/ModuleTemplate.cc @ 232:af531fc3f280

- Massive refactoring to make module tree stuff work. In theory we now support configuration files again. The graphics stuff is untested as yet.
author tomwalters
date Mon, 18 Oct 2010 04:42:28 +0000
parents c5f5e9569863
children
rev   line source
tomwalters@11 1 // Copyright #YEAR#, #AUTHOR_NAME#
tomwalters@11 2 //
tomwalters@11 3 // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@11 4 // http://www.acousticscale.org/AIMC
tomwalters@11 5 //
tomwalters@45 6 // Licensed under the Apache License, Version 2.0 (the "License");
tomwalters@45 7 // you may not use this file except in compliance with the License.
tomwalters@45 8 // You may obtain a copy of the License at
tomwalters@11 9 //
tomwalters@45 10 // http://www.apache.org/licenses/LICENSE-2.0
tomwalters@11 11 //
tomwalters@45 12 // Unless required by applicable law or agreed to in writing, software
tomwalters@45 13 // distributed under the License is distributed on an "AS IS" BASIS,
tomwalters@45 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
tomwalters@45 15 // See the License for the specific language governing permissions and
tomwalters@45 16 // limitations under the License.
tomwalters@11 17
tomwalters@11 18 /*!
tomwalters@11 19 * \author #AUTHOR_NAME# <#AUTHOR_EMAIL_ADDRESS#>
tomwalters@11 20 * \date created #TODAYS_DATE#
tomwalters@11 21 * \version \$Id$
tomwalters@11 22 */
tomwalters@11 23
tomwalters@11 24 #include "Modules/#MODULE_TYPE#/#MODULE_NAME#.h"
tomwalters@11 25
tomwalters@11 26 namespace aimc {
tomwalters@11 27 #MODULE_NAME#::#MODULE_NAME#(Parameters *params) : Module(params) {
tomwalters@11 28 module_description_ = "TODO: Short Description of the module";
tomwalters@11 29 module_identifier_ = "TODO: one-word id for the module";
tomwalters@11 30 module_type_ = "TODO: type code eg. bmm, sai";
tomwalters@11 31 module_version_ = "$Id$";
tomwalters@11 32
tomwalters@11 33 // Read parameter values from the parameter store. Setting any default
tomwalters@11 34 // values as necessary. The module should set defaults for all parameters
tomwalters@11 35 // that is uses here. The parameters_->DefaultType() methods look for a
tomwalters@11 36 // parameter with a given name. If it already exists in the parameter
tomwalters@11 37 // store, they return the current value. If the parameter doesn't already
tomwalters@11 38 // exist, it is added, set to the default value given, and that value is
tomwalters@11 39 // returned.
tomwalters@11 40 // Examples:
tomwalters@11 41 // integer_param_ = parameters_->DefaultInt("module.param_name", 4);
tomwalters@12 42 // boolean_param_ = parameters_->DefaultBool("module.param_name", true);
tomwalters@11 43 // float_param_ = parameters_->DefaultFloat("module.param_name", 4.4f);
tomwalters@11 44 }
tomwalters@11 45
tomwalters@11 46 #MODULE_NAME#::~#MODULE_NAME#() {
tomwalters@11 47 }
tomwalters@11 48
tomwalters@11 49 bool #MODULE_NAME#::InitializeInternal(const SignalBank &input) {
tomwalters@11 50 // Copy the parameters of the input signal bank into internal variables, so
tomwalters@11 51 // that they can be checked later.
tomwalters@11 52 sample_rate_ = input.sample_rate();
tomwalters@11 53 buffer_length_ = input.buffer_length();
tomwalters@11 54 channel_count_ = input.channel_count();
tomwalters@11 55
tomwalters@11 56 // If this module produces any output, then the output signal bank needs to
tomwalters@11 57 // be initialized here.
tomwalters@11 58 // Example:
tomwalters@11 59 // output_.Initialize(channel_count, buffer_length, sample_rate);
tomwalters@11 60 return true;
tomwalters@11 61 }
tomwalters@11 62
tomwalters@11 63 void #MODULE_NAME#::ResetInternal() {
tomwalters@11 64 // Reset any internal state variables to their default values here. After a
tomwalters@11 65 // call to ResetInternal(), the module should be in the same state as it is
tomwalters@11 66 // just after a call to InitializeInternal().
tomwalters@11 67 }
tomwalters@11 68
tomwalters@11 69 void #MODULE_NAME#::Process(const SignalBank &input) {
tomwalters@11 70 // Check to see if the module has been initialized. If not, processing
tomwalters@11 71 // should not continue.
tomwalters@11 72 if (!initialized_) {
tomwalters@12 73 LOG_ERROR(_T("Module %s not initialized."), module_identifier_.c_str());
tomwalters@11 74 return;
tomwalters@11 75 }
tomwalters@11 76
tomwalters@11 77 // Check that ths input this time is the same as the input passed to
tomwalters@11 78 // Initialize()
tomwalters@11 79 if (buffer_length_ != input.buffer_length()
tomwalters@11 80 || channel_count_ != input.channel_count()) {
tomwalters@11 81 LOG_ERROR(_T("Mismatch between input to Initialize() and input to "
tomwalters@12 82 "Process() in module %s."), module_identifier_.c_str());
tomwalters@11 83 return;
tomwalters@11 84 }
tomwalters@11 85
tomwalters@11 86 // Input is read from the input signal bank using calls like
tomwalters@11 87 // float value = input_.sample(channel_number, sample_index);
tomwalters@11 88
tomwalters@11 89 // Output is fed into the output signal bank (assuming that it was
tomwalters@11 90 // initialized during the call to InitializeInternal()) like this:
tomwalters@11 91 // output_.set_sample(channel_number, sample_index, sample_value);
tomwalters@11 92
tomwalters@11 93 // If the output bank is set up, a call to PushOutput() will pass the output
tomwalters@11 94 // on to all the target modules of this module. PushOutput() can be called
tomwalters@11 95 // multiple times within each call to Process().
tomwalters@11 96 // Example:
tomwalters@11 97 // PushOutput();
tomwalters@11 98 }
tomwalters@11 99 } // namespace aimc
tomwalters@11 100