torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PortBundle.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_PORTBUNDLE_HPP
17 #define TORC_GENERIC_PORTBUNDLE_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"
28 #include "torc/generic/Error.hpp"
30 #include "torc/generic/Port.hpp"
32 
33 namespace torc { namespace generic { class Net; } }
34 namespace torc { namespace generic { class BaseVisitor; } }
35 
36 namespace torc {
37 namespace generic {
38 
39 /**
40  * @brief Represents a bundle of ports.
41  *
42  * The PortBundle class represents an EDIF port bundle. PortBundles are ordered collection of scalar and vector ports and can be created using the (portBundle ...) syntax.
43  */
44 class PortBundle : public Port, public Bundle<Port> {
45 #ifdef GENOM_SERIALIZATION
46  friend class boost::serialization::access;
47 #endif //GENOM_SERIALIZATION
48  friend class FactoryType<PortBundle> ;
49 
50 public:
52 
53  /**
54  * Convenience class to create a port bundle.
55  */
56  class Factory : public FactoryType<PortBundle> {
57  public:
59  /**
60  * Create a port bundle.
61  *
62  * @param[in] inName Name of the port bundle to be created.
63  * @param[in] inViewPtr Pointer to parented(View) object.
64  * @param[in] inParentCollection Pointer to parent bundle.
65  * @param[in] inOriginalName Original name of the port bundle [optional].
66  *
67  * @return Pointer to created port bundle.
68  **/
69  virtual PortBundleSharedPtr newPortBundlePtr(const std::string& inName,
70  const ViewSharedPtr& inViewPtr,
71  const PortBundleSharedPtr& inParentCollection = PortBundleSharedPtr(),
72  const std::string& inOriginalName = std::string()) throw (Error);
73  };
74 
75  virtual void setParent(const ViewSharedPtr& inParent);
76 
77  /**
78  * Connect a Net to this object.
79  *
80  * @note This metod can be overridden by derived classes. However, the method must call the
81  * on_connected() method after this. The sigConnected_ signal must also be invoked in the
82  * overriding method.
83  *
84  * @param[in] inNet A pointer to the Net object that needs to be connected
85  * @return A connection that has been established. This can be used later for disconnection.
86  *
87  * @exception Error Pointer to the Net object does not exists
88  * <ul>
89  * <li>
90  * Id : eMessageIdErrorPointerToItemDoesNotExist
91  * </li>
92  * <li> Context Data
93  * <ul>
94  * <li>Pointe to Net object - <i>boost::shared_ptr</i></li>
95  * </ul>
96  * </li>
97  * </ul>
98  *
99  * @exception Error Net size does not match with port bundle size
100  * <ul>
101  * <li>
102  * Id : eMessageIdErrorItemSizeMismatch
103  * </li>
104  * <li> Context Data
105  * <ul>
106  * <li>Net Size - <i>SizeType</i></li>
107  * <li>Port Size - <i>SizeType</i></li>
108  * </ul>
109  * </li>
110  * </ul>
111  *
112  */
113  virtual Connectable::Connection connect(const NetSharedPtr& inNet) throw (Error);
114 
115  /**
116  * Disconnect a Net from this object.
117  * @note This metod can be overridden by derived classes. However, the method must call the
118  * on_connected() method after this. The sigConnected_ signal must also be invoked in the
119  * overriding method.
120 
121  * @param[in] inConnection A connection as returned by the connect() method
122  * @exception Error Provided connection is invalid, because pointer to the Net does not exist
123  * <ul>
124  * <li>
125  * Id : eMessageIdErrorPointerToItemDoesNotExist
126  * </li>
127  * <li> Context Data
128  * <ul>
129  * <li>Pointer to Net - <i>boost::shared_ptr</i></li>
130  * </ul>
131  * </li>
132  * </ul>
133  *
134  */
135  void disconnect(const Connectable::Connection& inConnection) throw (Error);
136 
138 
139  virtual void accept(BaseVisitor& inoutVisitor) throw (Error);
140 
141  virtual ~PortBundle() throw ();
142 
143 protected:
144  PortBundle();
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_PORTBUNDLE_HPP
An acyclic inoutVisitor implementation.
Definition: VisitorType.hpp:57
virtual void accept(BaseVisitor &inoutVisitor)
Definition: PortBundle.cpp:176
Represents a bundle of ports.
Definition: PortBundle.hpp:44
virtual void setParent(const ViewSharedPtr &inParent)
Definition: PortBundle.cpp:40
boost::shared_ptr< PortBundle > PortBundleSharedPtr
std::list< NetSharedPtr >::iterator Connection
Definition: Connectable.hpp:52
virtual Connectable::Connection connect(const NetSharedPtr &inNet)
Definition: PortBundle.cpp:55
std::string string
VisitorType< PortBundle > Visitor
Definition: PortBundle.hpp:51
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 PortBundleSharedPtr newPortBundlePtr(const std::string &inName, const ViewSharedPtr &inViewPtr, const PortBundleSharedPtr &inParentCollection=PortBundleSharedPtr(), const std::string &inOriginalName=std::string())
Definition: PortBundle.cpp:156
Interface for an EDIF port object.
boost::shared_ptr< View > ViewSharedPtr
A placeholder for a factory method.
Definition: FactoryType.hpp:35
Represents a "bundle" in the EDIF sense.
Definition: Bundle.hpp:43