00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/generic/om/PortBundleReference.hpp $ 00003 // $Id: PortBundleReference.hpp 10 2011-10-12 18:40:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 #ifndef TORC_GENERIC_OM_PORTBUNDLEREFERENCE_HPP 00017 #define TORC_GENERIC_OM_PORTBUNDLEREFERENCE_HPP 00018 00019 #include "torc/generic/om/PointerTypes.hpp" 00020 #include "torc/generic/om/DumpRestoreConfig.hpp" 00021 00022 //BOOST 00023 #ifdef GENOM_SERIALIZATION 00024 #include <boost/serialization/access.hpp> 00025 #endif //GENOM_SERIALIZATION 00026 00027 00028 #include "torc/generic/om/Bundle.hpp" 00029 #include "torc/generic/om/BundleFlattener.hpp" 00030 #include "torc/generic/util/Error.hpp" 00031 #include "torc/generic/om/FactoryType.hpp" 00032 #include "torc/generic/om/PortReference.hpp" 00033 #include "torc/generic/om/VisitorType.hpp" 00034 00035 namespace torc { namespace generic { class BaseVisitor; } } 00036 00037 namespace torc { 00038 00039 namespace generic { 00040 00041 /** 00042 * @brief Represents a reference to a bundle of ports. 00043 * 00044 * The PortBundle class represents a reference to an EDIF port bundle. 00045 */ 00046 class PortBundleReference : 00047 public PortReference, 00048 public Bundle<PortReference> { 00049 #ifdef GENOM_SERIALIZATION 00050 friend class boost::serialization::access; 00051 #endif //GENOM_SERIALIZATION 00052 00053 friend class FactoryType<PortBundleReference>; 00054 public: 00055 typedef VisitorType<PortBundleReference> Visitor; 00056 00057 /** 00058 * Convenience class to create a port bundle reference. 00059 */ 00060 class Factory: public FactoryType<PortBundleReference> 00061 { 00062 public: 00063 using FactoryType<PortBundleReference>::create; 00064 00065 /** 00066 * Create a portbundle ref. 00067 * 00068 * @param[in] inInstancePtr Pointer to parented(Instance) object. 00069 * @param[in] inPortPtr Pointer to master(Port) object. 00070 * @param[in] inFactory Factory for the child. 00071 * @param[in] inParentCollection Pointer to parent bundle. 00072 * 00073 * @return Pointer to created portbundle ref. 00074 **/ 00075 virtual PortBundleReferenceSharedPtr 00076 newPortBundleReferencePtr( const InstanceSharedPtr &inInstancePtr, 00077 const PortSharedPtr &inPortPtr, 00078 const ObjectFactorySharedPtr &inFactory, 00079 const PortBundleReferenceSharedPtr &inParentCollection 00080 = PortBundleReferenceSharedPtr() ) throw(Error); 00081 }; 00082 00083 virtual void 00084 accept(BaseVisitor & inoutVisitor) throw(Error); 00085 00086 virtual void 00087 setParent( const InstanceSharedPtr &inParent ) throw(); 00088 00089 /** 00090 * Connect a Net to this object. 00091 * 00092 * @note This metod can be overridden by derived classes. However, the method must call the on_connected() method after this. The sigConnected_ signal must also be invoked in the overriding method. 00093 * 00094 * @param[in] inNet A pointer to the Net object that needs to be connected 00095 * @return A connection that has been established. This can be used later for disconnection. 00096 * 00097 * @exception Error PortBundleReference size does not match with Master port size 00098 * <ul> 00099 * <li> 00100 * Id : eMessageIdErrorPointerToItemDoesNotExist 00101 * </li> 00102 * <li> Context Data 00103 * <ul> 00104 * <li>PortBundleReference Size - <i>SizeType</i></li> 00105 * <li>Master Port Size - <i>SizeType</i></li> 00106 * </ul> 00107 * </li> 00108 * </ul> 00109 * 00110 * @exception Error Net size does not match with PortBundleReference size 00111 * <ul> 00112 * <li> 00113 * Id : eMessageIdErrorItemSizeMismatch 00114 * </li> 00115 * <li> Context Data 00116 * <ul> 00117 * <li>Net Size - <i>SizeType</i></li> 00118 * <li>PortBundleReference Size - <i>SizeType</i></li> 00119 * </ul> 00120 * </li> 00121 * </ul> 00122 * 00123 */ 00124 virtual Connection 00125 connect(const NetSharedPtr & inNet) throw(Error) 00126 ; 00127 /** 00128 * Disconnect a Net from this object. 00129 * @note This metod can be overridden by derived classes. However, the method must call the on_connected() method after this. The sigConnected_ signal must also be invoked in the overriding method. 00130 00131 * @param[in] connection A connection as returned by the connect() method 00132 * @exception Error Provided connection is invalid, because pointer to the Net does not exist 00133 * <ul> 00134 * <li> 00135 * Id : eMessageIdErrorPointerToItemDoesNotExist 00136 * </li> 00137 * <li> Context Data 00138 * <ul> 00139 * <li>Pointer to Net - <i>boost::shared_ptr</i></li> 00140 * </ul> 00141 * </li> 00142 * </ul> 00143 * 00144 */ 00145 virtual void 00146 disconnect(const Connection & inConnection) throw(Error); 00147 00148 using Connectable::disconnect; 00149 00150 /** 00151 * Set master port. 00152 * 00153 * @param[in] inMaster Set the master port. 00154 * @exception Error Master port size does not match with port bundle reference size 00155 * <ul> 00156 * <li> 00157 * Id : eMessageIdErrorItemSizeMismatch 00158 * </li> 00159 * <li> Context Data 00160 * <ul> 00161 * <li>Net Size - <i>SizeType</i></li> 00162 * <li>Port Size - <i>SizeType</i></li> 00163 * </ul> 00164 * </li> 00165 * </ul> 00166 * 00167 */ 00168 virtual void 00169 bindToMasterPort(const PortSharedPtr &inMaster) throw(Error); 00170 00171 PortBundleReference(); 00172 00173 virtual 00174 ~PortBundleReference() throw(); 00175 00176 private: 00177 PortBundleReference( const PortBundleReference &); 00178 PortBundleReference & 00179 operator =( const PortBundleReference &); 00180 #ifdef GENOM_SERIALIZATION 00181 template<class Archive> void 00182 serialize( Archive &ar, unsigned int ); 00183 #endif //GENOM_SERIALIZATION 00184 00185 }; 00186 00187 } // namespace torc::generic 00188 00189 } // namespace torc 00190 #endif // TORC_GENERIC_OM_PORTBUNDLEREFERENCE_HPP