|
degate 0.1.1
|
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 __GATEPORT_H__ 00023 #define __GATEPORT_H__ 00024 00025 #include "globals.h" 00026 00027 #include "ConnectedLogicModelObject.h" 00028 #include "Rectangle.h" 00029 #include "Gate.h" 00030 #include "GateTemplatePort.h" 00031 #include <set> 00032 00033 #include <tr1/memory> 00034 00035 namespace degate { 00036 00037 /** 00038 * This class represents a port of a gate. 00039 * @todo Dispatch get_fill/frame_color() calls to 00040 * GateTemplatePort::get_xxx_color(). Make sure, that colors 00041 * are updated when changes are made in the PortColorManager. 00042 */ 00043 class GatePort : public Circle, public ConnectedLogicModelObject { 00044 00045 private: 00046 00047 std::tr1::shared_ptr<Gate> gate; 00048 std::tr1::shared_ptr<GateTemplatePort> gate_template_port; 00049 object_id_t template_port_id; 00050 00051 public: 00052 00053 00054 00055 /** 00056 * Create a gate port and set a "reference" to the the template port. 00057 * 00058 * @param _gate A shared pointer to the gate, the port is created for. 00059 * @param _gate_template_port A shared pointer to a template port. 00060 * @param _diameter The diameter of the port. 00061 */ 00062 GatePort(std::tr1::shared_ptr<Gate> _gate, 00063 std::tr1::shared_ptr<GateTemplatePort> _gate_template_port, 00064 unsigned int _diameter = 5); 00065 00066 /** 00067 * Create a gate port. 00068 * 00069 * @param _gate A shared pointer to the gate, the port is created for. 00070 * @param diameter The diameter of the port. 00071 */ 00072 GatePort(std::tr1::shared_ptr<Gate> _gate, unsigned int _diameter = 5); 00073 00074 00075 /** 00076 * The destructor. 00077 */ 00078 00079 virtual ~GatePort() {} 00080 00081 /** 00082 * Set the ID of the template port. 00083 */ 00084 00085 virtual void set_template_port_type_id(object_id_t _template_port_id); 00086 00087 /** 00088 * Get the ID of the template port. 00089 */ 00090 00091 virtual object_id_t get_template_port_type_id() const; 00092 00093 /** 00094 * Get the template port. 00095 */ 00096 00097 virtual GateTemplatePort_shptr get_template_port(); 00098 00099 /** 00100 * Get the template port. 00101 */ 00102 00103 virtual const GateTemplatePort_shptr get_template_port() const; 00104 00105 /** 00106 * Set the template port. 00107 */ 00108 00109 virtual void set_template_port(std::tr1::shared_ptr<GateTemplatePort> 00110 _gate_template_port); 00111 00112 00113 /** 00114 * Check if there is a template port defined. 00115 */ 00116 00117 virtual bool has_template_port() const; 00118 00119 /** 00120 * Check if a gate port already belongs to a gate. 00121 * Normally a gate port belongs to a gate. 00122 */ 00123 00124 virtual bool is_assigned_to_a_gate() const; 00125 00126 00127 /** 00128 * Get the gate, this gate port belongs to. 00129 * @return Returns a shared pointer to a gate. A pointer value 00130 * of NULL indicates, that the gate port is not assigned to a gate. 00131 * @see has_gate() 00132 */ 00133 00134 std::tr1::shared_ptr<Gate> get_gate(); 00135 00136 00137 /** 00138 * Get a human readable string that describes the whole 00139 * logic model object. The string should be unique in order 00140 * to let the user identify the concrete object. But that 00141 * is not a must. 00142 */ 00143 00144 virtual const std::string get_descriptive_identifier() const; 00145 00146 /** 00147 * Get a human readable string that names the object type. 00148 * Here it is "Gate port". 00149 */ 00150 00151 virtual const std::string get_object_type_name() const; 00152 00153 00154 /** 00155 * Print gate port. 00156 */ 00157 00158 void print(std::ostream & os = std::cout, int n_tabs = 0) const; 00159 00160 00161 00162 /** 00163 * Set the absolute position of a port. 00164 */ 00165 00166 void set_x(int x); 00167 00168 /** 00169 * Set the absolute position of a port. 00170 */ 00171 00172 void set_y(int y); 00173 00174 00175 void shift_x(int delta_x); 00176 void shift_y(int delta_y); 00177 void set_diameter(unsigned int diameter); 00178 00179 00180 00181 virtual bool in_bounding_box(BoundingBox const& bbox) const { 00182 return Circle::in_bounding_box(bbox); 00183 } 00184 00185 virtual BoundingBox const& get_bounding_box() const { 00186 return Circle::get_bounding_box(); 00187 } 00188 00189 virtual bool in_shape(int x, int y, int max_distance = 0) const { 00190 return Circle::in_shape(x, y, max_distance); 00191 } 00192 00193 }; 00194 00195 } 00196 00197 #endif
1.7.4