torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PortBundleReference.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 #ifndef TORC_GENERIC_PORTBUNDLEREFERENCE_HPP
17 #define TORC_GENERIC_PORTBUNDLEREFERENCE_HPP
18 
20 
21 //BOOST
22 #ifdef GENOM_SERIALIZATION
23 #include <boost/serialization/access.hpp>
24 #endif //GENOM_SERIALIZATION
25 #include "torc/generic/Bundle.hpp"
27 #include "torc/generic/Error.hpp"
31 
32 namespace torc { namespace generic { class BaseVisitor; } }
33 
34 namespace torc {
35 namespace generic {
36 
37 /**
38  * @brief Represents a reference to a bundle of ports.
39  *
40  * The PortBundle class represents a reference to an EDIF port bundle.
41  */
42 class PortBundleReference : public PortReference, public Bundle<PortReference> {
43 #ifdef GENOM_SERIALIZATION
44  friend class boost::serialization::access;
45 #endif //GENOM_SERIALIZATION
47 public:
49 
50  /**
51  * Convenience class to create a port bundle reference.
52  */
53  class Factory : public FactoryType<PortBundleReference> {
54  public:
56 
57  /**
58  * Create a portbundle ref.
59  *
60  * @param[in] inInstancePtr Pointer to parented(Instance) object.
61  * @param[in] inPortPtr Pointer to master(Port) object.
62  * @param[in] inFactory Factory for the child.
63  * @param[in] inParentCollection Pointer to parent bundle.
64  *
65  * @return Pointer to created portbundle ref.
66  **/
68  const InstanceSharedPtr& inInstancePtr, const PortSharedPtr& inPortPtr,
69  const ObjectFactorySharedPtr& inFactory,
70  const PortBundleReferenceSharedPtr& inParentCollection = PortBundleReferenceSharedPtr())
71  throw (Error);
72  };
73 
74  virtual void accept(BaseVisitor& inoutVisitor) throw (Error);
75 
76  virtual void setParent(const InstanceSharedPtr& inParent);
77 
78  /**
79  * Connect a Net to this object.
80  *
81  * @note This metod can be overridden by derived classes. However, the method must call the
82  * on_connected() method after this. The sigConnected_ signal must also be invoked in the
83  * overriding method.
84  *
85  * @param[in] inNet A pointer to the Net object that needs to be connected
86  * @return A connection that has been established. This can be used later for disconnection.
87  *
88  * @exception Error PortBundleReference size does not match with Master port size
89  * <ul>
90  * <li>
91  * Id : eMessageIdErrorPointerToItemDoesNotExist
92  * </li>
93  * <li> Context Data
94  * <ul>
95  * <li>PortBundleReference Size - <i>SizeType</i></li>
96  * <li>Master Port Size - <i>SizeType</i></li>
97  * </ul>
98  * </li>
99  * </ul>
100  *
101  * @exception Error Net size does not match with PortBundleReference size
102  * <ul>
103  * <li>
104  * Id : eMessageIdErrorItemSizeMismatch
105  * </li>
106  * <li> Context Data
107  * <ul>
108  * <li>Net Size - <i>SizeType</i></li>
109  * <li>PortBundleReference Size - <i>SizeType</i></li>
110  * </ul>
111  * </li>
112  * </ul>
113  *
114  */
115  virtual Connection connect(const NetSharedPtr& inNet) throw (Error)
116  ;
117  /**
118  * Disconnect a Net from this object.
119  * @note This metod can be overridden by derived classes. However, the method must call the
120  * on_connected() method after this. The sigConnected_ signal must also be invoked in the
121  * overriding method.
122 
123  * @param[in] connection A connection as returned by the connect() method
124  * @exception Error Provided connection is invalid, because pointer to the Net does not exist
125  * <ul>
126  * <li>
127  * Id : eMessageIdErrorPointerToItemDoesNotExist
128  * </li>
129  * <li> Context Data
130  * <ul>
131  * <li>Pointer to Net - <i>boost::shared_ptr</i></li>
132  * </ul>
133  * </li>
134  * </ul>
135  *
136  */
137  virtual void disconnect(const Connection& inConnection) throw (Error);
138 
140 
141  /**
142  * Set master port.
143  *
144  * @param[in] inMaster Set the master port.
145  * @exception Error Master port size does not match with port bundle reference size
146  * <ul>
147  * <li>
148  * Id : eMessageIdErrorItemSizeMismatch
149  * </li>
150  * <li> Context Data
151  * <ul>
152  * <li>Net Size - <i>SizeType</i></li>
153  * <li>Port Size - <i>SizeType</i></li>
154  * </ul>
155  * </li>
156  * </ul>
157  *
158  */
159  virtual void bindToMasterPort(const PortSharedPtr& inMaster) throw (Error);
160 
162 
163  virtual ~PortBundleReference() throw ();
164 
165 private:
167  PortBundleReference&
168  operator =(const PortBundleReference&);
169 #ifdef GENOM_SERIALIZATION
170  template <class Archive> void serialize(Archive& ar, unsigned int);
171 #endif //GENOM_SERIALIZATION
172 };
173 
174 } // namespace generic
175 } // namespace torc
176 
177 #endif // TORC_GENERIC_PORTBUNDLEREFERENCE_HPP
An acyclic inoutVisitor implementation.
Definition: VisitorType.hpp:57
VisitorType< PortBundleReference > Visitor
boost::shared_ptr< Instance > InstanceSharedPtr
Represents the usable instance of a port of a cell in another cell.
virtual Connection connect(const NetSharedPtr &inNet)
std::list< NetSharedPtr >::iterator Connection
Definition: Connectable.hpp:52
boost::shared_ptr< ObjectFactory > ObjectFactorySharedPtr
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
boost::shared_ptr< Net > NetSharedPtr
A base class for Visitor.
Definition: VisitorType.hpp:31
virtual void accept(BaseVisitor &inoutVisitor)
virtual void bindToMasterPort(const PortSharedPtr &inMaster)
boost::shared_ptr< Port > PortSharedPtr
virtual void setParent(const InstanceSharedPtr &inParent)
A placeholder for a factory method.
Definition: FactoryType.hpp:35
Represents a reference to a bundle of ports.
Represents a "bundle" in the EDIF sense.
Definition: Bundle.hpp:43
virtual PortBundleReferenceSharedPtr newPortBundleReferencePtr(const InstanceSharedPtr &inInstancePtr, const PortSharedPtr &inPortPtr, const ObjectFactorySharedPtr &inFactory, const PortBundleReferenceSharedPtr &inParentCollection=PortBundleReferenceSharedPtr())
boost::shared_ptr< PortBundleReference > PortBundleReferenceSharedPtr