//------------------------------------------------------------------------------ // unregisterAllObjects() -- //------------------------------------------------------------------------------ bool NetIO::unregisterAllObjects() { // Stop Registration For Object Classes clearAllObjectClassRegistrationFlags(); // Unregister all of our output objects ... for (unsigned int idx = 0; idx < nOutObjects; idx++) { Nib* nib = outHandleTbl[idx]; if (nib->isRegistered()) { getRTIambassador()->deleteObjectInstance(nib->getObjectHandle(),0); nib->setObjectHandle(0); nib->setClassIndex(0); } } return true; }
void NetIO::destroyOutputNib(Simulation::Nib* const nib0) { std::cout << "NetIO::destroyOutputNib(" << nib0 << ")" << std::endl; Nib* nib = dynamic_cast<Nib*>(nib0); if (nib != 0) { if (nib->isRegistered()) { // When this output NIB was registered as an HLA object ... std::cout << "###DeleteReq- Unref-2: handle: " << nib->getObjectHandle() << std::endl; removeNibFromObjectTables(nib, OUTPUT_NIB); getRTIambassador()->deleteObjectInstance(nib->getObjectHandle(),0); nib->setObjectHandle(0); nib->setClassIndex(0); } // Let our base class handle the rest BaseClass::destroyOutputNib(nib); } }
//------------------------------------------------------------------------------ // discoverObjectInstance() -- handle the discover of an object //------------------------------------------------------------------------------ void NetIO::discoverObjectInstance( const RTI::ObjectHandle theObject, const RTI::ObjectClassHandle theObjectClass, const char* theObjectName) { BaseEntity* baseEntity = nullptr; unsigned int idx = findObjectClassIndex(theObjectClass); switch (idx) { case AIRCRAFT_CLASS : baseEntity = new Aircraft(); break; case MUNITION_CLASS : baseEntity = new Munition(); break; case HUMAN_CLASS : baseEntity = new Human(); break; case GROUND_VEHICLE_CLASS : baseEntity = new GroundVehicle(); break; case SURFACE_VESSEL_CLASS : baseEntity = new SurfaceVessel(); break; }; if (baseEntity != nullptr) { Nib* nib = dynamic_cast<Nib*>( createNewInputNib() ); if (nib != nullptr) { nib->setObjectHandle(theObject); nib->setObjectName(theObjectName); nib->setClassIndex(idx); nib->setTimeExec( (double) getCurrentTime() ); nib->setBaseEntity(baseEntity); addNib2InputList(nib); addNibToObjectTables(nib, INPUT_NIB); nib->unref(); } baseEntity->unref(); // (NIB has it now) } }