00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TORC_GENERIC_OM_INTERFACEJOINEDINFO_HPP
00017 #define TORC_GENERIC_OM_INTERFACEJOINEDINFO_HPP
00018
00019 #include "torc/generic/om/PointerTypes.hpp"
00020 #include "torc/generic/util/Error.hpp"
00021 #include "torc/generic/om/FactoryType.hpp"
00022 #include "torc/generic/om/Visitable.hpp"
00023 #include "torc/generic/om/VisitorType.hpp"
00024 #include "torc/generic/om/SelfReferencing.hpp"
00025
00026 #include <list>
00027 #include <vector>
00028
00029 namespace torc { namespace generic { class Port; } }
00030 namespace torc { namespace generic { class PortList; } }
00031 namespace torc { namespace generic { class BaseVisitor; } }
00032
00033 namespace torc {
00034
00035 namespace generic {
00036
00037
00038
00039
00040
00041
00042
00043
00044 class InterfaceJoinedInfo :
00045 public Visitable,
00046 public SelfReferencing<InterfaceJoinedInfo>
00047 {
00048 friend class FactoryType<InterfaceJoinedInfo>;
00049
00050 public:
00051
00052
00053
00054
00055 enum JoinedType
00056 {
00057 eJoinedTypeJoin = 0,
00058 eJoinedTypeWeak,
00059 eJoinedTypeMust
00060 };
00061
00062
00063
00064
00065
00066
00067 enum RelationType
00068 {
00069 eRelationTypeParent = 0,
00070 eRelationTypeChild
00071 };
00072
00073
00074
00075
00076
00077 typedef VisitorType<InterfaceJoinedInfo> Visitor;
00078
00079
00080
00081
00082 class Factory: public FactoryType<InterfaceJoinedInfo>
00083 {
00084 public:
00085 using FactoryType<InterfaceJoinedInfo>::create;
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 InterfaceJoinedInfoSharedPtr
00097 virtual newInterfaceJoinedInfoPtr( const std::list< PortSharedPtr > & inPorts,
00098 const std::list< PortListSharedPtr > & inPortLists,
00099 const ViewSharedPtr & inViewPtr,
00100 const InterfaceJoinedInfoSharedPtr & inParentJoinedInfo
00101 = InterfaceJoinedInfoSharedPtr() ) throw(Error);
00102 };
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 virtual void
00118 accept(BaseVisitor & visitor) throw(Error);
00119
00120
00121
00122
00123
00124
00125 inline const JoinedType
00126 getJoinedType() const throw();
00127
00128
00129
00130
00131
00132
00133 void
00134 setJoinedType( const JoinedType & inSource ) throw();
00135
00136
00137
00138
00139
00140
00141
00142 void
00143 addPort( const PortSharedPtr & inPort ) throw(Error);
00144
00145
00146
00147
00148
00149
00150 inline void
00151 getPorts( std::list< PortSharedPtr > & outPorts ) const throw();
00152
00153
00154
00155
00156
00157
00158 void
00159 setPorts( const std::list< PortSharedPtr > & inSource ) throw();
00160
00161
00162
00163
00164
00165
00166 void
00167 addPortList( const PortListSharedPtr & inPortList ) throw();
00168
00169
00170
00171
00172
00173
00174 inline void
00175 getPortLists( std::list< PortListSharedPtr > & outPortLists) const throw();
00176
00177
00178
00179
00180
00181
00182 void
00183 setPortLists( const std::list< PortListSharedPtr > & inSource ) throw();
00184
00185
00186
00187
00188
00189
00190 inline void
00191 getChildren( std::vector< InterfaceJoinedInfoSharedPtr >
00192 & outJoinedInfos ) const throw();
00193
00194
00195
00196
00197
00198
00199
00200
00201 void
00202 setChildren(const std::vector< InterfaceJoinedInfoSharedPtr >
00203 & inSource) throw();
00204
00205
00206
00207
00208
00209
00210 bool
00211 addChildJoinedInfo(
00212 const InterfaceJoinedInfoSharedPtr & inChildJoinInfo) throw();
00213
00214
00215
00216
00217
00218 template<typename _Action>
00219 inline void applyOnAllChildren(const _Action & action) throw(Error);
00220
00221
00222
00223
00224
00225
00226 inline const RelationType
00227 getRelationType() const throw();
00228
00229
00230
00231
00232
00233
00234 void
00235 setRelationType(const RelationType & inSource) throw();
00236
00237
00238
00239
00240
00241 size_t
00242 getSize() const throw();
00243
00244 virtual ~InterfaceJoinedInfo() throw();
00245
00246 protected:
00247 InterfaceJoinedInfo();
00248
00249 private:
00250 JoinedType mJoinedType;
00251 RelationType mRelationType;
00252 std::list< PortSharedPtr > mJoinedPorts;
00253 std::list< PortListSharedPtr > mJoinedPortLists;
00254 std::vector< InterfaceJoinedInfoSharedPtr > mChildren;
00255
00256 };
00257
00258
00259
00260
00261
00262
00263 inline const InterfaceJoinedInfo::JoinedType
00264 InterfaceJoinedInfo::getJoinedType() const throw() {
00265 return mJoinedType;
00266 }
00267
00268
00269
00270
00271
00272
00273 inline void
00274 InterfaceJoinedInfo::getPorts(
00275 std::list< PortSharedPtr > & outPorts ) const throw() {
00276 outPorts.insert( outPorts.end(),
00277 mJoinedPorts.begin(), mJoinedPorts.end() );
00278 }
00279
00280
00281
00282
00283
00284
00285 inline void
00286 InterfaceJoinedInfo::getPortLists(
00287 std::list< PortListSharedPtr > & outPortLists ) const throw() {
00288 outPortLists.insert( outPortLists.end(),
00289 mJoinedPortLists.begin(), mJoinedPortLists.end() );
00290 }
00291
00292
00293
00294
00295
00296
00297 inline void
00298 InterfaceJoinedInfo::getChildren( std::vector< InterfaceJoinedInfoSharedPtr >
00299 & outJoinedInfos ) const throw() {
00300 outJoinedInfos.insert( outJoinedInfos.end(),
00301 mChildren.begin(), mChildren.end() );
00302 }
00303
00304
00305
00306
00307
00308 template<typename _Action>
00309 inline void
00310 InterfaceJoinedInfo::applyOnAllChildren(const _Action & action) throw(Error) {
00311 try
00312 {
00313 std::vector< InterfaceJoinedInfoSharedPtr >::iterator it
00314 = mChildren.begin();
00315 for(; it != mChildren.end(); ++ it )
00316 {
00317 action( *it );
00318 }
00319 }
00320 catch(Error &e)
00321 {
00322 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00323 throw;
00324 }
00325 }
00326
00327
00328
00329
00330
00331
00332 inline const InterfaceJoinedInfo::RelationType
00333 InterfaceJoinedInfo::getRelationType() const throw() {
00334 return mRelationType;
00335 }
00336
00337 }
00338
00339 }
00340 #endif // TORC_GENERIC_OM_INTERFACEJOINEDINFO_HPP