| 1315 | //----------------------------------------------------------------------------- |
| 1316 | |
| 1317 | SimObject* SimObject::clone() |
| 1318 | { |
| 1319 | if( !getClassRep() ) |
| 1320 | return NULL; |
| 1321 | |
| 1322 | ConsoleObject* conObject = getClassRep()->create(); |
| 1323 | if( !conObject ) |
| 1324 | return NULL; |
| 1325 | |
| 1326 | SimObject* simObject = dynamic_cast< SimObject* >( conObject ); |
| 1327 | if( !simObject ) |
| 1328 | { |
| 1329 | delete conObject; |
| 1330 | return NULL; |
| 1331 | } |
| 1332 | |
| 1333 | simObject->assignFieldsFrom( this ); |
| 1334 | |
| 1335 | String name = Sim::getUniqueName( getName() ); |
| 1336 | if( !simObject->registerObject( name ) ) |
| 1337 | { |
| 1338 | delete simObject; |
| 1339 | return NULL; |
| 1340 | } |
| 1341 | |
| 1342 | if( getGroup() ) |
| 1343 | getGroup()->addObject( simObject ); |
| 1344 | |
| 1345 | return simObject; |
| 1346 | } |
| 1347 | |
| 1348 | //----------------------------------------------------------------------------- |
| 1349 |
no test coverage detected