// $Id: DefaultSupplyNameSpec.hpp,v 1.8 2010/10/12 18:57:28 philw Exp $ // // Data definition of a Default Supply Name Specification. This consists // primarily of a sequence of "Parts" representing names or properties of // the Upstream and Downstream Accounts. // // This class contains: // (1) Data and methods to configure the Default Supply Name Specification // (2) Serialization and "User Settings"-based Persitence. // (3) A method to generate a Default Supply Name for a given Supply: // -- QString computeDefaultNameForSupply (const Supply*) const; // // class DefaultSupplyNameSpec // struct DefaultSupplyNameSpec::Part // //-- #ifndef DefaultSupplyNameSpecINCLUDED #define DefaultSupplyNameSpecINCLUDED #ifndef cwReturnStatusINCLUDED #include "cwReturnStatus.hpp" #endif #include #include class Supply; class DefaultSupplyNameSpec { public: // Supply Name Part Types typedef enum { PartType_UND = 0, PartType_String, // User entered character string PartType_UpObjName, // Upstream Object Name PartType_UpAcctName, // Upstream Account Name PartType_DownObjName, // Downstream Object Name PartType_DownAcctName, // Downstream Account Name PartType_UpWaterType, // Upstream Account Water Type PartType_UpWaterOwner, // Upstream Account Water Owner PartType_DownWaterType, // Downstream Account Water Type PartType_DownWaterOwner, // Downstream Account Water Owner PartType_SplyTypeCode, // Supply Type Code PartType_COUNT // ( Number of Part Types ) } PartType; static QString partTypeUserString (PartType); static QString partTypeTerseString (PartType); static PartType partTypeFromUserString (const QString&); static bool getPartTypeFromTerseString (const QString&, PartType& ret); // Supply Name Parts struct Part { PartType _partType; QString _stringVal; // Used for only PartType_String Part (PartType typ=PartType_UND, const QString& str="") : _partType (typ), _stringVal (str) {} bool operator== (const Part&) const; QString str (const Supply*, bool removeSpaces, bool camelCaseToo) const; }; private: // Persistent Fields QList _partList; // Supply Name Part List QString _supplyTypeStr_InpOut; // Supply Type String: Input/Output QString _supplyTypeStr_DivRet; // Supply Type String: Diversion/Return QString _supplyTypeStr_Tran; // Supply Type String: Transfer bool _removeSpacesEna; // Remove Spaces? bool _remSpacesInPartsOnly; // ... Only in Parts? bool _remSpacesCamelCase; // ... CamelCase Too? bool _omitRepeatObjNames; // Omit Repeated Object Names? // Sample Supply Name Cache (used in editor; not actual part of spec). QString _sampSupplyActualName; static QString _lastSampSupplyActualName; // Non-persistent Fields; Not part of comparison. int _temporaryChangeCnt; public: DefaultSupplyNameSpec(); // Internal Change Tracking -- Diagnostics int temporaryChangeCnt() const { return _temporaryChangeCnt; } void clearTemporaryChangeCnt() { _temporaryChangeCnt = 0; } // Factory Value Support static const DefaultSupplyNameSpec& factoryValueRef(); void setFactoryValue(); bool isFactoryValue() const; // Supply Name Part List const QList& partList() const { return _partList; } void setPartList (const QList&); int partListCount() const { return _partList.count(); } // Other Getters QString supplyTypeStr_InpOut() const { return _supplyTypeStr_InpOut; } QString supplyTypeStr_DivRet() const { return _supplyTypeStr_DivRet; } QString supplyTypeStr_Tran() const { return _supplyTypeStr_Tran; } bool removeSpacesEna() const { return _removeSpacesEna; } bool remSpacesInPartsOnly() const { return _remSpacesInPartsOnly; } bool remSpacesCamelCase() const { return _remSpacesCamelCase; } bool omitRepeatObjNames() const { return _omitRepeatObjNames; } QString sampSupplyActualName() const { return _sampSupplyActualName; } static QString lastSampSupplyActualName() { return _lastSampSupplyActualName; } // Other Setters void setSupplyTypeStr_InpOut (const QString&); void setSupplyTypeStr_DivRet (const QString&); void setSupplyTypeStr_Tran (const QString&); void setRemoveSpacesEna (bool); void setRemSpacesInPartsOnly (bool); void setRemSpacesCamelCase (bool); void setOmitRepeatObjNames (bool); void setSampSupplyActualName (const QString&); // Equality Operators bool equals (const DefaultSupplyNameSpec& rhs, bool ignoreNonSpecFields=false) const; bool operator== (const DefaultSupplyNameSpec& rhs) const; bool operator!= (const DefaultSupplyNameSpec& rhs) const; // Utilities static QString camelCase (const QString&); // Serialization and Persistence QString serialize() const; okstat loadSerial (const QString&); void saveToUserSettings() const; okstat loadFromUserSettings(); // Generate Default Name for a given Supply QString computeDefaultNameForSupply (const Supply*) const; }; #endif // DefaultSupplyNameSpecINCLUDED //--- (end DefaultSupplyNameSpec.hpp) ---