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