torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InstanceReference.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 InstanceReference class.
18 
19 #ifndef TORC_PHYSICAL_INSTANCEREFERENCE_HPP
20 #define TORC_PHYSICAL_INSTANCEREFERENCE_HPP
21 
22 #include <string>
23 #include <boost/smart_ptr.hpp>
24 
25 namespace torc {
26 namespace physical {
27 
28  /// \brief Instantiation of a module instance.
29  /// \details This class references a module instance. It is used in cases where a module has
30  /// been instantiated in a design, and instances appearing in that design point back to
31  /// the module instances they were instantiated from.
33  // friends
34  /// \brief The Factory class has direct access to our internals.
35  friend class Factory;
36  protected:
37  // types
38  /// \brief Imported type name.
40  /// \brief Local forward declaration of InstanceSharedPtr to avoid dependency loops.
41  typedef boost::shared_ptr<class Instance> InstanceSharedPtr;
42  /// \brief Local forward declaration of InstanceWeakPtr to avoid dependency loops.
43  typedef boost::weak_ptr<class Instance> InstanceWeakPtr;
44  /// \brief Local forward declaration of ModuleSharedPtr to avoid dependency loops.
45  typedef boost::shared_ptr<class Module> ModuleSharedPtr;
46  /// \brief Local forward declaration of ModuleWeakPtr to avoid dependency loops.
47  typedef boost::weak_ptr<class Module> ModuleWeakPtr;
48  // members
49  /// \brief The module instantiation name.
50  /// \details The instantiation name is the name under which the module was instantiated.
52  /// \brief The module weak pointer.
54  /// \brief The instance weak pointer.
55  /// \details The instance pointer points to the module instance that this object references.
57  // constructors
58  /// \brief Protected constructor.
59  /// \param inInstantiationName The name under which the reference module was instantiated.
60  /// \param inModulePtr The module containing the referenced instance.
61  /// \param inInstancePtr The instance being referenced.
62  InstanceReference(const string& inInstantiationName, ModuleSharedPtr inModulePtr,
63  InstanceSharedPtr inInstancePtr) : mInstantiationName(inInstantiationName),
64  mModulePtr(inModulePtr), mInstancePtr(inInstancePtr) {}
65  public:
66  // accessors
67  /// \brief Returns the weak module pointer.
68  const ModuleWeakPtr& getModulePtr(void) const { return mModulePtr; }
69  /// \brief Returns the weak instance pointer.
70  const InstanceWeakPtr& getInstancePtr(void) const { return mInstancePtr; }
71  /// \brief Returns the instantiation name.
72  const string& getInstantiationName(void) const { return mInstantiationName; }
73  // Setting accessors will be provided if necessary.
74  // operators
75  /// \brief Equality operator.
76  bool operator ==(const InstanceReference& rhs) const {
77  return !(mInstancePtr < rhs.mInstancePtr) && !(rhs.mInstancePtr < mInstancePtr)
78  && !(mModulePtr < rhs.mModulePtr) && !(rhs.mModulePtr < mModulePtr)
80  }
81  };
82 
83  /// \brief Shared pointer encapsulation of an InstanceReference.
84  typedef boost::shared_ptr<InstanceReference> InstanceReferenceSharedPtr;
85 
86  /// \brief Weak pointer encapsulation of an InstanceReference.
87  typedef boost::weak_ptr<InstanceReference> InstanceReferenceWeakPtr;
88 
89 } // namespace physical
90 } // namespace torc
91 
92 #endif // TORC_PHYSICAL_INSTANCEREFERENCE_HPP
std::string string
Imported type name.
boost::weak_ptr< class Module > ModuleWeakPtr
Local forward declaration of ModuleWeakPtr to avoid dependency loops.
InstanceReference(const string &inInstantiationName, ModuleSharedPtr inModulePtr, InstanceSharedPtr inInstancePtr)
Protected constructor.
boost::weak_ptr< class Instance > InstanceWeakPtr
Local forward declaration of InstanceWeakPtr to avoid dependency loops.
boost::shared_ptr< class Instance > InstanceSharedPtr
Local forward declaration of InstanceSharedPtr to avoid dependency loops.
bool operator==(const InstanceReference &rhs) const
Equality operator.
ModuleWeakPtr mModulePtr
The module weak pointer.
const ModuleWeakPtr & getModulePtr(void) const
Returns the weak module pointer.
const InstanceWeakPtr & getInstancePtr(void) const
Returns the weak instance pointer.
std::string string
string mInstantiationName
The module instantiation name.
Factory class for physical netlist elements.
boost::weak_ptr< InstanceReference > InstanceReferenceWeakPtr
Weak pointer encapsulation of an InstanceReference.
boost::shared_ptr< class Module > ModuleSharedPtr
Local forward declaration of ModuleSharedPtr to avoid dependency loops.
InstanceWeakPtr mInstancePtr
The instance weak pointer.
Instantiation of a module instance.
boost::shared_ptr< InstanceReference > InstanceReferenceSharedPtr
Shared pointer encapsulation of an InstanceReference.
const string & getInstantiationName(void) const
Returns the instantiation name.