00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "torc/generic/om/Simulate.hpp"
00017 #include "torc/generic/om/WaveValue.hpp"
00018 #include "torc/generic/om/Apply.hpp"
00019 #include "torc/generic/om/InterfaceAttributes.hpp"
00020 #include "torc/generic/om/View.hpp"
00021
00022 namespace torc {
00023
00024 namespace generic {
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 SimulateSharedPtr
00042 Simulate::Factory::newSimulatePtr( const std::string & inName,
00043 const std::vector< PortListAliasSharedPtr > & inPortListAliases,
00044 const std::vector< ApplySharedPtr > & inAllApply,
00045 const std::vector< WaveValueSharedPtr > & inWaveValues,
00046 const ViewSharedPtr & inView,
00047 const std::string & inOriginalName,
00048 const InterfaceAttributesSharedPtr & inInterfaceAttributes ) throw(Error) {
00049 try
00050 {
00051 SimulateSharedPtr newSimulate;
00052 create( newSimulate );
00053 newSimulate->setName( inName );
00054 newSimulate->setPortListAliases( inPortListAliases );
00055 newSimulate->setAllApply( inAllApply );
00056 newSimulate->setWaveValues( inWaveValues );
00057 newSimulate->setOriginalName( inOriginalName );
00058 if( inInterfaceAttributes )
00059 {
00060 inInterfaceAttributes->setSimulate( newSimulate );
00061 inView->setInterfaceAttributes( inInterfaceAttributes );
00062 }
00063 else
00064 {
00065 inView->setSimulate( newSimulate );
00066 }
00067 return newSimulate;
00068 }
00069 catch( Error &e )
00070 {
00071 e.setCurrentLocation(
00072 __FUNCTION__, __FILE__, __LINE__ );
00073 throw;
00074 }
00075 }
00076
00077 void
00078 Simulate::accept(BaseVisitor & inoutVisitor) throw(Error) {
00079 try
00080 {
00081 runVisitor( *this, inoutVisitor );
00082 }
00083 catch( Error &e )
00084 {
00085 e.setCurrentLocation(
00086 __FUNCTION__, __FILE__, __LINE__ );
00087 throw;
00088 }
00089 }
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 void
00101 Simulate::addPortListAlias(const PortListAliasSharedPtr & inPortListAlias) throw(Error) {
00102 if( !inPortListAlias )
00103 {
00104 return;
00105 }
00106 std::string name = inPortListAlias->getName();
00107 if( name.empty() )
00108 {
00109 Error e( eMessageIdErrorEmptyItemName,
00110 __FUNCTION__, __FILE__, __LINE__ );
00111 e.saveContextData("Empty port list alias name ", name);
00112 throw e;
00113 }
00114 if( false == mPortListAliasSymTab.set( name, inPortListAlias ) )
00115 {
00116 Error e( eMessageIdErrorItemAlreadyExists,
00117 __FUNCTION__, __FILE__, __LINE__ );
00118 e.saveContextData("Port list alias name", name);
00119 throw e;
00120 }
00121 }
00122
00123
00124
00125
00126
00127
00128 void
00129 Simulate::setPortListAliases(
00130 const std::vector< PortListAliasSharedPtr > & inPortListAliases ) throw(Error) {
00131 std::vector< PortListAliasSharedPtr >::const_iterator it = inPortListAliases.begin();
00132 for( ; it != inPortListAliases.end(); it++ )
00133 {
00134 try
00135 {
00136 addPortListAlias( *it );
00137 }
00138 catch( Error &e )
00139 {
00140 e.setCurrentLocation(
00141 __FUNCTION__, __FILE__, __LINE__ );
00142 throw;
00143 }
00144 }
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154 PortListAliasSharedPtr
00155 Simulate::findPortListAlias(const std::string & inName) throw() {
00156 if( inName.empty() )
00157 {
00158 Error e( eMessageIdErrorEmptyItemName,
00159 __FUNCTION__, __FILE__, __LINE__ );
00160 e.saveContextData("Empty PortListAlias name", inName);
00161 throw e;
00162 }
00163 PortListAliasSharedPtr portListAlias;
00164 mPortListAliasSymTab.get( inName, portListAlias );
00165 return portListAlias;
00166 }
00167
00168
00169
00170
00171
00172
00173 void
00174 Simulate::addApply( const ApplySharedPtr & inSource) throw(Error) {
00175 try
00176 {
00177 mAllApply.push_back( inSource );
00178 }
00179 catch( Error &e )
00180 {
00181 e.setCurrentLocation(
00182 __FUNCTION__, __FILE__, __LINE__ );
00183 throw;
00184 }
00185 }
00186
00187
00188
00189
00190
00191
00192 void
00193 Simulate::setAllApply( const std::vector< ApplySharedPtr > & inAllApply ) throw(Error) {
00194 std::vector< ApplySharedPtr >::const_iterator it = inAllApply.begin();
00195 for( ; it != inAllApply.end(); it++ )
00196 {
00197 try
00198 {
00199 addApply( *it );
00200 }
00201 catch( Error &e )
00202 {
00203 e.setCurrentLocation(
00204 __FUNCTION__, __FILE__, __LINE__ );
00205 throw;
00206 }
00207 }
00208 }
00209
00210
00211
00212
00213
00214
00215 void
00216 Simulate::setWaveValues(
00217 const std::vector< WaveValueSharedPtr > & inWaveValues ) throw(Error) {
00218 std::vector< WaveValueSharedPtr >::const_iterator it = inWaveValues.begin();
00219 for( ; it != inWaveValues.end(); it++ )
00220 {
00221 try
00222 {
00223 addWaveValue( *it );
00224 }
00225 catch( Error &e )
00226 {
00227 e.setCurrentLocation(
00228 __FUNCTION__, __FILE__, __LINE__ );
00229 throw;
00230 }
00231 }
00232 }
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 void
00243 Simulate::addWaveValue( const WaveValueSharedPtr & inSource ) throw(Error) {
00244 if( !inSource )
00245 {
00246 return;
00247 }
00248 std::string name = inSource->getName();
00249 if( name.empty() )
00250 {
00251 Error e( eMessageIdErrorEmptyItemName,
00252 __FUNCTION__, __FILE__, __LINE__ );
00253 e.saveContextData("Empty WaveValue name ", name);
00254 throw e;
00255 }
00256 if( false == mWaveValueSymTab.set( name, inSource ) )
00257 {
00258 Error e( eMessageIdErrorItemAlreadyExists,
00259 __FUNCTION__, __FILE__, __LINE__ );
00260 e.saveContextData("WaveValue name", name);
00261 throw e;
00262 }
00263 }
00264
00265
00266
00267
00268
00269
00270
00271
00272 WaveValueSharedPtr
00273 Simulate::findWaveValue(const std::string & inName) throw() {
00274 if( inName.empty() )
00275 {
00276 Error e( eMessageIdErrorEmptyItemName,
00277 __FUNCTION__, __FILE__, __LINE__ );
00278 e.saveContextData("Empty WaveValue name", inName);
00279 throw e;
00280 }
00281 WaveValueSharedPtr waveValue;
00282 mWaveValueSymTab.get( inName, waveValue );
00283 return waveValue;
00284 }
00285
00286 Simulate::Simulate()
00287 : Nameable(),
00288 Renamable(),
00289 Commentable(),
00290 Visitable(),
00291 SelfReferencing<Simulate>(),
00292 UserDataContainer(),
00293 mPortListAliasSymTab(),
00294 mWaveValueSymTab(),
00295 mAllApply() {
00296 }
00297
00298 Simulate::~Simulate() throw() {
00299 }
00300
00301 }
00302
00303 }