degate  0.1.2
ProjectImporter.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 __PROJECTIMPORTER_H__
00023 #define __PROJECTIMPORTER_H__
00024 
00025 #include "globals.h"
00026 #include "Project.h"
00027 #include "XMLImporter.h"
00028 
00029 #include <stdexcept>
00030 
00031 namespace degate {
00032 
00033 /**
00034  * Parser for degate's project files.
00035  *
00036  * The ProjectImporter parses the degate's project files. Basically this is the
00037  * file project.xml, that is present in every degate project directory.
00038  * The ProjectImporter loads associated files, e.g. the logic model file and
00039  * the gate library, as well.
00040  */
00041 class ProjectImporter : public XMLImporter {
00042 
00043 private:
00044 
00045   void parse_project_element(Project_shptr parent_prj, const xmlpp::Element * const project_node);
00046   void parse_grids_element(const xmlpp::Element * const project_node, Project_shptr prj);
00047   void parse_layers_element(const xmlpp::Element * const layers_node, Project_shptr prj);
00048   void parse_port_colors_element(const xmlpp::Element * const port_colors_elem, Project_shptr prj);
00049 
00050   void parse_colors_element(const xmlpp::Element * const port_colors_elem, Project_shptr prj);
00051 
00052   std::string get_project_filename(std::string const& dir) const;
00053 
00054   /**
00055    * Load a background image and set it to the layer. In case of a conversion
00056    * from old  single file images to tile based images, the new image is stored
00057    * in the project directory.
00058    */
00059   void load_background_image(Layer_shptr layer,
00060                              std::string const& image_filename,
00061                              Project_shptr prj);
00062 
00063 public:
00064   ProjectImporter() {}
00065   ~ProjectImporter() {}
00066 
00067   /**
00068    * Import a degate project.
00069    * @param path The parameter path specifies the project directory
00070    *             or the path to the project.xml file. It is determined automatically.
00071    * @exception InvalidPathException This exception is raised if \p path does not exists.
00072    * @exception InvalidXMLException This exception is raised if there is a parsing error.
00073    * @return Returns a pointer to a project object.
00074    */
00075   Project_shptr import(std::string const& path);
00076 
00077   /**
00078    * Import a complete degate project, including the default gate library and the logic model.
00079    * @param path The parameter path specifies the project directory
00080    *             or the path to the project.xml file. It is determined automatically.
00081    * @exception std::runtime_error If there are parsing problems.
00082    * @return Returns a pointer to a project object.
00083    */
00084   Project_shptr import_all(std::string const& path);
00085 
00086 };
00087 
00088 }
00089 
00090 #endif