torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
physical/InstancePin.hpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Header for the InstancePin class.
18 
19 #ifndef TORC_PHYSICAL_INSTANCEPIN_HPP
20 #define TORC_PHYSICAL_INSTANCEPIN_HPP
21 
25 #include <boost/smart_ptr.hpp>
26 
27 namespace torc {
28 namespace physical {
29 
30  /// \brief Physical design instance-pin pair, suitable for specifying a net endpoint.
31  /// \details This class specifies a pin on a physical design instance.
32  /// \sa SitePin.
33  class InstancePinBase : public Progeny<class Net>, protected Progenitor<InstancePin> {
34  protected:
35  // types
36  /// \brief Imported type name.
38  // members
39  /// \brief The pin weak instance pointer.
41  /// \brief The pin name.
43  // functions
44  /// \brief Asks the associated instance to add this pin from its pin map.
45  void addToInstance(void) { mInstancePtr.lock()->addPin(mSelfWeakPtr); }
46  /// \brief Asks the associated instance to remove this pin from its pin map.
47  void removeFromInstance(void) { mInstancePtr.lock()->removePin(mSelfWeakPtr); }
48  // constructors
49  /// \brief Protected constructor.
50  /// \param inInstancePtr The pin instance pointer.
51  /// \param inPinName The pin name.
52  InstancePinBase(InstanceSharedPtr inInstancePtr, const string& inPinName)
53  : mInstancePtr(inInstancePtr), mPinName(inPinName) {}
54  /// \brief Disabled copy constructor.
56  // operators
57  /// \brief Disabled assignment operator.
58  void operator =(const InstancePin&) {}
59  public:
60  // constructors
61  /// \brief Non-virtual destructor.
62  ~InstancePinBase(void) { if(!mInstancePtr.expired()) removeFromInstance(); }
63  // accessors
64  /// \brief Returns the weak instance pointer.
65  const InstanceWeakPtr& getInstancePtr(void) const { return mInstancePtr; }
66  /// \brief Returns the pin name.
67  const PinName& getPinName(void) const { return mPinName; }
68  /// \brief Sets the weak instance pointer.
69  void setInstancePtr(const InstanceWeakPtr& inInstancePtr) { mInstancePtr = inInstancePtr; }
70  /// \brief Sets the pin name.
71  void setPinName(const string& inPinName) { mPinName = inPinName; }
72  // operators
73  /// \brief Equality operator.
74  bool operator ==(const InstancePinBase& rhs) const {
75  return !(mInstancePtr < rhs.mInstancePtr) && !(rhs.mInstancePtr < mInstancePtr)
76  && mPinName == rhs.mPinName;
77  }
78  };
79 
80  /// \brief Physical design instance-pin pair, suitable for specifying a net endpoint.
81  /// \details This class specifies a pin on a physical design instance. Note that this class
82  /// has a TilewirePlaceholder as a base class, and is directly analogous to its
83  /// Tilewire-aware counterpart, torc::architecture::InstancePin. This approach is used to
84  /// avoid importing torc::architecture dependencies into torc::physical for users who do
85  /// not require device database functionality.
86  /// \sa SitePin.
88  // friends
89  /// \brief The Factory class has direct access to our internals.
90  friend class Factory;
91  /// \brief The Net class has direct access to our internals.
92  /// \details The parent Net can use this to direct the InstancePin to register itself with
93  /// its related Instance.
94  friend class Net;
95  protected:
96  // constructors
97  /// \brief Protected constructor.
98  /// \param inInstancePtr The pin instance pointer.
99  /// \param inPinName The pin name.
100  InstancePin(InstanceSharedPtr inInstancePtr, const string& inPinName)
101  : InstancePinBase(inInstancePtr, inPinName), TilewirePlaceholder() {}
102  private:
103  // constructors
104  /// \brief Disabled copy constructor.
107  };
108 
109  /// \brief Shared pointer encapsulation of an InstancePin.
110  typedef boost::shared_ptr<InstancePin> InstancePinSharedPtr;
111 
112  /// \brief Weak pointer encapsulation of an InstancePin.
113  typedef boost::weak_ptr<InstancePin> InstancePinWeakPtr;
114 
115  /// \brief Vector of InstancePin shared pointers.
116  typedef std::vector<InstancePinSharedPtr> InstancePinSharedPtrVector;
117 
118 } // namespace physical
119 } // namespace torc
120 
121 #endif // TORC_PHYSICAL_INSTANCEPIN_HPP
void operator=(const InstancePin &)
Disabled assignment operator.
void setInstancePtr(const InstanceWeakPtr &inInstancePtr)
Sets the weak instance pointer.
Physical design instance-pin pair, suitable for specifying a net endpoint.
const PinName & getPinName(void) const
Returns the pin name.
void addToInstance(void)
Asks the associated instance to add this pin from its pin map.
Encapsulation of a site pin name.
bool operator==(const InstancePinBase &rhs) const
Equality operator.
InstancePinBase(const InstancePin &)
Disabled copy constructor.
Header for the Instance class.
InstancePin(InstanceSharedPtr inInstancePtr, const string &inPinName)
Protected constructor.
~InstancePinBase(void)
Non-virtual destructor.
std::vector< InstancePinSharedPtr > InstancePinSharedPtrVector
Vector of InstancePin shared pointers.
Header for the TilewirePlaceholder class.
Drop-in placeholder for a Tilewire with no torc::architecture dependencies.
boost::shared_ptr< class InstancePin > InstancePinSharedPtr
Shared pointer encapsulation of an InstancePin.
std::string string
void removeFromInstance(void)
Asks the associated instance to remove this pin from its pin map.
InstancePinBase(InstanceSharedPtr inInstancePtr, const string &inPinName)
Protected constructor.
Physical design net.
void setPinName(const string &inPinName)
Sets the pin name.
Physical design instance-pin pair, suitable for specifying a net endpoint.
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
InstancePin(const InstancePin &rhs)
Disabled copy constructor.
Factory class for physical netlist elements.
Concept for any object that may have children.
Definition: Progenitor.hpp:36
Concept for any object that may have a parent.
Definition: Progeny.hpp:29
Header for the Progeny class.
InstanceWeakPtr mInstancePtr
The pin weak instance pointer.
boost::weak_ptr< class InstancePin > InstancePinWeakPtr
Weak pointer encapsulation of an InstancePin.
const InstanceWeakPtr & getInstancePtr(void) const
Returns the weak instance pointer.
std::string string
Imported type name.
WeakPtrType mSelfWeakPtr
Weak pointer this object.
Definition: Progenitor.hpp:57
boost::weak_ptr< Instance > InstanceWeakPtr
Weak pointer encapsulation of an Instance.