const TrackManager* OnboardComputer::getTrackManagerByType(const std::type_info& type) const { const TrackManager* p = 0; const Basic::Pair* pair = findByType(type); if (pair != 0) { p = dynamic_cast<const TrackManager*>( pair->object() ); } return p; }
//------------------------------------------------------------------------------ // getTrackManagerByType() -- return the first track manager of type //------------------------------------------------------------------------------ TrackManager* OnboardComputer::getTrackManagerByType(const std::type_info& type) { TrackManager* p = nullptr; base::Pair* pair = findByType(type); if (pair != nullptr) { p = dynamic_cast<TrackManager*>( pair->object() ); } return p; }
SOTemplate const* InnerObjectFormats::findSOTemplateBySField (SField const& sField) const { SOTemplate const* ret = nullptr; auto itemPtr = findByType (sField.getCode ()); if (itemPtr) ret = &(itemPtr->elements); return ret; }
IBase * EntityMgr::queryInterface(const char * entityType, iid_t iid, bool softQuery) { int numItems = findByType(entityType); IBase * pInt = NULL; if (numItems > 0) { pInt = queryInterface(entityResult.front(), iid, true); } if (NULL==pInt && !softQuery) { if (numItems==0) throw Exception("core: Entity {type='%s'} not exists", entityType); const char * iname = getCore()->getIdName(iid); throw Exception("core: Entity {type='%s'} doesn't support Iterface{iid=0x%08X, name='%s'}", entityType, iid, iname); } return pInt; }
//------------------------------------------------------------------------------ // findByType() -- find one of our components by type (our children first // then grandchildren). //------------------------------------------------------------------------------ const Pair* Component::findByType(const std::type_info& type) const { const Pair* q {}; const PairStream* subcomponents = getComponents(); if (subcomponents != nullptr) { q = subcomponents->findByType(type); const List::Item* item = subcomponents->getFirstItem(); while (item != nullptr && q == nullptr) { const auto p = static_cast<const Pair*>(item->getValue()); const auto obj = static_cast<const Component*>(p->object()); q = obj->findByType(type); item = item->getNext(); } subcomponents->unref(); subcomponents = nullptr; } return q; }
//----------------------------------------------------------------------------- // drawIt() -- default function to draw the display //----------------------------------------------------------------------------- void FoxDisplay::drawIt() { if (glCanvas != nullptr) { if (!glCanvas->isCurrent()) { glCanvas->makeCurrent(); } // if we are rotating, get our graphic and rotate it Basic::Pair* p = (Basic::Pair*)findByType(typeid(BasicGL::Polygon)); if (p != nullptr) { BasicGL::Polygon* g = dynamic_cast<BasicGL::Polygon*>(p->object()); if (g != nullptr) { g->lcSaveMatrix(); g->lcTranslate(trans, 0); g->lcRotate(rotAng); BaseClass::drawIt(); g->lcRestoreMatrix(); } } } }