RPL Global User-defined Functions -- 4-27-2009 http://cadswes2.colorado.edu/~philw/2009/GlobalRplFunctions/ "Globalness" determination design change and namespace-related mechanisms. (1) Removal of the RplSet::_isGlobal flag. This is now redundant with the RplApplication::Type value: RplApplication::GLOBAL. However, a similar RplSet flag was added to indicate that an opened RplSet had previously been saved as a global set: bool _wasGlobalOnLastSave. (2) It is now important that the RplApplication::Type of RplObjs be set at the time of the recomputation of the namespaces. Specifically, this is true for RplObjs in a Global Function Set, since the namespaces of Global Function Sets are included in all namespaces, and the determination of a RplSet being a global set is now based on the RplSet's RplApplication ::Type. (3) A static collection of instantiated RplSets is now maintained by the RplSet class. This is used to easily iterate over all RplSets to recompute their namespaces when a Global Function Set is created or destroyed. See RplSet: static cwSlist _allRplSets. (4) The RplSet 'testValidity' functions now also process the Global Function Groups in other (global) RplSets. -------------- Rpl/RplObj.cpp Rpl/RplObj.hpp -------------- Added a constructor having a RplApplication::Type parameter: RplObj (RplApplication::Type, const RWCString& name, bool active); Added optional boolean parameter: void setApplicationType (RplApplication::Type appType, bool tempDynamic_NoNotify=false); Note: The mechanism for which this (above) is intended has not yet been implemented. In FuncCallExpr, before calling into a Global Function, the RplApplication::Type of that function needs to be temporarily set to the application type of the caller. New virtual method application type change subclass notification, now generated within RplObj::SetApplicationType. virtual void applicationTypeWasSet() {} New protected method: void propagateApplicationType(); This is the implementation of setApplicationType without the application type change check, and without generating the new subclass notification, virtual void applicationTypeWasSet() {}. -------------- Rpl/RplSet.cpp Rpl/RplSet.hpp -------------- Added a RplApplication::Type parameter to the constructor which had just the RplSet name parameter: RplSet (RplApplication::Type, const RWCString& name = DEFAULT_NAME); Removal of the _isGlobal flag and introduction of the _wasGlobalOnLastSave flag. (a) Removed method: void setRplSetIsGlobal (bool isGlobal); (b) Added methods: bool wasGlobalOnLastSave() const { return (_wasGlobalOnLastSave); } void setWasGlobalOnLastSave (bool wasGlobal); New static mechanism to maintain a collection of all instantiated RplSets. The list is maintained via the RplSet constructors and destructor. static cwSlist _allRplSets; ... this is used by methods to recompute the RplSets' namespaces: public: static void computeAllNamespaces(); private: static void populateNameSpaces (const cwSlist&); ... generally (currently always) called with _allRplSets. The RplSet implementation of virtual method, RplObj::applicationTypeWasSet() ---------------- Rpl/RplGroup.cpp Rpl/RplGroup.hpp ---------------- Added RplApplication::Type parameter to this constructor: RplGroup (RplApplication::Type, const RWCString& name = DEFAULT_RPL_GROUP_NAME, bool active = true); ------------------------ Rpl/RplSetMgr.cpp Rpl/RplSetMgr.hpp Rpl/GlobalRplSetMgr.cpp Rpl/GlobalRplSetMgr.hpp ------------------------ Removed this notification virtual method. Globalness of open RplSets is no longer dynamic. private: // Overridden in GlobalRplSetMgr subclass. // Base class implementation clears the _isGlobal flag. virtual void setAdded_updateGlobalFlag (RplSet*); RplResult::Status RplSet::testFuncsValidity (RplExpression::ValidityLevel) RplResult::Status RplSet::testValidity (RplExpression::ValidityLevel) Add processing of the Global Function Groups. ------------------ Rpl/Rpl.y Rpl/Rpl.tab.cpp -- generated Rpl/lex.rpl_.cpp -- generated ------------------ Change of handling of the 'IS_GLOBAL TRUE' field. This used to call RplSet::setRplSetIsGlobal (bool), which has been removed. It instead calls RplSet::setWasGlobalOnLastSave (bool). ------------------- QtRpl/RplDlgMgr.cpp QtRpl/RplDlgMgr.hpp ------------------- REMOVAL of the temporary compilation flag: #define SHOW_DYNAMIC_GLOBAL_TOGGLE false Add RplApplication::Type parameter to uses of the RplSet constructors: RplDlgMgr::newRuleset() ... RplSet *rplSet = new RplSet (RplApplication::RBS); RplDlgMgr::newOptset() ... RplSet *rplSet = new RplSet (RplApplication::OPT); RplDlgMgr::newGlobalFunctionSet() ... RplSet *rplSet = new RplSet (RplApplication::GLOBAL); The prior code had turned off 'Global' before closing RplSet editor dialogs. (This was to simplify the RplSet instance deletion sequence). This was removed. (RplSet globalness is no longer dynamic). -------------------- QtRpl/RplBaseDlg.cpp QtRpl/RplBaseDlg.hpp -------------------- Removal of "is global" toggle handler: void isGlobalToggleHandler (bool); In: RplBaseDlg::loadButtonHandler(), when clicking ON (Do Load), first call RplSet::computeAllNamespaces() before loading the RplSet. This updates the including of open Global Function Sets within the dialog's RplSet. ------------------------- QtRpl/RplSetDlg.cpp QtRpl/RplSetDlgWidgets.ui ------------------------- Removal of QAction* _isGlobalToggleAction; The toggle text had been: "[X] Functions Globally Accessible". ------------------------- Sim/NewOptControl.cpp Sim/RplExprSlotMgr.cpp Sim/mrmControl.cpp Accounting/AccountMgr.cpp ------------------------- Add RplApplication::Type parameter to uses of the RplSet constructors: NewOptControl::generatePostRunRuleSet() ... RplSet* set = new RplSet (RplApplication::OPT, "Post-optimization ruleset"); RplExprSlotMgr::RplExprSlotMgr() ... _rplSet = new RplSet (RplApplication::SLOT_EXPR, RPL_EXPR_SLOT_RPL_SET_NAME); MRMControl::MRMControl (char* name) ... _iterRplSet = new RplSet (RplApplication::MRM, "MRM Rules"); AccountMgr::initObjectLevelMethods() _objectLevelMethods = new RplSet (RplApplication::UDAM); --------------------- Q3GUI/LoadSaveMgr.cpp --------------------- Changed "suggested" file extension for Global Function Set files, as indicated by the first file filter for opening Global Function Sets: static const char* FILTER_STR_GBLSET_FILES ("Global Function Set Files (*.gbl *.gbl.gz);;" "RuleSet Files (*.rls *.rls.gz);;" "Optimization Policy Set Files (*.opt *.opt.gz);;" "gzip Files (*.gz);;" "All (*)"); ---