torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VectorPortReference.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_VECTORPORTREFERENCE_HPP
17 #define TORC_GENERIC_VECTORPORTREFERENCE_HPP
18 
20 
21 //BOOST
22 #ifdef GENOM_SERIALIZATION
23 #include <boost/serialization/access.hpp>
24 #endif //GENOM_SERIALIZATION
25 #include "torc/generic/Vector.hpp"
29 #include "torc/generic/Error.hpp"
32 
33 namespace torc { namespace generic { class BaseVisitor; } }
34 namespace torc { namespace generic { class Net; } }
35 
36 namespace torc {
37 namespace generic {
38 
39 /**
40  * @brief Represents a reference to a port array.
41  *
42  * The VectorPortReference class represents a reference to a port array.
43  */
44 class VectorPortReference : public PortReference, public Vector<PortReference,
45  VectorPortBitReference, VectorPortBitReference::Factory, true> {
46 #ifdef GENOM_SERIALIZATION
47  friend class boost::serialization::access;
48 #endif //GENOM_SERIALIZATION
50 
51 public:
55 
56  /**
57  * Convenience class to create a vector port ref.
58  */
59  class Factory : public FactoryType<VectorPortReference> {
60  public:
62  /**
63  * Create a vector port ref.
64  *
65  * @param[in] inInstancePtr Pointer to parented(Instance) object.
66  * @param[in] inPortPtr Pointer to master(Port) object.
67  * @param[in] inSize Size of the net array.
68  * @param[in] inParentCollection Pointer to parent bundle.
69  * @param[in] inFactory Factory for the child.
70  *
71  * @return Pointer to created scalar port ref.
72  **/
74  const InstanceSharedPtr& inInstancePtr, const PortSharedPtr& inPortPtr,
75  const size_t& inSize, const PortBundleReferenceSharedPtr& inParentCollection
78 
79  /**
80  * Create a vector port ref.
81  *
82  * @param[in] inInstancePtr Pointer to parented(Instance) object.
83  * @param[in] inPortPtr Pointer to master(Port) object.
84  * @param[in] inLimits Dimensions of the vector.
85  * @param[in] inParentCollection Pointer to parent bundle.
86  * @param[in] inFactory Factory for the child.
87  *
88  * @return Pointer to created scalar port ref.
89  **/
91  const InstanceSharedPtr& inInstancePtr,
92  const PortSharedPtr& inPortPtr,
93  const std::vector<size_t>& inLimits,
94  const PortBundleReferenceSharedPtr& inParentCollection = PortBundleReferenceSharedPtr(),
95  const ChildFactorySharedPtr& inFactory
97  ) throw (Error);
98 
99  };
100 
101  virtual void accept(BaseVisitor& inoutVisitor) throw (Error);
102 
103  virtual void setParent(const InstanceSharedPtr& inParent);
104 
105  /**
106  * Connect a Net to this object.
107  *
108  * @note This metod can be overridden by derived classes. However, the method must call the
109  * on_connected() method after this. The sigConnected_ signal must also be invoked in the
110  * overriding method.
111  *
112  * @param[in] inNet A pointer to the Net object that needs to be connected
113  * @return A connection that has been established. This can be used later for disconnection.
114  *
115  * @exception Error Pointer to the Net object does not exist
116  * <ul>
117  * <li>
118  * Id : eMessageIdErrorPointerToItemDoesNotExist
119  * </li>
120  * <li> Context Data
121  * <ul>
122  * <li>Pointer to the Net - <i>boost::shared_ptr</i></li>
123  * </ul>
124  * </li>
125  * </ul>
126  *
127  * @exception Error Net size does not match with VectorPortReference size
128  * <ul>
129  * <li>
130  * Id : eMessageIdErrorItemSizeMismatch
131  * </li>
132  * <li> Context Data
133  * <ul>
134  * <li>Net Size - <i>SizeType</i></li>
135  * <li>VectorPortReference Size - <i>SizeType</i></li>
136  * </ul>
137  * </li>
138  * </ul>
139  *
140  */
141  virtual Connectable::Connection connect(const NetSharedPtr& inNet) throw (Error);
142 
143  /**
144  * Disconnect a Net from this object.
145  * @note This metod can be overridden by derived classes. However, the method must call the
146  * on_connected() method after this. The sigConnected_ signal must also be invoked in the
147  * overriding method.
148 
149  * @param[in] inConnection A connection as returned by the connect() method
150  * @exception Error Provided connection is invalid, because pointer to the Net does not exist
151  * <ul>
152  * <li>
153  * Id : eMessageIdErrorPointerToItemDoesNotExist
154  * </li>
155  * <li> Context Data
156  * <ul>
157  * <li>Pointer to Net - <i>boost::shared_ptr</i></li>
158  * </ul>
159  * </li>
160  * </ul>
161  *
162  */
163  void disconnect(const Connectable::Connection& inConnection) throw (Error);
164 
166 
167  /*
168  * Returns the list of connected nets. The return list consists of the following:
169  * 1) Nets connected to the whole port
170  * 2) Nets connected to the individual nodes of the port
171  *
172  * @param[out] outNets List of nets to be populated
173  * @param[in] inSkipChildConnections bool Whether child connection is skipped or not
174  */
175 
176  virtual void getConnectedNets(std::vector<NetSharedPtr>& outNets,
177  bool inSkipChildConnections = false) const throw (Error);
178 
179  virtual void onChildCreate(const VectorPortBitReferenceSharedPtr& inCreatedChild) const
180  throw (Error);
181  /**
182  * Set master port.
183  *
184  * @param[in] inMaster Set the master port.
185  */
186  virtual void bindToMasterPort(const PortSharedPtr& inMaster) throw (Error);
187 
188  ~VectorPortReference() throw ();
189 
190 protected:
192 
193 private:
194 #ifdef GENOM_SERIALIZATION
195  template <class Archive> void
196  serialize(Archive& ar, unsigned int);
197 #endif //GENOM_SERIALIZATION
198 };
199 
200 } // namespace generic
201 } // namespace torc
202 
203 #endif // TORC_GENERIC_VECTORPORTREFERENCE_HPP
virtual void setParent(const InstanceSharedPtr &inParent)
An acyclic inoutVisitor implementation.
Definition: VisitorType.hpp:57
virtual Connectable::Connection connect(const NetSharedPtr &inNet)
boost::shared_ptr< Instance > InstanceSharedPtr
Represents a reference to a port array.
Represents the usable instance of a port of a cell in another cell.
boost::shared_ptr< VectorPortBitReference > VectorPortBitReferenceSharedPtr
virtual VectorPortReferenceSharedPtr newVectorPortReferencePtr(const InstanceSharedPtr &inInstancePtr, const PortSharedPtr &inPortPtr, const size_t &inSize, const PortBundleReferenceSharedPtr &inParentCollection=PortBundleReferenceSharedPtr(), const ChildFactorySharedPtr &inFactory=BaseType::ChildFactorySharedPtr(new BaseType::ChildFactory()))
std::list< NetSharedPtr >::iterator Connection
Definition: Connectable.hpp:52
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 getConnectedNets(std::vector< NetSharedPtr > &outNets, bool inSkipChildConnections=false) const
Vector< PortReference, VectorPortBitReference, VectorPortBitReference::Factory, true > BaseType
An array of objects.
Definition: Vector.hpp:50
boost::shared_ptr< Port > PortSharedPtr
virtual void bindToMasterPort(const PortSharedPtr &inMaster)
boost::shared_ptr< VectorPortReference > VectorPortReferenceSharedPtr
A placeholder for a factory method.
Definition: FactoryType.hpp:35
virtual void onChildCreate(const VectorPortBitReferenceSharedPtr &inCreatedChild) const
VisitorType< VectorPortReference > Visitor
boost::shared_ptr< PortBundleReference > PortBundleReferenceSharedPtr