| 1461 | //----------------------------------------------------------------------------- |
| 1462 | |
| 1463 | SimObject* SimObject::clone() |
| 1464 | { |
| 1465 | if( !getClassRep() ) |
| 1466 | return NULL; |
| 1467 | |
| 1468 | ConsoleObject* conObject = getClassRep()->create(); |
| 1469 | if( !conObject ) |
| 1470 | return NULL; |
| 1471 | |
| 1472 | SimObject* simObject = dynamic_cast< SimObject* >( conObject ); |
| 1473 | if( !simObject ) |
| 1474 | { |
| 1475 | delete conObject; |
| 1476 | return NULL; |
| 1477 | } |
| 1478 | |
| 1479 | simObject->assignFieldsFrom( this ); |
| 1480 | |
| 1481 | String name = Sim::getUniqueName( getName() ); |
| 1482 | if( !simObject->registerObject( name.c_str() ) ) |
| 1483 | { |
| 1484 | delete simObject; |
| 1485 | return NULL; |
| 1486 | } |
| 1487 | |
| 1488 | if( getGroup() ) |
| 1489 | getGroup()->addObject( simObject ); |
| 1490 | |
| 1491 | return simObject; |
| 1492 | } |
| 1493 | |
| 1494 | //----------------------------------------------------------------------------- |
| 1495 |
no test coverage detected