|
|
|||
File indexing completed on 2026-11-13 10:44:32
0001 // Copyright (c) 2022 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _DE_ConfigurationContext_HeaderFile 0015 #define _DE_ConfigurationContext_HeaderFile 0016 0017 #include <NCollection_DataMap.hxx> 0018 #include <TCollection_AsciiString.hxx> 0019 #include <NCollection_List.hxx> 0020 0021 //! Provides convenient interface to resource file 0022 //! Allows loading of the resource file and getting attributes' 0023 //! values starting from some scope, for example 0024 //! if scope is defined as "ToV4" and requested parameter 0025 //! is "exec.op", value of "ToV4.exec.op" parameter from 0026 //! the resource file will be returned 0027 class DE_ConfigurationContext : public Standard_Transient 0028 { 0029 public: 0030 DEFINE_STANDARD_RTTIEXT(DE_ConfigurationContext, Standard_Transient) 0031 0032 //! Creates an empty tool 0033 Standard_EXPORT DE_ConfigurationContext(); 0034 0035 //! Import the custom configuration 0036 //! Save all parameters with their values. 0037 //! @param[in] theConfiguration path to configuration file or string value 0038 //! @return true in case of success, false otherwise 0039 Standard_EXPORT bool Load(const TCollection_AsciiString& theConfiguration); 0040 0041 //! Import the resource file. 0042 //! Save all parameters with their values. 0043 //! @param[in] theFile path to the resource file 0044 //! @return true in case of success, false otherwise 0045 Standard_EXPORT bool LoadFile(const TCollection_AsciiString& theFile); 0046 0047 //! Import the resource string. 0048 //! Save all parameters with their values. 0049 //! @param[in] theResource string with resource content 0050 //! @return true in case of success, false otherwise 0051 Standard_EXPORT bool LoadStr(const TCollection_AsciiString& theResource); 0052 0053 //! Checks for existing the parameter name 0054 //! @param[in] theParam complex parameter name 0055 //! @param[in] theScope base parameter name 0056 //! @return true if parameter is defined in the resource file 0057 Standard_EXPORT bool IsParamSet(const TCollection_AsciiString& theParam, 0058 const TCollection_AsciiString& theScope = "") const; 0059 0060 //! Gets value of parameter as being of specific type 0061 //! @param[in] theParam complex parameter name 0062 //! @param[out] theValue value to get by parameter 0063 //! @param[in] theScope base parameter name 0064 //! @return false if parameter is not defined or has a wrong type 0065 Standard_EXPORT bool GetReal(const TCollection_AsciiString& theParam, 0066 double& theValue, 0067 const TCollection_AsciiString& theScope = "") const; 0068 0069 //! Gets value of parameter as being of specific type 0070 //! @param[in] theParam complex parameter name 0071 //! @param[out] theValue value to get by parameter 0072 //! @param[in] theScope base parameter name 0073 //! @return false if parameter is not defined or has a wrong type 0074 Standard_EXPORT bool GetInteger(const TCollection_AsciiString& theParam, 0075 int& theValue, 0076 const TCollection_AsciiString& theScope = "") const; 0077 0078 //! Gets value of parameter as being of specific type 0079 //! @param[in] theParam complex parameter name 0080 //! @param[out] theValue value to get by parameter 0081 //! @param[in] theScope base parameter name 0082 //! @return false if parameter is not defined or has a wrong type 0083 Standard_EXPORT bool GetBoolean(const TCollection_AsciiString& theParam, 0084 bool& theValue, 0085 const TCollection_AsciiString& theScope = "") const; 0086 0087 //! Gets value of parameter as being of specific type 0088 //! @param[in] theParam complex parameter name 0089 //! @param[out] theValue value to get by parameter 0090 //! @param[in] theScope base parameter name 0091 //! @return false if parameter is not defined or has a wrong type 0092 Standard_EXPORT bool GetString(const TCollection_AsciiString& theParam, 0093 TCollection_AsciiString& theValue, 0094 const TCollection_AsciiString& theScope = "") const; 0095 0096 //! Gets value of parameter as being of specific type 0097 //! @param[in] theParam complex parameter name 0098 //! @param[out] theValue value to get by parameter 0099 //! @param[in] theScope base parameter name 0100 //! @return false if parameter is not defined or has a wrong type 0101 Standard_EXPORT bool GetStringSeq(const TCollection_AsciiString& theParam, 0102 NCollection_List<TCollection_AsciiString>& theValue, 0103 const TCollection_AsciiString& theScope = "") const; 0104 0105 //! Gets value of parameter as being of specific type 0106 //! @param[in] theParam complex parameter name 0107 //! @param[in] theDefValue value by default if param is not found or has wrong type 0108 //! @param[in] theScope base parameter name 0109 //! @return specific type value 0110 Standard_EXPORT double RealVal(const TCollection_AsciiString& theParam, 0111 const double theDefValue, 0112 const TCollection_AsciiString& theScope = "") const; 0113 0114 //! Gets value of parameter as being of specific type 0115 //! @param[in] theParam complex parameter name 0116 //! @param[in] theDefValue value by default if param is not found or has wrong type 0117 //! @param[in] theScope base parameter name 0118 //! @return specific type value 0119 Standard_EXPORT int IntegerVal(const TCollection_AsciiString& theParam, 0120 const int theDefValue, 0121 const TCollection_AsciiString& theScope = "") const; 0122 0123 //! Gets value of parameter as being of specific type 0124 //! @param[in] theParam complex parameter name 0125 //! @param[in] theDefValue value by default if param is not found or has wrong type 0126 //! @param[in] theScope base parameter name 0127 //! @return specific type value 0128 Standard_EXPORT bool BooleanVal(const TCollection_AsciiString& theParam, 0129 const bool theDefValue, 0130 const TCollection_AsciiString& theScope = "") const; 0131 0132 //! Gets value of parameter as being of specific type 0133 //! @param[in] theParam complex parameter name 0134 //! @param[in] theDefValue value by default if param is not found or has wrong type 0135 //! @param[in] theScope base parameter name 0136 //! @return specific type value 0137 Standard_EXPORT TCollection_AsciiString 0138 StringVal(const TCollection_AsciiString& theParam, 0139 const TCollection_AsciiString& theDefValue, 0140 const TCollection_AsciiString& theScope = "") const; 0141 0142 //! Gets internal resource map 0143 //! @return map with resource value 0144 Standard_EXPORT const NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& 0145 GetInternalMap() const 0146 { 0147 return myResource; 0148 } 0149 0150 protected: 0151 //! Update the resource with param value from the line 0152 //! @paramp[in] theResourceLine line contains the parameter 0153 //! @return true if theResourceLine has loaded correctly 0154 bool load(const TCollection_AsciiString& theResourceLine); 0155 0156 private: 0157 NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> 0158 myResource; //!< Internal parameters map 0159 }; 0160 0161 #endif // _DE_ConfigurationContext_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|