00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/physical/InstancePin.hpp $ 00003 // $Id: InstancePin.hpp 10 2011-10-12 18:40:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Header for the InstancePin class. 00018 00019 #ifndef TORC_PHYSICAL_INSTANCEPIN_HPP 00020 #define TORC_PHYSICAL_INSTANCEPIN_HPP 00021 00022 #include "torc/physical/Progeny.hpp" 00023 #include "torc/physical/Instance.hpp" 00024 #include "torc/physical/TilewirePlaceholder.hpp" 00025 #include <boost/smart_ptr.hpp> 00026 00027 namespace torc { 00028 namespace physical { 00029 00030 /// \brief Physical design instance-pin pair, suitable for specifying a net endpoint. 00031 /// \details This class specifies a pin on a physical design instance. 00032 /// \sa SitePin. 00033 class InstancePinBase : public Progeny<class Net>, protected Progenitor<InstancePin> { 00034 protected: 00035 // types 00036 /// \brief Imported type name. 00037 typedef std::string string; 00038 // members 00039 /// \brief The pin weak instance pointer. 00040 InstanceWeakPtr mInstancePtr; 00041 /// \brief The pin name. 00042 PinName mPinName; 00043 // functions 00044 /// \brief Asks the associated instance to add this pin from its pin map. 00045 void addToInstance(void) { mInstancePtr.lock()->addPin(mSelfWeakPtr); } 00046 /// \brief Asks the associated instance to remove this pin from its pin map. 00047 void removeFromInstance(void) { mInstancePtr.lock()->removePin(mSelfWeakPtr); } 00048 // constructors 00049 /// \brief Protected constructor. 00050 /// \param inInstancePtr The pin instance pointer. 00051 /// \param inPinName The pin name. 00052 InstancePinBase(InstanceSharedPtr inInstancePtr, const string& inPinName) 00053 : mInstancePtr(inInstancePtr), mPinName(inPinName) {} 00054 /// \brief Disabled copy constructor. 00055 InstancePinBase(const InstancePin&) : mInstancePtr(), mPinName("") {} 00056 // operators 00057 /// \brief Disabled assignment operator. 00058 void operator =(const InstancePin&) {} 00059 public: 00060 // constructors 00061 /// \brief Non-virtual destructor. 00062 ~InstancePinBase(void) { if(!mInstancePtr.expired()) removeFromInstance(); } 00063 // accessors 00064 /// \brief Returns the weak instance pointer. 00065 const InstanceWeakPtr& getInstancePtr(void) const { return mInstancePtr; } 00066 /// \brief Returns the pin name. 00067 const PinName& getPinName(void) const { return mPinName; } 00068 /// \brief Sets the weak instance pointer. 00069 void setInstancePtr(const InstanceWeakPtr& inInstancePtr) { mInstancePtr = inInstancePtr; } 00070 /// \brief Sets the pin name. 00071 void setPinName(const string& inPinName) { mPinName = inPinName; } 00072 // operators 00073 /// \brief Equality operator. 00074 bool operator ==(const InstancePinBase& rhs) const { 00075 return !(mInstancePtr < rhs.mInstancePtr) && !(rhs.mInstancePtr < mInstancePtr) 00076 && mPinName == rhs.mPinName; 00077 } 00078 }; 00079 00080 /// \brief Physical design instance-pin pair, suitable for specifying a net endpoint. 00081 /// \details This class specifies a pin on a physical design instance. Note that this class 00082 /// has a TilewirePlaceholder as a base class, and is directly analogous to its 00083 /// Tilewire-aware counterpart, torc::architecture::InstancePin. This approach is used to 00084 /// avoid importing torc::architecture dependencies into torc::physical for users who do 00085 /// not require device database functionality. 00086 /// \sa SitePin. 00087 class InstancePin : public InstancePinBase, public TilewirePlaceholder { 00088 // friends 00089 /// \brief The Factory class has direct access to our internals. 00090 friend class Factory; 00091 /// \brief The Net class has direct access to our internals. 00092 /// \details The parent Net can use this to direct the InstancePin to register itself with 00093 /// its related Instance. 00094 friend class Net; 00095 protected: 00096 // constructors 00097 /// \brief Protected constructor. 00098 /// \param inInstancePtr The pin instance pointer. 00099 /// \param inPinName The pin name. 00100 InstancePin(InstanceSharedPtr inInstancePtr, const string& inPinName) 00101 : InstancePinBase(inInstancePtr, inPinName), TilewirePlaceholder() {} 00102 private: 00103 // constructors 00104 /// \brief Disabled copy constructor. 00105 InstancePin(const InstancePin& rhs) 00106 : InstancePinBase(rhs), TilewirePlaceholder() {} 00107 }; 00108 00109 /// \brief Shared pointer encapsulation of an InstancePin. 00110 typedef boost::shared_ptr<InstancePin> InstancePinSharedPtr; 00111 00112 /// \brief Weak pointer encapsulation of an InstancePin. 00113 typedef boost::weak_ptr<InstancePin> InstancePinWeakPtr; 00114 00115 /// \brief Vector of InstancePin shared pointers. 00116 typedef std::vector<InstancePinSharedPtr> InstancePinSharedPtrVector; 00117 00118 } // namespace physical 00119 } // namespace torc 00120 00121 #endif // TORC_PHYSICAL_INSTANCEPIN_HPP