torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VectorPort.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_VECTORPORT_HPP
17 #define TORC_GENERIC_VECTORPORT_HPP
18 
20 
21 #ifdef GENOM_SERIALIZATION
22 #include <boost/serialization/access.hpp>
23 #endif //GENOM_SERIALIZATION
24 #include "torc/generic/Port.hpp"
25 #include "torc/generic/Vector.hpp"
29 #include "torc/generic/Error.hpp"
31 
32 namespace torc { namespace generic { class Net; } }
33 namespace torc { namespace generic { class BaseVisitor; } }
34 
35 namespace torc {
36 
37 namespace generic {
38 
39 /**
40  * @brief Represents a port array.
41  *
42  * The VectorPort class represents a port array. Such objects in EDIF are declard using the
43  * (port (array ...) ) syntax.
44  */
45 class VectorPort : public Port, public Vector<Port, VectorPortBit, VectorPortBit::Factory, true> {
46 #ifdef GENOM_SERIALIZATION
47  friend class boost::serialization::access;
48 #endif //GENOM_SERIALIZATION
49  friend class FactoryType<VectorPort> ;
50 
51 public:
53 
55 
56  /**
57  * Convenience class to create a vector port.
58  */
59  class Factory : public FactoryType<VectorPort> {
60  public:
62  /**
63  * Create a vector port.
64  *
65  * @param[in] inName Name of the vector port to be created.
66  * @param[in] inDirection Direction of port.
67  * @param[in] inViewPtr Pointer to parented(View) object.
68  * @param[in] inSize Size of the port array.
69  * @param[in] inParentCollection Pointer to parent bundle.
70  * @param[in] inFactory Factory for the child.
71  * @param[in] inOriginalName Original name of the vector port [optional].
72  *
73  * @return Pointer to created vector port.
74  **/
76  const std::string& inName,
77  const EPortDirection& inDirection,
78  const ViewSharedPtr& inViewPtr,
79  const size_t& inSize,
80  const PortBundleSharedPtr& inParentCollection = PortBundleSharedPtr(),
82  new BaseVectorType::ChildFactory()), const std::string& inOriginalName
83  = std::string()) throw (Error);
84  /**
85  * Create a vector port.
86  *
87  * @param[in] inName Name of the vector port to be created.
88  * @param[in] inDirection Direction of port.
89  * @param[in] inViewPtr Pointer to parented(View) object.
90  * @param[in] inLimits Dimensions of the vector.
91  * @param[in] inParentCollection Pointer to parent bundle.
92  * @param[in] inFactory Factory for the child.
93  * @param[in] inOriginalName Original name of the vector port [optional].
94  *
95  * @return Pointer to created vector port.
96  **/
97  virtual VectorPortSharedPtr newVectorPortPtr(const std::string& inName,
98  const EPortDirection& inDirection, const ViewSharedPtr& inViewPtr,
99  const std::vector<size_t>& inLimits, const PortBundleSharedPtr& inParentCollection
100  = PortBundleSharedPtr(), const ChildFactorySharedPtr& inFactory
102  const std::string& inOriginalName = std::string()) throw (Error);
103  };
104 
105  virtual void setParent(const ViewSharedPtr& inParent);
106 
107  virtual void accept(BaseVisitor& inoutVisitor) throw (Error);
108 
109  virtual Connectable::Connection connect(const NetSharedPtr& inNet) throw (Error);
110 
112 
113  void disconnect(const Connectable::Connection& inConnection) throw (Error);
114 
115  /*
116  * Returns the list of connected nets. The return list consists of the following:
117  * 1) Nets connected to the whole port
118  * 2) Nets connected to the individual nodes of the port
119  *
120  * param[out] outNets List of nets to be populated
121  */
122 
123  virtual void getConnectedNets(std::vector<NetSharedPtr>& outNets,
124  bool inSkipChildConnections = false) const throw (Error);
125 
126  virtual ~VectorPort() throw ();
127 
128 protected:
129  virtual void onChildCreate(const boost::shared_ptr<BaseVectorType::ChildType>& inCreatedChild)
130  const throw (Error);
131 
132  VectorPort();
133 
134 private:
135 #ifdef GENOM_SERIALIZATION
136  template <class Archive> void
137  serialize(Archive& ar, unsigned int);
138 #endif //GENOM_SERIALIZATION
139 };
140 
141 } // namespace generic
142 } // namespace torc
143 
144 #endif // TORC_GENERIC_VECTORPORT_HPP
An acyclic inoutVisitor implementation.
Definition: VisitorType.hpp:57
Represents a bit of a port.
boost::shared_ptr< PortBundle > PortBundleSharedPtr
std::list< NetSharedPtr >::iterator Connection
Definition: Connectable.hpp:52
Vector< Port, VectorPortBit, VectorPortBit::Factory, true > BaseVectorType
Definition: VectorPort.hpp:52
std::string string
boost::shared_ptr< VectorPort > VectorPortSharedPtr
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
Represents a port array.
Definition: VectorPort.hpp:45
boost::shared_ptr< Net > NetSharedPtr
virtual VectorPortSharedPtr newVectorPortPtr(const std::string &inName, const EPortDirection &inDirection, const ViewSharedPtr &inViewPtr, const size_t &inSize, const PortBundleSharedPtr &inParentCollection=PortBundleSharedPtr(), const ChildFactorySharedPtr &inFactory=BaseVectorType::ChildFactorySharedPtr(new BaseVectorType::ChildFactory()), const std::string &inOriginalName=std::string())
Definition: VectorPort.cpp:54
A base class for Visitor.
Definition: VisitorType.hpp:31
virtual void onChildCreate(const boost::shared_ptr< BaseVectorType::ChildType > &inCreatedChild) const
Definition: VectorPort.cpp:199
virtual void getConnectedNets(std::vector< NetSharedPtr > &outNets, bool inSkipChildConnections=false) const
Definition: VectorPort.cpp:183
An array of objects.
Definition: Vector.hpp:50
boost::shared_ptr< VectorPortBit::Factory > ChildFactorySharedPtr
Definition: Vector.hpp:63
Interface for an EDIF port object.
boost::shared_ptr< View > ViewSharedPtr
virtual void setParent(const ViewSharedPtr &inParent)
Definition: VectorPort.cpp:113
VisitorType< VectorPort > Visitor
Definition: VectorPort.hpp:54
virtual void accept(BaseVisitor &inoutVisitor)
Definition: VectorPort.cpp:104
virtual Connectable::Connection connect(const NetSharedPtr &inNet)
Definition: VectorPort.cpp:131
A placeholder for a factory method.
Definition: FactoryType.hpp:35