tomwalters@84: // Copyright 2010, Thomas Walters tomwalters@84: // tomwalters@84: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@84: // http://www.acousticscale.org/AIMC tomwalters@84: // tomwalters@84: // Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@84: // you may not use this file except in compliance with the License. tomwalters@84: // You may obtain a copy of the License at tomwalters@84: // tomwalters@84: // http://www.apache.org/licenses/LICENSE-2.0 tomwalters@84: // tomwalters@84: // Unless required by applicable law or agreed to in writing, software tomwalters@84: // distributed under the License is distributed on an "AS IS" BASIS, tomwalters@84: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@84: // See the License for the specific language governing permissions and tomwalters@84: // limitations under the License. tomwalters@84: tomwalters@84: /*! \file tomwalters@84: * \brief Parse a configuration file to generate a tree of modules. tomwalters@84: */ tomwalters@84: tomwalters@84: /*! \author: Thomas Walters tomwalters@84: * \date 2010/08/08 tomwalters@84: * \version \$Id: $ tomwalters@84: */ tomwalters@84: tomwalters@121: #include tomwalters@121: #include tomwalters@84: #include tomwalters@84: tomwalters@121: #include "Support/Common.h" tomwalters@121: #include "Support/Module.h" tomwalters@121: #include "Support/Parameters.h" tomwalters@121: #include "Support/SignalBank.h" tomwalters@121: #include "Support/linked_ptr.h" tomwalters@121: tomwalters@84: namespace aimc { tomwalters@84: using std::string; tomwalters@121: using std::map; tomwalters@121: using std::ostream; tomwalters@120: tomwalters@84: class ModuleTree { tomwalters@84: public: tomwalters@121: ModuleTree(); tomwalters@121: bool LoadConfigFile(const string &filename); tomwalters@121: bool LoadConfigText(const string &config_text); tomwalters@121: string GetFullConfig(); tomwalters@121: bool Initialize(Parameters *global_parameters); tomwalters@121: void Reset(); tomwalters@121: void PrintConfiguration(ostream &out); tomwalters@121: void Process(); tomwalters@121: void MakeDotGraph(ostream &out); tomwalters@114: void set_output_filename_prefix(const string &prefix) { tomwalters@114: output_filename_prefix_ = prefix; tomwalters@121: }; tomwalters@84: string output_filename_prefix() { tomwalters@84: return output_filename_prefix_; tomwalters@121: }; tomwalters@84: private: tomwalters@121: bool ConstructTree(); tomwalters@121: Parameters config_; tomwalters@121: SignalBank s_; tomwalters@84: string output_filename_prefix_; tomwalters@121: map > modules_; tomwalters@121: Module *root_module_; tomwalters@121: map > parameters_; tomwalters@121: bool initialized_; tomwalters@84: DISALLOW_COPY_AND_ASSIGN(ModuleTree); tomwalters@84: }; tomwalters@84: } // namespace aimc