degate  0.1.2
LogicModelImporter.h
Go to the documentation of this file.
00001 /* -*-c++-*-
00002 
00003  This file is part of the IC reverse engineering tool degate.
00004 
00005  Copyright 2008, 2009, 2010 by Martin Schobert
00006 
00007  Degate is free software: you can redistribute it and/or modify
00008  it under the terms of the GNU General Public License as published by
00009  the Free Software Foundation, either version 3 of the License, or
00010  any later version.
00011 
00012  Degate is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU General Public License for more details.
00016 
00017  You should have received a copy of the GNU General Public License
00018  along with degate. If not, see <http://www.gnu.org/licenses/>.
00019 
00020 */
00021 
00022 #ifndef __LOGICMODELIMPORTER_H__
00023 #define __LOGICMODELIMPORTER_H__
00024 
00025 #include "globals.h"
00026 #include "LogicModel.h"
00027 #include "XMLImporter.h"
00028 
00029 #include <stdexcept>
00030 
00031 namespace degate {
00032 
00033 /**
00034  * This class implements a logic model loader.
00035  */
00036 class LogicModelImporter : public XMLImporter {
00037 private:
00038 
00039   unsigned int width, height;
00040   GateLibrary_shptr gate_library;
00041 
00042   std::list<Gate_shptr> gates;
00043 
00044   void parse_logic_model_element(const xmlpp::Element * const lm_element,
00045                                  LogicModel_shptr lmodel);
00046 
00047   void parse_gates_element(const xmlpp::Element * const gates_element, LogicModel_shptr lmodel);
00048 
00049   void parse_vias_element(const xmlpp::Element * const vias_element,
00050                           LogicModel_shptr lmodel) ;
00051 
00052   void parse_emarkers_element(const xmlpp::Element * const emarkers_element,
00053                               LogicModel_shptr lmodel) ;
00054 
00055   void parse_wires_element(const xmlpp::Element * const wires_element,
00056                            LogicModel_shptr lmodel);
00057 
00058   void parse_nets_element(const xmlpp::Element * const nets_element,
00059                           LogicModel_shptr lmodel);
00060 
00061   void parse_annotations_element(const xmlpp::Element * const annotations_element,
00062                                  LogicModel_shptr lmodel) ;
00063 
00064   std::list<Module_shptr> parse_modules_element(const xmlpp::Element * const modules_element,
00065                                      LogicModel_shptr lmodel) ;
00066 
00067 public:
00068 
00069   /**
00070    * Create a logic model importer.
00071    * @param _width The geometrical width of the logic model.
00072    * @param _height The geometrical height of the logic model.
00073    * @param _gate_library The gate library to resolve references to gate templates.
00074    *              The gate library is stored into the logic model. You should not set it by yourself.
00075    */
00076 
00077   LogicModelImporter(unsigned int _width, unsigned int _height, GateLibrary_shptr _gate_library) :
00078     width(_width),
00079     height(_height),
00080     gate_library(_gate_library) {}
00081 
00082 
00083   /**
00084    * Create a logic model importer. The gate library is not used to resolve references.
00085    * @param _width The geometrical width of the logic model.
00086    * @param _height The geometrical height of the logic model.
00087    */
00088 
00089   LogicModelImporter(unsigned int _width, unsigned int _height) :
00090     width(_width),
00091     height(_height) {}
00092 
00093 
00094   /**
00095    * The destructor.
00096    */
00097 
00098   ~LogicModelImporter() {}
00099 
00100   /**
00101    * import a logic model.
00102    */
00103   LogicModel_shptr import(std::string const& filename);
00104 
00105 
00106   /**
00107    * Import a logic model that is stored in a XML file into an existing logic model.
00108    */
00109   void import_into(LogicModel_shptr lmodel, std::string const& filename);
00110 
00111 };
00112 
00113 }
00114 
00115 #endif