torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
physical/Port.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 Port class.
18 
19 #ifndef TORC_PHYSICAL_PORT_HPP
20 #define TORC_PHYSICAL_PORT_HPP
21 
22 #include "torc/physical/Named.hpp"
25 #include <boost/smart_ptr.hpp>
26 
27 // forward declaration of XdlParser within its namespace
28 namespace torc {
29  class XdlParser;
30 } // namespace torc
31 
32 namespace torc {
33 namespace physical {
34 
35  /// \brief Module input or output port.
36  /// \details This class declares a named port for the enclosing module.
37  class Port : public Named, public Progeny<class Module> {
38  // friends
39  /// \brief The Factory class has direct access to our internals.
40  friend class Factory;
41  protected:
42  // types
43  /// \brief Imported type name.
45  // members
46  /// \brief The port instance pointer.
48  /// \brief The port pin name.
50  // constructors
51  /// \brief Protected constructor.
52  /// \param inName The port name.
53  /// \param inInstancePtr The port instance pointer.
54  /// \param inPinName The port pin name.
55  Port(const string& inName, InstanceSharedPtr inInstancePtr, const string& inPinName)
56  : Named(inName), mInstancePtr(inInstancePtr), mPinName(inPinName) {}
57  public:
58  // accessors
59  /// \brief Returns a weak instance pointer.
60  const InstanceWeakPtr& getInstancePtr(void) const { return mInstancePtr; }
61  /// \brief Returns the pin name.
62  const PinName& getPinName(void) const { return mPinName; }
63  // operators
64  /// \brief Equality operator.
65  /// \details This function deems ports equal if their names are identical.
66  /// \returns true if both port names are identical, or false otherwise.
67  bool operator ==(const Port& rhs) const { return mName == rhs.mName; }
68  };
69 
70  /// \brief Shared pointer encapsulation of a Port.
71  typedef boost::shared_ptr<Port> PortSharedPtr;
72 
73  /// \brief Weak pointer encapsulation of a Port.
74  typedef boost::weak_ptr<Port> PortWeakPtr;
75 
76  /// \brief Vector of Port shared pointers.
77  typedef std::vector<PortSharedPtr> PortSharedPtrVector;
78 
79  /// \brief Temporary module port.
80  /// \details This class should only be used by XdlParser to remember the port while awaiting
81  /// the definition of the port's instance.
82  class PortTemp {
83  /// \brief The XdlParser class has direct access to our internals.
84  friend class torc::XdlParser;
85  // types
86  /// \brief Imported type name.
88  protected:
89  // members
90  /// \brief The port name.
91  string mName;
92  /// \brief The port instance.
93  string mInstance;
94  /// \brief The port pin.
95  string mPin;
96  // constructors
97  /// \param inName The port name.
98  /// \param inInstance The port instance.
99  /// \param inPin The port pin.
100  PortTemp(const string& inName, const string& inInstance, const string& inPin)
101  : mName(inName), mInstance(inInstance), mPin(inPin) {}
102  // accessors
103  /// \brief Returns the port name.
104  const string& getName(void) const { return mName; }
105  /// \brief Returns the port instance.
106  const string& getInstance(void) const { return mInstance; }
107  /// \brief Returns the port instance pin.
108  const string& getPin(void) const { return mPin; }
109  };
110 
111  /// \brief Vector
112  typedef std::vector<PortTemp> PortTempVector;
113 
114 
115 } // namespace physical
116 } // namespace torc
117 
118 #endif // TORC_PHYSICAL_PORT_HPP
const string & getInstance(void) const
Returns the port instance.
A Bison parser.
Definition: XdlParser.hpp:149
PortTemp(const string &inName, const string &inInstance, const string &inPin)
Encapsulation of a site pin name.
string mName
The name of the object.
Definition: Named.hpp:43
Header for the Instance class.
boost::shared_ptr< Port > PortSharedPtr
Shared pointer encapsulation of a Port.
boost::weak_ptr< Port > PortWeakPtr
Weak pointer encapsulation of a Port.
const PinName & getPinName(void) const
Returns the pin name.
Concept for any object that can be named.
Definition: Named.hpp:36
string mPin
The port pin.
string mInstance
The port instance.
std::string string
Imported type name.
std::string string
Header for the Named class.
InstanceWeakPtr mInstancePtr
The port instance pointer.
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
Factory class for physical netlist elements.
std::vector< PortTemp > PortTempVector
Vector.
string mName
The port name.
Concept for any object that may have a parent.
Definition: Progeny.hpp:29
Header for the Progeny class.
PinName mPinName
The port pin name.
const string & getPin(void) const
Returns the port instance pin.
Port(const string &inName, InstanceSharedPtr inInstancePtr, const string &inPinName)
Protected constructor.
Module input or output port.
const string & getName(void) const
Returns the port name.
Temporary module port.
std::string string
Imported type name.
const InstanceWeakPtr & getInstancePtr(void) const
Returns a weak instance pointer.
boost::weak_ptr< Instance > InstanceWeakPtr
Weak pointer encapsulation of an Instance.
std::vector< PortSharedPtr > PortSharedPtrVector
Vector of Port shared pointers.
bool operator==(const Port &rhs) const
Equality operator.