torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VectorNet.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_VECTORNET_HPP
17 #define TORC_GENERIC_VECTORNET_HPP
18 
20 
21 #ifdef GENOM_SERIALIZATION
22 #include <boost/serialization/access.hpp>
23 #endif //GENOM_SERIALIZATION
24 #include "torc/generic/Net.hpp"
25 #include "torc/generic/Vector.hpp"
28 #include "torc/generic/Error.hpp"
30 
31 namespace torc { namespace generic { class BaseVisitor; } }
32 
33 namespace torc {
34 namespace generic {
35 
36 /**
37  * @brief Represents a net array.
38  *
39  * The VectorNet class represents a net array. Such objects in EDIF are declared using the
40  * (net (array ...) ) syntax.
41  */
42 class VectorNet : public Net, public Vector<Net, VectorNetBit, VectorNetBit::Factory, true> {
43 #ifdef GENOM_SERIALIZATION
44  friend class boost::serialization::access;
45 #endif //GENOM_SERIALIZATION
46  friend class FactoryType<VectorNet> ;
47 
48 public:
51 
52  /**
53  * Convenience class to create a vector net.
54  */
55  class Factory : public FactoryType<VectorNet> {
56  public:
58  /**
59  * Create a vector net.
60  *
61  * @param[in] inName Name of the vector net to be created.
62  * @param[in] inViewPtr Pointer to parented(View) object.
63  * @param[in] inSize Size of the net array.
64  * @param[in] inParentCollection Pointer to parent bundle.
65  * @param[in] inFactory Factory for the child.
66  * @param[in] inOriginalName Original name of the vector net [optional].
67  *
68  * @return Pointer to created vector net.
69  **/
71  const std::string& inName,
72  const ViewSharedPtr& inViewPtr,
73  const size_t& inSize,
74  const NetBundleSharedPtr& inParentCollection = NetBundleSharedPtr(),
75  const ChildFactorySharedPtr& inFactory
77  const std::string& inOriginalName = std::string()) throw (Error);
78  /**
79  * Create a vector net.
80  *
81  * @param[in] inName Name of the vector net to be created.
82  * @param[in] inViewPtr Pointer to parented(View) object.
83  * @param[in] inLimits Dimensions of the vector.
84  * @param[in] inParentCollection Pointer to parent bundle.
85  * @param[in] inFactory Factory for the child.
86  * @param[in] inOriginalName Original name of the vector net [optional].
87  *
88  * @return Pointer to created vector net.
89  **/
91  const std::string& inName,
92  const ViewSharedPtr& inViewPtr,
93  const std::vector<size_t>& inLimits,
94  const NetBundleSharedPtr& inParentCollection = NetBundleSharedPtr(),
95  const ChildFactorySharedPtr& inFactory
97  const std::string& inOriginalName = std::string()) throw (Error);
98  };
99 
100  virtual void accept(BaseVisitor& inoutVisitor) throw (Error);
101 
102  virtual void setParent(const ViewSharedPtr& inParent);
103 
104  /**
105  * Connect a Net to this object.
106  *
107  * @note This metod can be overridden by derived classes. However, the method must call the
108  * on_connected() method after this. The sigConnected_ signal must also be invoked in the
109  * overriding method.
110  *
111  * @param[in] inNet A pointer to the Net object that needs to be connected
112  * @return A connection that has been established. This can be used later for disconnection.
113  */
114  virtual Connectable::Connection connect(const NetSharedPtr& inNet) throw (Error);
115 
116  /**
117  * Disconnect a Net from this object.
118  * @note This metod can be overridden by derived classes. However, the method must call the
119  * on_connected() method after this. The sigConnected_ signal must also be invoked in the
120  * overriding method.
121 
122  * @param[in] inConnection A connection as returned by the connect() method
123  * @exception Error Provided connection is invalid
124  */
125  void disconnect(const Connectable::Connection& inConnection) throw (Error);
126 
127  void disconnect() throw (Error);
128 
129  virtual void getConnectedNets(std::vector<NetSharedPtr>& outNets, bool inSkipChildConnections =
130  false) const throw (Error);
131 
132  virtual void getConnectedPorts(std::vector<PortSharedPtr>& outPorts,
133  bool inSkipChildConnections = false) const;
134 
135  virtual void getConnectedPortRefs(std::vector<PortReferenceSharedPtr>& outPortRefs,
136  bool inSkipChildConnections = false) const;
137 
138  virtual ~VectorNet() throw ();
139 
140 protected:
141  virtual void onChildCreate(
142  const boost::shared_ptr<BaseVectorType::ChildType>& inCreatedChild) const throw (Error);
143 
144  VectorNet();
145 
146 private:
147 #ifdef GENOM_SERIALIZATION
148  template <class Archive> void serialize(Archive& ar, unsigned int);
149 #endif //GENOM_SERIALIZATION
150 };
151 
152 } // namespace generic
153 } // namespace torc
154 
155 #endif // TORC_GENERIC_VECTORNET_HPP
An acyclic inoutVisitor implementation.
Definition: VisitorType.hpp:57
Represents a bit of a net array.
virtual void setParent(const ViewSharedPtr &inParent)
Definition: VectorNet.cpp:105
VisitorType< VectorNet > Visitor
Definition: VectorNet.hpp:50
virtual void onChildCreate(const boost::shared_ptr< BaseVectorType::ChildType > &inCreatedChild) const
Definition: VectorNet.cpp:215
Represents an EDIF Net.
Definition: generic/Net.hpp:58
Vector< Net, VectorNetBit, VectorNetBit::Factory, true > BaseVectorType
Definition: VectorNet.hpp:49
std::list< NetSharedPtr >::iterator Connection
Definition: Connectable.hpp:52
std::string string
virtual void getConnectedPorts(std::vector< PortSharedPtr > &outPorts, bool inSkipChildConnections=false) const
Definition: VectorNet.cpp:184
boost::shared_ptr< VectorNet > VectorNetSharedPtr
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
virtual void accept(BaseVisitor &inoutVisitor)
Definition: VectorNet.cpp:96
boost::shared_ptr< Net > NetSharedPtr
A base class for Visitor.
Definition: VisitorType.hpp:31
boost::shared_ptr< PortReference > PortReferenceSharedPtr
Represents a net array.
Definition: VectorNet.hpp:42
virtual Connectable::Connection connect(const NetSharedPtr &inNet)
Definition: VectorNet.cpp:123
virtual void getConnectedNets(std::vector< NetSharedPtr > &outNets, bool inSkipChildConnections=false) const
Definition: VectorNet.cpp:168
An array of objects.
Definition: Vector.hpp:50
boost::shared_ptr< VectorNetBit::Factory > ChildFactorySharedPtr
Definition: Vector.hpp:63
boost::shared_ptr< View > ViewSharedPtr
boost::shared_ptr< Port > PortSharedPtr
virtual void getConnectedPortRefs(std::vector< PortReferenceSharedPtr > &outPortRefs, bool inSkipChildConnections=false) const
Definition: VectorNet.cpp:199
A placeholder for a factory method.
Definition: FactoryType.hpp:35
boost::shared_ptr< NetBundle > NetBundleSharedPtr
virtual VectorNetSharedPtr newVectorNetPtr(const std::string &inName, const ViewSharedPtr &inViewPtr, const size_t &inSize, const NetBundleSharedPtr &inParentCollection=NetBundleSharedPtr(), const ChildFactorySharedPtr &inFactory=BaseVectorType::ChildFactorySharedPtr(new BaseVectorType::ChildFactory()), const std::string &inOriginalName=std::string())
Definition: VectorNet.cpp:49