// $Id: RepGenSimObj.cpp,v 1.16 2010/05/14 19:37:47 lynn Exp $ // // class RepGenSimObj // // concrete subclasses: // class RepGenSimObjHtml : public RepGenSimObj // class RepGenSimObjText : public RepGenSimObj // //-- #ifndef RepGenSimObjINCLUDED #include "RepGenSimObj.hpp" #endif #ifndef RwModelReportINCLUDED #include "RwModelReport.hpp" #endif #ifndef RepGenSlotHtmlINCLUDED #include "RepGenSlotHtml.hpp" #endif #ifndef RepGenSlotTextINCLUDED #include "RepGenSlotText.hpp" #endif // #ifndef RepGenUtilsINCLUDED // #include "RepGenUtils.hpp" // #endif #ifndef RunTypeINCLUDED #include "RunType.hpp" #endif #ifndef SimObjINCLUDED #include "SimObj.hpp" #endif #ifndef AggregateObjINCLUDED #include "AggregateObj.hpp" #endif // #ifndef SlotINCLUDED // #include "Slot.hpp" // #endif // #ifndef SlotGUIUtilsINCLUDED // #include "SlotGUIUtils.hpp" // #endif #ifndef cwfstreamINCLUDED #include "cwfstream.hpp" #endif #include "rwStr.hpp" //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- RepGenSimObj::RepGenSimObj (RwModelReport* rep, SimObj* obj) : _modelReport (rep), _simObj (obj) { } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- RepGenSimObj::~RepGenSimObj() { } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void RepGenSimObj::writeObj (cwofstream& os) { static const char (*mname) ("RepGenSimObj::writeObj"); // std::cout << mname << std::endl; if (_simObj == NULL) return; //------------------------>> writeObjSummary (os); writeMethodTable (os); writeSlotLists (os); writeSlotDetails (os); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void RepGenSimObj::writeSlotDetails (cwofstream& os) { if (_simObj == NULL) return; //------------------------>> const RunType ctlType (RT_SIMULATION); cwDlist slotList; _simObj->getSlotsInUse (slotList, ctlType); // ********************** // *** Slot Details *** // ********************** const bool isText = _modelReport && _modelReport->isTextReport(); cwIterator slotIter; for (slotIter = slotList.first(); slotIter; slotIter = slotList.next (slotIter)) { const Slot* slotPtr = slotList.elem (slotIter); if (slotPtr == NULL) continue; //---------------------------- if (isText) { RepGenSlotText repSlotText (_modelReport, slotPtr); if (repSlotText.slotDetailSupported()) { repSlotText.writeSlotDetail (os); } } else { RepGenSlotHtml repSlotHtml (_modelReport, slotPtr); if (repSlotHtml.slotDetailSupported()) { repSlotHtml.writeSlotDetail (os); } } } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Build composite SimObj list (a SimObj and its AggElement SimObjs). // static void RepGenSimObj::buildCompSimObjList (const SimObj* obj, cwSlist& compSimObjList) { compSimObjList.append (obj); if (obj->isAggObj()) { const AggregateObj *aggObj = dynamic_cast(obj); if (aggObj) { cwIterator aggIter; SimObj* aggElement (NULL); for (aggElement = aggObj->firstObjInAggregate(aggIter); aggElement; aggElement = aggObj->nextObjInAggregate(aggIter)) { compSimObjList.append (aggElement); } } } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Builds parallel QStringLists of the given Object's Categories and Methods // static void RepGenSimObj::getCatsMeths (const SimObj* obj, QStringList& catsList, QStringList& methsList, bool includeDefaultMethodSettings) { if (obj == NULL) return; //-------------------->> // Get the user method categories. CategoryNameList catNameList; obj->getUserCategories (catNameList); cwIterator catIter; for (catIter = catNameList.first(); catIter; catIter = catNameList.next (catIter)) { const QString catName = catNameList.elem (catIter); if (catName.isEmpty()) continue; //----------------------------- QString selMethName (""); const bool getSelMethFail = obj->getSelectedMethod (catName, selMethName); if (!includeDefaultMethodSettings) { QString defaultMethName (""); const bool getDefaultMethFail = obj->getDefaultMethod (catName, defaultMethName); getDefaultMethFail; // (compilation warning fix) // Skip method categories with the default method selected. if (selMethName == defaultMethName) continue; //------------------------------------------- } QString catNameStr (catName); QString methNameStr (selMethName); if (getSelMethFail) { methNameStr += " ERROR"; } catsList << catNameStr; methsList << methNameStr; } } //--- (end RepGenSimObj.cpp) ---