degate 0.1.1
Project.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 __PROJECT_H__
00023 #define __PROJECT_H__
00024 
00025 #include <degate.h>
00026 #include <globals.h>
00027 #include <LogicModel.h>
00028 #include <PortColorManager.h>
00029 #include <RCBase.h>
00030 
00031 #include <string>
00032 #include <list>
00033 #include <tr1/memory>
00034 
00035 #include <time.h>
00036 
00037 namespace degate {
00038 
00039   class Project;
00040   typedef std::list<std::tr1::shared_ptr<Project> > ProjectList;
00041   typedef std::tr1::shared_ptr<Project> Project_shptr;
00042 }
00043 
00044 #include "ProjectImporter.h"
00045 
00046 namespace degate {
00047 
00048   /**
00049    * The project class is a container for project related data.
00050    *
00051    */
00052 
00053   class Project {
00054 
00055   private:
00056 
00057     BoundingBox bounding_box;
00058 
00059     std::string name;
00060     std::string description;
00061     std::string degate_version;
00062     std::string directory;
00063     std::string server_url;
00064 
00065     RegularGrid_shptr regular_horizontal_grid;
00066     RegularGrid_shptr regular_vertical_grid;
00067     IrregularGrid_shptr irregular_horizontal_grid;
00068     IrregularGrid_shptr irregular_vertical_grid;
00069 
00070     bool changed;
00071     time_t last_persistent_version;
00072 
00073     diameter_t default_pin_diameter;
00074     diameter_t default_wire_diameter;
00075     diameter_t default_port_diameter;
00076     length_t lambda;
00077 
00078     transaction_id_t last_transaction_id;
00079 
00080     LogicModel_shptr logic_model;
00081 
00082     PortColorManager_shptr port_color_manager;
00083 
00084     default_colors_t default_colors;
00085 
00086     double pixel_per_um;
00087     int template_dimension;
00088 
00089     RCBase::container_type rcv_blacklist;
00090 
00091     unsigned int font_size;
00092 
00093   private:
00094 
00095     void init_default_values();
00096 
00097   public:
00098 
00099     /**
00100      * Create a new and empty project.
00101      * It will create an empty logic model as well.
00102      */
00103 
00104     Project(length_t width, length_t height);
00105 
00106     /**
00107      * Create a new and empty project.
00108      * It will create an empty logic model as well.
00109      */
00110 
00111     Project(length_t width, length_t height, std::string const& _directory, unsigned int layers = 0);
00112 
00113 
00114     /**
00115      * The destructor.
00116      */
00117 
00118     virtual ~Project();
00119 
00120     /**
00121      * Set the project directory.
00122      */
00123 
00124     void set_project_directory(std::string const& _directory);
00125 
00126     /**
00127      * Get the project directory.
00128      */
00129 
00130     std::string const& get_project_directory();
00131 
00132     /**
00133      * Get the bounding box that represents the covered area for this project.
00134      */
00135 
00136     BoundingBox const& get_bounding_box() const;
00137 
00138     /**
00139      * Get the width of the project.
00140      */
00141 
00142     unsigned int get_width() const;
00143 
00144     /**
00145      * get the height of a project.
00146      */
00147 
00148     unsigned int get_height() const;
00149 
00150     /**
00151      * Get the logic model. The logic model should be present all time. This means
00152      * that you can call this method and should not receive a NULL pointer.
00153      */
00154 
00155     LogicModel_shptr get_logic_model();
00156 
00157     /**
00158      * Set the logic model for a project.
00159      * If you reset the logic model, the old logic model will be destroyed.
00160      */
00161 
00162     void set_logic_model(LogicModel_shptr _logic_model);
00163 
00164 
00165     void set_name(std::string _name);
00166     std::string const& get_name() const;
00167 
00168     void set_description(std::string _description);
00169     std::string const& get_description() const;
00170 
00171     void set_degate_version(std::string version_str);
00172     std::string const& get_degate_version();
00173 
00174     void set_lambda(length_t l);
00175     length_t get_lambda() const;
00176 
00177     void set_default_pin_diameter(diameter_t pin_diameter);
00178     diameter_t get_default_pin_diameter() const;
00179 
00180     void set_default_wire_diameter(diameter_t wire_diameter);
00181     diameter_t get_default_wire_diameter() const;
00182 
00183     void set_default_port_diameter(diameter_t port_diameter);
00184     diameter_t get_default_port_diameter() const;
00185 
00186 
00187     /**
00188      * Set the default color for an entity.
00189      */
00190     void set_default_color(ENTITY_COLOR e, color_t c);
00191 
00192     /**
00193      * Get the default color for an entity.
00194      * @return Returns the default color. If there is no default setting
00195      *   0 is returned.
00196      */
00197     color_t get_default_color(ENTITY_COLOR e) const;
00198 
00199     /**
00200      * Get all color defaults.
00201      */
00202     const default_colors_t get_default_colors() const;
00203 
00204     /**
00205      * Set changed flag to indicate that the project data was changed.
00206      *
00207      * This method is normally called from the GUI.
00208      * If the project was saved to disc, the code should call set_changed(false). Project
00209      * saving is implemented in ProjectExporter, but because the ProjectExporter might be used
00210      * for different purposes, this method must be called from the GUI code.
00211      */
00212 
00213     void set_changed(bool state = true);
00214 
00215     /**
00216      * Check if the project was changed.
00217      */
00218 
00219     bool is_changed() const;
00220 
00221     /**
00222      * Get time since last "save".
00223      * @return Returns the time in seconds since the project change state was set to false.
00224      * @see set_changed()
00225      */
00226 
00227     time_t get_time_since_last_save() const;
00228 
00229     /**
00230      * Reset last save counter.
00231      */
00232 
00233     void reset_last_saved_counter();
00234 
00235 
00236     RegularGrid_shptr get_regular_horizontal_grid();
00237     RegularGrid_shptr get_regular_vertical_grid();
00238     IrregularGrid_shptr get_irregular_horizontal_grid();
00239     IrregularGrid_shptr get_irregular_vertical_grid();
00240 
00241     PortColorManager_shptr get_port_color_manager();
00242 
00243     /**
00244      * Dump basic meta data for the project as human readable text into an ostream.
00245      */
00246 
00247     void print(std::ostream &);
00248 
00249     /**
00250      * Dump most meta data for the project as human readable text into an ostream.
00251      */
00252 
00253     void print_all(std::ostream &);
00254 
00255     /**
00256      * Set server url.
00257      */
00258 
00259     void set_server_url(std::string const& server_url);
00260 
00261     /**
00262      * Get server url.
00263      */
00264 
00265     std::string get_server_url() const;
00266 
00267 
00268     /**
00269      * Get the last pulled transaction ID.
00270      */
00271 
00272     transaction_id_t get_last_pulled_tid() const;
00273 
00274     /**
00275      * Set last pulled transaction ID.
00276      */
00277 
00278     void set_last_pulled_tid(transaction_id_t tid);
00279 
00280 
00281     /**
00282      * Get the ratio of pixels per micrometer.
00283      */
00284     double get_pixel_per_um() const;
00285 
00286     /**
00287      * Get the ratio of pixels per micrometer.
00288      */
00289     void set_pixel_per_um(double pix_per_um);
00290 
00291 
00292     /**
00293      * Get the template dimension. This is either the height or the width of a gate (template).
00294      */
00295     int get_template_dimension() const;
00296 
00297     /**
00298      * Set the template dimension.
00299      */
00300     void set_template_dimension(int template_dimension);
00301 
00302     /**
00303      * Set the default font size.
00304      */
00305     void set_font_size(unsigned int font_size);
00306 
00307     /**
00308      * Get the default font size.
00309      */
00310     unsigned int get_font_size() const;
00311 
00312     /**
00313      * Get a list of blacklisted Rule Check violations.
00314      */
00315     RCBase::container_type & get_rcv_blacklist();
00316 
00317   };
00318 
00319 }
00320 
00321 #endif