//------------------------------------------------------------------------------
// resetStores() -- Reset all stores
//------------------------------------------------------------------------------
void Stores::resetStores(Basic::PairStream* const list)
{
   // Reset the external stores
   if (list != nullptr) {
      Basic::List::Item* item = list->getFirstItem();
      while (item != nullptr) {
         Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
         Basic::Component* p = static_cast<Basic::Component*>( pair->object() );
         p->event(RESET_EVENT);
         item = item->getNext();
      }
   }
}
Example #2
0
// DATALINK_MESSAGE event handler
bool Datalink::onDatalinkMessageEvent(Basic::Object* const msg)
{
   // Just pass it down to all of our subcomponents
   Basic::PairStream* subcomponents = getComponents();
   if (subcomponents != 0) {
      for (Basic::List::Item* item = subcomponents->getFirstItem(); item != 0; item = item->getNext()) {
         Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
         Basic::Component* sc = static_cast<Basic::Component*>(pair->object());
         sc->event(DATALINK_MESSAGE, msg);
      }
      subcomponents->unref();
      subcomponents = 0;
   }
   return true;
}
Example #3
0
//------------------------------------------------------------------------------
// killedNotification() -- Default killed notification handler
//------------------------------------------------------------------------------
bool System::killedNotification(Player* const p)
{
   // Just let all of our subcomponents know that we were just killed
   Basic::PairStream* subcomponents = getComponents();
   if(subcomponents != 0) {
      for (Basic::List::Item* item = subcomponents->getFirstItem(); item != 0; item = item->getNext()) {
         Basic::Pair* pair = (Basic::Pair*)(item->getValue());
         Basic::Component* sc = (Basic::Component*) pair->object();
         sc->event(KILL_EVENT, p);
      }
      subcomponents->unref();
      subcomponents = 0;
   }
   return true;
}
Example #4
0
//------------------------------------------------------------------------------
// Default function to jettison all jettisonable stores
//------------------------------------------------------------------------------
bool Stores::jettisonAll()
{
   // Notify the external stores that we're shutting down
   Basic::PairStream* list = getStores();
   if (list != 0) {
      Basic::List::Item* item = list->getFirstItem();
      while (item != 0) {
         Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
         Basic::Component* p = static_cast<Basic::Component*>( pair->object() );
         p->event(JETTISON_EVENT);
         item = item->getNext();
      }
      list->unref();
      list = 0;
   }
   return true;
}
Example #5
0
//------------------------------------------------------------------------------
// shutdownNotification() -- We're shutting down
//------------------------------------------------------------------------------
bool StoresMgr::shutdownNotification()
{
   // Notify the external stores that we're shutting down
   Basic::PairStream* list = getStores();
   if (list != 0) {
      Basic::List::Item* item = list->getFirstItem();
      while (item != 0) {
         Basic::Pair* pair = (Basic::Pair*)(item->getValue());
         Basic::Component* p = (Basic::Component*)( pair->object() );
         p->event(SHUTDOWN_EVENT);
         item = item->getNext();
      }
      list->unref();
      list = 0;
   }

   // Clear our stores
   setSlotStores(0);

   return BaseClass::shutdownNotification();
}
Example #6
0
//------------------------------------------------------------------------------
// shutdownNotification() -- We're shutting down
//------------------------------------------------------------------------------
bool Station::shutdownNotification()
{
   // Tell the interoperability networks that we're shutting down
   if (networks != 0) {
      Basic::List::Item* item = networks->getFirstItem();
      while (item != 0) {
         Basic::Pair* pair = (Basic::Pair*)(item->getValue());
         Basic::Component* p = dynamic_cast<Basic::Component*>(pair->object());
         p->event(SHUTDOWN_EVENT);
         item = item->getNext();
      }
   }
   setSlotNetworks(0);

   // Tell the I/O devices that we're shutting down
   if (ioHandlers != 0) {
      Basic::List::Item* item = ioHandlers->getFirstItem();
      while (item != 0) {
         Basic::Pair* pair = (Basic::Pair*)(item->getValue());
         Basic::Component* p = dynamic_cast<Basic::Component*>(pair->object());
         p->event(SHUTDOWN_EVENT);
         item = item->getNext();
      }
   }
   setSlotIoHandler((Basic::PairStream*)0);

   // Tell our simulation to shut down
   Simulation* s = getSimulation();
   if (s != 0) {
      s->event(SHUTDOWN_EVENT);
   }
   setOwnshipPlayer(0);

   // Inform our OTW interfaces
   if (otw != 0) {
      Basic::List::Item* item = otw ->getFirstItem();
      while (item != 0) {
         Basic::Pair* pair = (Basic::Pair*)(item->getValue());
         Basic::Component* p = dynamic_cast<Basic::Component*>(pair->object());
         p->event(SHUTDOWN_EVENT);
         item = item->getNext();
      }
   }
   setSlotOutTheWindow((Basic::PairStream*)0);

   // Zero (unref) our thread objects (of any).  The thread's functions have ref()'d
   // these objects, so they won't be deleted until the threads terminate, which they
   // will based on our BaseClass::isShutdown() function.  But at least we won't
   // mistakenly think that they're still around.
   tcThread = 0;
   netThread = 0;
   bgThread = 0;

   // remove the reset timer
   setSlotStartupResetTime(0);

   return BaseClass::shutdownNotification();
}
Example #7
0
bool Station::setSlotIoHandler(Basic::PairStream* const list)
{
    bool ok = true;

    // Remove the old list
    if (ioHandlers != 0) {
        // we are no longer the container for these handlers
        for (Basic::List::Item* item = ioHandlers->getFirstItem(); item != 0; item = item->getNext()) {
            Basic::Pair* pair = (Basic::Pair*)(item->getValue());
            Basic::Component* p = (Basic::Component*)( pair->object() );
            p->container(0);
        }
        ioHandlers = 0;
    }

    // Set our list pointer
    ioHandlers = list;

    // Make sure the new list is setup correctly
    if (ioHandlers != 0) {
        for (Basic::List::Item* item = ioHandlers->getFirstItem(); item != 0; item = item->getNext()) {
            Basic::Pair* pair = (Basic::Pair*)(item->getValue());
            Basic::IoHandler* p = dynamic_cast<Basic::IoHandler*>( pair->object() );
            if (p != 0) {
                // We are its container
                p->container(this);
            }
            else {
                // Not of the proper type
                std::cerr << "Player::setSlotIoHandler: Slot \"" << pair->slot() << "\" is not of type Basic::IoHandler" << std::endl;
                ok = false;
            }
        }
    }
    return ok;
}