00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "torc/generic/om/DumpRestoreConfig.hpp"
00017
00018 #ifndef HAVE_CONFIG_H
00019 #include "torc/generic/config.h"
00020 #endif
00021
00022
00023 #ifdef GENOM_SERIALIZATION
00024 #include <boost/archive/binary_iarchive.hpp>
00025 #include <boost/archive/binary_oarchive.hpp>
00026 #include <boost/serialization/base_object.hpp>
00027 #include <boost/serialization/export.hpp>
00028 #endif //GENOM_SERIALIZATION
00029
00030 #include "torc/generic/om/Port.hpp"
00031 #include "torc/generic/om/PortReference.hpp"
00032 #include "torc/generic/om/VectorNetBit.hpp"
00033
00034 #ifdef GENOM_SERIALIZATION
00035 BOOST_CLASS_EXPORT( torc::generic::VectorNetBit )
00036 #endif //GENOM_SERIALIZATION
00037
00038 namespace torc {
00039
00040 namespace generic {
00041
00042 void
00043 VectorNetBit::accept(
00044 BaseVisitor & inoutVisitor) throw(Error) {
00045 try
00046 {
00047 runVisitor( *this, inoutVisitor );
00048 }
00049 catch( Error &e )
00050 {
00051 e.setCurrentLocation(
00052 __FUNCTION__, __FILE__, __LINE__ );
00053 throw;
00054 }
00055 }
00056
00057 Connectable::Connection
00058 VectorNetBit::connect(
00059 const NetSharedPtr &inNet ) throw(Error) {
00060 if( !inNet )
00061 {
00062 Error e( eMessageIdErrorPointerToItemDoesNotExist,
00063 __FUNCTION__, __FILE__, __LINE__ );
00064 e.saveContextData("Pointer to the Net object does not exist", inNet);
00065 throw e;
00066 }
00067 if( inNet->getSize() != getSize() )
00068 {
00069 Error e( eMessageIdErrorItemSizeMismatch,
00070 __FUNCTION__, __FILE__, __LINE__ );
00071 e.saveContextData("Net Size", inNet->getSize());
00072 e.saveContextData("VectorNetBit Size", getSize() );
00073 throw e;
00074 }
00075 return Connectable::connect( inNet );
00076 }
00077
00078 void
00079 VectorNetBit::disconnect(
00080 const Connection &inConnection) throw(Error) {
00081 Connectable::disconnect( inConnection );
00082 }
00083
00084 void
00085 VectorNetBit::getConnectedNets(
00086 std::vector< NetSharedPtr > &outNets,
00087 bool inSkipChildConnections ) const throw(Error) {
00088 Composite<Net>::Pointer parent = getParentCollection();
00089 if( !parent )
00090 {
00091 Error e( eMessageIdErrorPointerToItemDoesNotExist,
00092 __FUNCTION__, __FILE__, __LINE__ );
00093 e.saveContextData("Pointer to parent collection does not exist", parent);
00094 throw e;
00095 }
00096 if( eCompositionTypeVector
00097 != parent->getCompositionType() )
00098 {
00099 Error e( eMessageIdErrorCompositionTypeMismatch,
00100 __FUNCTION__, __FILE__, __LINE__ );
00101 e.saveContextData("Composition type mismatch", parent->getCompositionType());
00102 throw e;
00103 }
00104
00105 Net::getConnectedNets( outNets );
00106
00107 if( !inSkipChildConnections )
00108 {
00109
00110
00111 VectorBit<Net>::List parentConnections;
00112 parent->getConnectedNets( parentConnections, true );
00113 VectorBit<Net>::List::iterator connNet
00114 = parentConnections.begin();
00115 VectorBit<Net>::List::iterator connNetEnd
00116 = parentConnections.end();
00117 const std::vector<VectorBit<Net>::SizeType> &myIndex = getIndices();
00118 for(; connNet != connNetEnd; ++connNet )
00119 {
00120 Composite<Net>::Pointer cousin;
00121 if( eCompositionTypeVector
00122 == (*connNet)->getCompositionType() )
00123 {
00124 cousin = (*connNet)->get( myIndex );
00125
00126
00127 }
00128 else
00129 {
00130 VectorBit<Net>::List bChildren;
00131 (*connNet)->getChildren( bChildren );
00132 cousin = bChildren[ getAbsoluteIndex() ];
00133
00134 }
00135 if( !cousin )
00136 {
00137 Error e( eMessageIdErrorPointerToItemDoesNotExist,
00138 __FUNCTION__, __FILE__, __LINE__ );
00139 e.saveContextData("Pointer to item does not exist", cousin);
00140 throw e;
00141 }
00142 outNets.push_back( cousin );
00143 }
00144
00145
00146 }
00147 return;
00148 }
00149
00150 void
00151 VectorNetBit::getConnectedPorts(
00152 std::vector< PortSharedPtr > &outPorts,
00153 bool inSkipChildConnections
00154 ) const throw() {
00155 Composite<Net>::Pointer parent = getParentCollection();
00156 if( !parent )
00157 {
00158 Error e( eMessageIdErrorPointerToItemDoesNotExist,
00159 __FUNCTION__, __FILE__, __LINE__ );
00160 e.saveContextData("Pointer to parent collection does not exist", parent);
00161 throw e;
00162 }
00163 if( eCompositionTypeVector
00164 != parent->getCompositionType() )
00165 {
00166 Error e( eMessageIdErrorCompositionTypeMismatch,
00167 __FUNCTION__, __FILE__, __LINE__ );
00168 e.saveContextData("Composition type mismatch", parent->getCompositionType());
00169 throw e;
00170 }
00171
00172 Net::getConnectedPorts( outPorts );
00173
00174 if( !inSkipChildConnections )
00175 {
00176
00177
00178 VectorBit<Port>::List parentConnections;
00179 parent->getConnectedPorts( parentConnections, true );
00180 VectorBit<Port>::List::iterator connPort
00181 = parentConnections.begin();
00182 VectorBit<Port>::List::iterator connPortEnd
00183 = parentConnections.end();
00184 const std::vector<VectorBit<Net>::SizeType> &myIndex = getIndices();
00185 for(; connPort != connPortEnd; ++connPort )
00186 {
00187 Composite<Port>::Pointer cousin;
00188
00189 if( eCompositionTypeVector
00190 == (*connPort)->getCompositionType() )
00191 {
00192 cousin = (*connPort)->get( myIndex );
00193 }
00194 else
00195 {
00196 VectorBit<Port>::List bChildren;
00197 (*connPort)->getChildren( bChildren );
00198 cousin = bChildren[ getAbsoluteIndex() ];
00199 }
00200 if( !cousin )
00201 {
00202 Error e( eMessageIdErrorPointerToItemDoesNotExist,
00203 __FUNCTION__, __FILE__, __LINE__ );
00204 e.saveContextData("Pointer to item does not exist", cousin);
00205 throw e;
00206 }
00207 outPorts.push_back( cousin );
00208 }
00209
00210
00211 }
00212 return;
00213 }
00214
00215 void
00216 VectorNetBit::getConnectedPortRefs(
00217 std::vector< PortReferenceSharedPtr > &outPortRefs,
00218 bool inSkipChildConnections
00219 ) const throw() {
00220 Composite<Net>::Pointer parent = getParentCollection();
00221 if( !parent )
00222 {
00223 Error e( eMessageIdErrorPointerToItemDoesNotExist,
00224 __FUNCTION__, __FILE__, __LINE__ );
00225 e.saveContextData("Pointer to parent collection does not exist", parent);
00226 throw e;
00227 }
00228
00229 if( eCompositionTypeVector
00230 != parent->getCompositionType() )
00231 {
00232 Error e( eMessageIdErrorCompositionTypeMismatch,
00233 __FUNCTION__, __FILE__, __LINE__ );
00234 e.saveContextData("Composition type mismatch", parent->getCompositionType());
00235 throw e;
00236 }
00237
00238 Net::getConnectedPortRefs ( outPortRefs );
00239
00240 if( !inSkipChildConnections )
00241 {
00242
00243
00244 VectorBit<PortReference>::List parentConnections;
00245 parent->getConnectedPortRefs( parentConnections, true );
00246 VectorBit<PortReference>::List::iterator connPortRef
00247 = parentConnections.begin();
00248 VectorBit<PortReference>::List::iterator connPortRefEnd
00249 = parentConnections.end();
00250 const std::vector<VectorBit<Net>::SizeType> &myIndex = getIndices();
00251 for(; connPortRef != connPortRefEnd; ++connPortRef )
00252 {
00253 Composite<PortReference>::Pointer cousin;
00254
00255 if( eCompositionTypeVector
00256 == (*connPortRef)->getCompositionType() )
00257 {
00258 cousin = (*connPortRef)->get( myIndex );
00259 }
00260 else
00261 {
00262 VectorBit<PortReference>::List bChildren;
00263 (*connPortRef)->getChildren( bChildren );
00264 cousin = bChildren[ getAbsoluteIndex() ];
00265 }
00266 if( !cousin )
00267 {
00268 Error e( eMessageIdErrorPointerToItemDoesNotExist,
00269 __FUNCTION__, __FILE__, __LINE__ );
00270 e.saveContextData("Pointer to item does not exist", cousin);
00271 throw e;
00272 }
00273 outPortRefs.push_back( cousin );
00274 }
00275
00276
00277 }
00278 return;
00279 }
00280
00281 VectorNetBit::VectorNetBit()
00282 : Net(),
00283 VectorBit<Net>() {
00284 }
00285
00286 VectorNetBit::~VectorNetBit() throw() {
00287 }
00288
00289 #ifdef GENOM_SERIALIZATION
00290 template<class Archive> void
00291 VectorNetBit::serialize( Archive &ar, unsigned int ) {
00292 ar & boost::serialization::base_object< Net >( *this );
00293 ar & boost::serialization::base_object< VectorBit<Net> >(*this);
00294 }
00295
00296
00297 template void
00298 VectorNetBit::serialize<boost::archive::binary_iarchive>(
00299 boost::archive::binary_iarchive & ar, const unsigned int);
00300
00301 template void
00302 VectorNetBit::serialize<boost::archive::binary_oarchive>(
00303 boost::archive::binary_oarchive & ar, const unsigned int);
00304
00305 #endif //GENOM_SERIALIZATION
00306
00307 }
00308
00309 }