Example #1
0
//------------------------------------------------------------------------------
// Search all of the objects in the main list for objects of 'type' and add
// them to the sublist.  Also check all Stores type objects for any 'type' objects.
//------------------------------------------------------------------------------
void StoresMgr::searchAndAdd(Basic::PairStream* const mainList, const std::type_info& type, Basic::PairStream* sublist)
{
   if (mainList != 0 && sublist != 0) {

      const Basic::List::Item* item = mainList->getFirstItem();
      while (item != 0) {

         Basic::Pair* pair = (Basic::Pair*)(item->getValue());
         Basic::Component* p = (Basic::Component*)( pair->object() );

         // Check the type and add to the list
         bool isType = p->isClassType(type);
         if (isType) sublist->put(pair);

         // If this is a Stores object then check its stores for 'type' objects as well
         Stores* sp = dynamic_cast<Stores*>(p);
         if ( sp != 0 ) {
            Basic::PairStream* pstores = sp->getStores();
            searchAndAdd(pstores, type, sublist);
            pstores->unref();
         }

         item = item->getNext();
      }
   }  
}