Phil [10-2-2013]: Proposal for factoring out a non-cached part of SimObj::getSlotsInUse(). (The latter calls the former, see below). (1) virtual void getSlotsInUseNoCache( cwDlist &slotsInuse, RunType ctlType = RT_UNKNOWN) const; (2) int getSlotsInUse( cwDlist &slotsInuse, RunType ctlType = RT_UNKNOWN) const; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void SimObj::getSlotsInUseNoCache (cwDlist& slotsInUse, RunType ctlType) const { slotsInUse.clear(); // If the default arg is given, use the current controller if (ctlType == RT_UNKNOWN) { ctlType = ws->getRunInfo()->getType(); } // Only use the opt list for the opt controller const int listIndex = (ctlType == RT_OPT) ? OPT_IN_USE : SIM_RBS_IN_USE; const cwSlist& slotList = _slotLists [listIndex]; cwIterator it; FORALL(it, slotList) { SlotProxy* proxy = slotList.elem(it); if (proxy->isInstantiated()) { slotsInUse.append(proxy->getSlotPtr()); } } const Controller* ctl = ws->getRunInfo()->getController(ctlType); (void) getUserMethodSlots (slotsInUse, ctl); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- int SimObj::getSlotsInUse (cwDlist& slotsInUse, RunType ctlType) const { slotsInUse.clear(); // If a run is initiating or we are within a run then the slots in // use shouldn't change until the run is over, so if we have a valid // slots in use cache, use it. // const RunInfo* runInfo = getSimWorkspace()->getRunInfo(); const bool isInitOrRun = runInfo->isInitializingOrWithinRun(); if (isInitOrRun) { const bool cacheInvalid = getSlotsInUseCache(slotsInUse); if (!cacheInvalid) { return slotsInUse.size(); //--------------------->> } } getSlotsInUseNoCache (slotsInUse, ctlType); // If we are in a run, then cache a copy of the list of slots in use // so we don't have to do all this work the next time we're // called during this run. // if (isInitOrRun) { setSlotsInUseCache (slotsInUse); } return slotsInUse.size(); } //----------------------------------------------------------------------------- //-----------------------------------------------------------------------------