00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TORC_GENERIC_OM_NET_HPP
00017 #define TORC_GENERIC_OM_NET_HPP
00018
00019 #include "torc/generic/om/PointerTypes.hpp"
00020 #include "torc/generic/om/DumpRestoreConfig.hpp"
00021
00022 #include <algorithm>
00023 #include <vector>
00024
00025 #ifdef GENOM_SERIALIZATION
00026 #include <boost/serialization/access.hpp>
00027 #endif //GENOM_SERIALIZATION
00028
00029 #include "torc/generic/om/Commentable.hpp"
00030 #include "torc/generic/om/Composite.hpp"
00031 #include "torc/generic/om/Connectable.hpp"
00032 #include "torc/generic/util/Error.hpp"
00033 #include "torc/generic/om/Nameable.hpp"
00034 #include "torc/generic/om/ParentedObject.hpp"
00035 #include "torc/generic/om/PropertyContainer.hpp"
00036 #include "torc/generic/om/Renamable.hpp"
00037 #include "torc/generic/om/SymTab.hpp"
00038 #include "torc/generic/om/Visitable.hpp"
00039 #include "torc/generic/om/View.hpp"
00040 #include "torc/generic/om/UserDataContainer.hpp"
00041
00042 namespace torc { namespace generic { class ConnectionHandler; } }
00043 namespace torc { namespace generic { class Port; } }
00044 namespace torc { namespace generic { class PortReference; } }
00045 namespace torc { namespace generic { class NetAttributes; } }
00046
00047 namespace torc {
00048
00049 namespace generic {
00050
00051
00052
00053
00054
00055
00056 class Net :
00057 public Commentable,
00058 public Connectable,
00059 public Nameable,
00060 public PropertyContainer,
00061 public Renamable,
00062 public Visitable,
00063 virtual public Composite<Net>,
00064 public ParentedObject<View>,
00065 public UserDataContainer
00066 {
00067 #ifdef GENOM_SERIALIZATION
00068 friend class boost::serialization::access;
00069 #endif //GENOM_SERIALIZATION
00070 friend class ConnectionHandler;
00071
00072 public:
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 void
00103 addSubnet(
00104 const NetSharedPtr &inSubnet) throw(Error);
00105
00106
00107
00108
00109
00110
00111
00112 NetSharedPtr
00113 findSubnet(const std::string &inName) throw(Error);
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 void
00146 removeSubnet(const std::string &inName) throw(Error);
00147
00148 inline void getSubnets(
00149 std::vector< NetSharedPtr > &outSubnets
00150 ) const throw();
00151
00152 void
00153 setSubnets(
00154 const std::vector< NetSharedPtr >
00155 & inSource) throw(Error);
00156
00157
00158
00159
00160
00161 template<typename _Action>
00162 inline void
00163 applyOnAllSubnets( const _Action &action ) throw(Error);
00164
00165 inline NetSharedPtr
00166 getParentNet() const throw();
00167
00168 void
00169 setParentNet( const NetSharedPtr &inParent ) throw();
00170
00171
00172
00173
00174
00175
00176 inline const NetAttributesSharedPtr
00177 getAttributes() const throw();
00178
00179
00180
00181
00182
00183
00184 void
00185 setAttributes(const NetAttributesSharedPtr & inSource) throw();
00186
00187 protected:
00188 void
00189 addConnectedPort(
00190 const PortSharedPtr &inPort) throw(Error);
00191
00192 void
00193 removeConnectedPort(const PortSharedPtr &inPort) throw(Error);
00194
00195 void
00196 addConnectedPortList(
00197 const PortListSharedPtr &inPort) throw(Error);
00198
00199 void
00200 removeConnectedPortList(
00201 const PortListSharedPtr &inList) throw(Error);
00202
00203 public:
00204
00205
00206
00207
00208
00209 PortSharedPtr
00210 findConnectedPort(const std::string &inName) throw(Error);
00211
00212
00213
00214
00215
00216
00217 virtual void
00218 getConnectedPorts(
00219 std::vector< PortSharedPtr > &outPort,
00220 bool inSkipChildConnections = false ) const throw();
00221
00222
00223
00224
00225
00226
00227 template<typename _Action>
00228 inline void
00229 applyOnAllConnectedPorts( const _Action &action ) throw(Error);
00230
00231
00232
00233
00234
00235 virtual void
00236 getConnectedPortLists(
00237 std::vector< PortListSharedPtr > &outPortList) const throw();
00238
00239
00240
00241
00242
00243
00244 template<typename _Action>
00245 inline void
00246 applyOnAllConnectedPortLists(
00247 const _Action &action ) throw(Error);
00248
00249 using Connectable::disconnect;
00250
00251 virtual void
00252 disconnect() throw(Error);
00253
00254
00255 protected:
00256
00257 void
00258 setConnectedPorts(
00259 const std::vector< PortSharedPtr > & inSource) throw(Error);
00260
00261
00262 protected:
00263
00264 void
00265 addConnectedPortReference(
00266 const PortReferenceSharedPtr & portRef) throw(Error);
00267
00268 void
00269 removeConnectedPortReference(
00270 const PortReferenceSharedPtr &inPortRef) throw(Error);
00271
00272 public:
00273
00274
00275
00276
00277
00278 PortReferenceSharedPtr
00279 findConnectedPortReference(
00280 const std::string &inName) throw(Error);
00281
00282
00283
00284
00285
00286 virtual void
00287 getConnectedPortRefs(
00288 std::vector< PortReferenceSharedPtr > &outPortRefs,
00289 bool inSkipChildConnections = false) const throw();
00290
00291
00292
00293
00294
00295
00296 template<typename _Action>
00297 inline void
00298 applyOnAllConnectedPortRefs( const _Action &action ) throw(Error);
00299
00300 protected:
00301 Net();
00302
00303 public:
00304 virtual
00305 ~Net() throw();
00306
00307 private:
00308 #ifdef GENOM_SERIALIZATION
00309 template<class Archive> void
00310 serialize( Archive &ar, unsigned int );
00311 #endif //GENOM_SERIALIZATION
00312
00313 Net(const Net & source) throw();
00314
00315 Net &
00316 operator=(const Net & source) throw();
00317
00318 protected:
00319
00320 void
00321 setConnectedPortRefs(
00322 const std::vector< PortReferenceSharedPtr > & inSource) throw(Error);
00323
00324 private:
00325 SymTab< std::string, NetSharedPtr, true > mSubnets;
00326 std::list< PortSharedPtr > mConnectedPorts;
00327 std::list< PortListSharedPtr > mConnectedPortLists;
00328 std::list< PortReferenceSharedPtr > mConnectedPortRefs;
00329 NetSharedPtr mParentNet;
00330 NetAttributesSharedPtr mAttributes;
00331 };
00332
00333 inline void
00334 Net::getSubnets(
00335 std::vector< NetSharedPtr > &outSubnets ) const throw() {
00336 mSubnets.getValues( outSubnets );
00337 return;
00338 }
00339
00340 template<typename _Action>
00341 inline void
00342 Net::applyOnAllSubnets( const _Action &action ) throw(Error)
00343 {
00344 try
00345 {
00346 mSubnets.applyOnAll( action );
00347 }
00348 catch(Error &e)
00349 {
00350 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00351 throw;
00352 }
00353 }
00354
00355 inline NetSharedPtr
00356 Net::getParentNet() const throw() {
00357 return mParentNet;
00358 }
00359
00360
00361
00362
00363
00364
00365 inline const NetAttributesSharedPtr
00366 Net::getAttributes() const throw() {
00367 return mAttributes;
00368 }
00369
00370 template<typename _Action>
00371 inline void
00372 Net::applyOnAllConnectedPorts( const _Action &action ) throw(Error)
00373 {
00374 try
00375 {
00376 std::for_each( mConnectedPorts.begin(),
00377 mConnectedPorts.end(), action );
00378 }
00379 catch(Error &e)
00380 {
00381 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00382 throw;
00383 }
00384 }
00385
00386 template<typename _Action>
00387 inline void
00388 Net::applyOnAllConnectedPortLists( const _Action &action ) throw(Error)
00389 {
00390 try
00391 {
00392 std::for_each( mConnectedPortLists.begin(),
00393 mConnectedPortLists.end(), action );
00394 }
00395 catch(Error &e)
00396 {
00397 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00398 throw;
00399 }
00400 }
00401
00402 template<typename _Action>
00403 inline void
00404 Net::applyOnAllConnectedPortRefs( const _Action &action ) throw(Error)
00405 {
00406 try
00407 {
00408 std::for_each( mConnectedPortRefs.begin(),
00409 mConnectedPortRefs.end(), action );
00410 }
00411 catch(Error &e)
00412 {
00413 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00414 throw;
00415 }
00416 }
00417
00418 }
00419
00420 }
00421 #endif // TORC_GENERIC_OM_NET_HPP