|
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 __NET_H__ 00023 #define __NET_H__ 00024 00025 #include <set> 00026 #include <tr1/memory> 00027 00028 00029 #include "globals.h" 00030 00031 00032 namespace degate { 00033 00034 00035 /** 00036 * The net class represents an electrical potential that is shared 00037 * between electrically adjacent objects. 00038 * 00039 * Why do methods in class Net work with object ID instead of 00040 * shared pointers? There is an automatism. A ConnectedLogicModelObject 00041 * adds itself to a net, if you set the net for the ConnectedLogicModelObject. 00042 * And it removes itself from a Net object, if it's destructor is called. 00043 * The problem is, that the ConnectedLogicModelObject itself only 00044 * has a \p this pointer. An object can't have a shared pointer to itself. 00045 * One could work with normal pointers, but this would somehow circumvent 00046 * shared pointer approach in libdegate. So we use loosely coupled 00047 * object IDs. 00048 * 00049 * @see ConnectedLogicModelObject::set_net() 00050 * @see ConnectedLogicModelObject::remove_net() 00051 */ 00052 class Net : public LogicModelObjectBase { 00053 00054 friend class ConnectedLogicModelObject; 00055 00056 private: 00057 00058 std::set<object_id_t> connections; 00059 00060 protected: 00061 00062 /** 00063 * Add an object of type ConnectedLogicModelObject to the net. 00064 * It is silently ignored, if the object is already referenced 00065 * from the net. 00066 * @exception InvalidObjectIDException This exception is thrown 00067 * if the object has an invalid object ID. 00068 */ 00069 00070 virtual void add_object(ConnectedLogicModelObject_shptr o); 00071 00072 00073 /** 00074 * Add an object to the net. 00075 * @see add_object() 00076 */ 00077 virtual void add_object(object_id_t oid); 00078 00079 00080 /** 00081 * Remove an object from a net. 00082 * @exception CollectionLookupException Indicates that the object 00083 * is not referenced from the net. 00084 * @exception InvalidObjectIDException As in add_object(). 00085 * @see add_object() 00086 */ 00087 00088 virtual void remove_object(ConnectedLogicModelObject_shptr o); 00089 00090 /** 00091 * Remove object. 00092 * @see remove_object() 00093 */ 00094 00095 virtual void remove_object(object_id_t o); 00096 00097 00098 public: 00099 00100 typedef std::set<object_id_t>::iterator connection_iterator; 00101 typedef std::set<object_id_t>::iterator iterator; 00102 typedef std::set<object_id_t>::const_iterator const_iterator; 00103 00104 /** 00105 * Construct a new net. 00106 */ 00107 Net(); 00108 00109 /** 00110 * Destroy a net. 00111 * @see LogicModel::remove_net() 00112 */ 00113 virtual ~Net(); 00114 00115 /** 00116 * Get an iterator to iterate over all objects that are electrically connected with this net. 00117 * Be careful with iterator invalidation! 00118 */ 00119 virtual connection_iterator begin(); 00120 00121 /** 00122 * Get an end marker. 00123 */ 00124 virtual connection_iterator end(); 00125 00126 00127 /** 00128 * Get the number of objects that are connected with this net. 00129 */ 00130 00131 virtual unsigned int size() const; 00132 00133 /** 00134 * Get a human readable description for the object. 00135 */ 00136 const std::string get_descriptive_identifier() const; 00137 }; 00138 00139 } 00140 00141 #endif
1.7.4