|
||||
File indexing completed on 2025-01-18 10:04:08
0001 // Created on: 1995-12-08 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1995-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _Interface_Static_HeaderFile 0018 #define _Interface_Static_HeaderFile 0019 0020 #include <Standard.hxx> 0021 0022 #include <Standard_Integer.hxx> 0023 #include <Standard_Real.hxx> 0024 #include <Interface_StaticSatisfies.hxx> 0025 #include <Interface_TypedValue.hxx> 0026 #include <TColStd_HSequenceOfHAsciiString.hxx> 0027 class TCollection_HAsciiString; 0028 0029 class Interface_Static; 0030 DEFINE_STANDARD_HANDLE(Interface_Static, Interface_TypedValue) 0031 0032 //! This class gives a way to manage meaningful static variables, 0033 //! used as "global" parameters in various procedures. 0034 //! 0035 //! A Static brings a specification (its type, constraints if any) 0036 //! and a value. Its basic form is a string, it can be specified 0037 //! as integer or real or enumerative string, and queried as such. 0038 //! Its string content, which is a Handle(HAsciiString) can be 0039 //! shared by other data structures, hence gives a direct on line 0040 //! access to its value. 0041 //! 0042 //! All this description is inherited from TypedValue 0043 //! 0044 //! A Static can be given an initial value, it can be filled from, 0045 //! either a set of Resources (an applicative feature which 0046 //! accesses and manages parameter files), or environment or 0047 //! internal definition : these define families of Static. 0048 //! In addition, it supports a status for reinitialisation : an 0049 //! initialisation procedure can ask if the value of the Static 0050 //! has changed from its last call, in this case does something 0051 //! then marks the Status "uptodate", else it does nothing. 0052 //! 0053 //! Statics are named and recorded then accessed in an alphabetic 0054 //! dictionary 0055 class Interface_Static : public Interface_TypedValue 0056 { 0057 0058 public: 0059 0060 0061 //! Creates and records a Static, with a family and a name 0062 //! family can report to a name of resource or to a system or 0063 //! internal definition. The name must be unique. 0064 //! 0065 //! type gives the type of the parameter, default is free text 0066 //! Also available : Integer, Real, Enum, Entity (i.e. Object) 0067 //! More precise specifications, titles, can be given to the 0068 //! Static once created 0069 //! 0070 //! init gives an initial value. If it is not given, the Static 0071 //! begin as "not set", its value is empty 0072 Standard_EXPORT Interface_Static(const Standard_CString family, const Standard_CString name, const Interface_ParamType type = Interface_ParamText, const Standard_CString init = ""); 0073 0074 //! Creates a new Static with same definition as another one 0075 //! (value is copied, except for Entity : it remains null) 0076 Standard_EXPORT Interface_Static(const Standard_CString family, const Standard_CString name, const Handle(Interface_Static)& other); 0077 0078 //! Writes the properties of a 0079 //! parameter in the diagnostic file. These include: 0080 //! - Name 0081 //! - Family, 0082 //! - Wildcard (if it has one) 0083 //! - Current status (empty string if it was updated or 0084 //! if it is the original one) 0085 //! - Value 0086 Standard_EXPORT void PrintStatic (Standard_OStream& S) const; 0087 0088 //! Returns the family. It can be : a resource name for applis, 0089 //! an internal name between : $e (environment variables), 0090 //! $l (other, purely local) 0091 Standard_EXPORT Standard_CString Family() const; 0092 0093 //! Sets a "wild-card" static : its value will be considered 0094 //! if <me> is not properly set. (reset by set a null one) 0095 Standard_EXPORT void SetWild (const Handle(Interface_Static)& wildcard); 0096 0097 //! Returns the wildcard static, which can be (is most often) null 0098 Standard_EXPORT Handle(Interface_Static) Wild() const; 0099 0100 //! Records a Static has "uptodate", i.e. its value has been taken 0101 //! into account by a reinitialisation procedure 0102 //! This flag is reset at each successful SetValue 0103 Standard_EXPORT void SetUptodate(); 0104 0105 //! Returns the status "uptodate" 0106 Standard_EXPORT Standard_Boolean UpdatedStatus() const; 0107 0108 //! Declares a new Static (by calling its constructor) 0109 //! If this name is already taken, does nothing and returns False 0110 //! Else, creates it and returns True 0111 //! For additional definitions, get the Static then edit it 0112 Standard_EXPORT static Standard_Boolean Init (const Standard_CString family, const Standard_CString name, const Interface_ParamType type, const Standard_CString init = ""); 0113 0114 //! As Init with ParamType, but type is given as a character 0115 //! This allows a simpler call 0116 //! Types : 'i' Integer, 'r' Real, 't' Text, 'e' Enum, 'o' Object 0117 //! '=' for same definition as, <init> gives the initial Static 0118 //! Returns False if <type> does not match this list 0119 Standard_EXPORT static Standard_Boolean Init (const Standard_CString family, const Standard_CString name, const Standard_Character type, const Standard_CString init = ""); 0120 0121 //! Returns a Static from its name. Null Handle if not present 0122 Standard_EXPORT static Handle(Interface_Static) Static (const Standard_CString name); 0123 0124 //! Returns True if a Static named <name> is present, False else 0125 Standard_EXPORT static Standard_Boolean IsPresent (const Standard_CString name); 0126 0127 //! Returns a part of the definition of a Static, as a CString 0128 //! The part is designated by its name, as a CString 0129 //! If the required value is not a string, it is converted to a 0130 //! CString then returned 0131 //! If <name> is not present, or <part> not defined for <name>, 0132 //! this function returns an empty string 0133 //! 0134 //! Allowed parts for CDef : 0135 //! family : the family 0136 //! type : the type ("integer","real","text","enum") 0137 //! label : the label 0138 //! satis : satisfy function name if any 0139 //! rmin : minimum real value 0140 //! rmax : maximum real value 0141 //! imin : minimum integer value 0142 //! imax : maximum integer value 0143 //! enum nn (nn : value of an integer) : enum value for nn 0144 //! unit : unit definition for a real 0145 Standard_EXPORT static Standard_CString CDef (const Standard_CString name, const Standard_CString part); 0146 0147 //! Returns a part of the definition of a Static, as an Integer 0148 //! The part is designated by its name, as a CString 0149 //! If the required value is not a string, returns zero 0150 //! For a Boolean, 0 for false, 1 for true 0151 //! If <name> is not present, or <part> not defined for <name>, 0152 //! this function returns zero 0153 //! 0154 //! Allowed parts for IDef : 0155 //! imin, imax : minimum or maximum integer value 0156 //! estart : starting number for enum 0157 //! ecount : count of enum values (starting from estart) 0158 //! ematch : exact match status 0159 //! eval val : case determined from a string 0160 Standard_EXPORT static Standard_Integer IDef (const Standard_CString name, const Standard_CString part); 0161 0162 //! Returns True if <name> is present AND set 0163 //! <proper> True (D) : considers this item only 0164 //! <proper> False : if not set and attached to a wild-card, 0165 //! considers this wild-card 0166 Standard_EXPORT static Standard_Boolean IsSet (const Standard_CString name, const Standard_Boolean proper = Standard_True); 0167 0168 //! Returns the value of the 0169 //! parameter identified by the string name. 0170 //! If the specified parameter does not exist, an empty 0171 //! string is returned. 0172 //! Example 0173 //! Interface_Static::CVal("write.step.schema"); 0174 //! which could return: 0175 //! "AP214" 0176 Standard_EXPORT static Standard_CString CVal (const Standard_CString name); 0177 0178 //! Returns the integer value of 0179 //! the translation parameter identified by the string name. 0180 //! Returns the value 0 if the parameter does not exist. 0181 //! Example 0182 //! Interface_Static::IVal("write.step.schema"); 0183 //! which could return: 3 0184 Standard_EXPORT static Standard_Integer IVal (const Standard_CString name); 0185 0186 //! Returns the value of a static 0187 //! translation parameter identified by the string name. 0188 //! Returns the value 0.0 if the parameter does not exist. 0189 Standard_EXPORT static Standard_Real RVal (const Standard_CString name); 0190 0191 //! Modifies the value of the 0192 //! parameter identified by name. The modification is specified 0193 //! by the string val. false is returned if the parameter does not exist. 0194 //! Example 0195 //! Interface_Static::SetCVal 0196 //! ("write.step.schema","AP203") 0197 //! This syntax specifies a switch from the default STEP 214 mode to STEP 203 mode. 0198 Standard_EXPORT static Standard_Boolean SetCVal (const Standard_CString name, const Standard_CString val); 0199 0200 //! Modifies the value of the 0201 //! parameter identified by name. The modification is specified 0202 //! by the integer value val. false is returned if the 0203 //! parameter does not exist. 0204 //! Example 0205 //! Interface_Static::SetIVal 0206 //! ("write.step.schema", 3) 0207 //! This syntax specifies a switch from the default STEP 214 mode to STEP 203 mode.S 0208 Standard_EXPORT static Standard_Boolean SetIVal (const Standard_CString name, const Standard_Integer val); 0209 0210 //! Modifies the value of a 0211 //! translation parameter. false is returned if the 0212 //! parameter does not exist. The modification is specified 0213 //! by the real number value val. 0214 Standard_EXPORT static Standard_Boolean SetRVal (const Standard_CString name, const Standard_Real val); 0215 0216 //! Sets a Static to be "uptodate" 0217 //! Returns False if <name> is not present 0218 //! This status can be used by a reinitialisation procedure to 0219 //! rerun if a value has been changed 0220 Standard_EXPORT static Standard_Boolean Update (const Standard_CString name); 0221 0222 //! Returns the status "uptodate" from a Static 0223 //! Returns False if <name> is not present 0224 Standard_EXPORT static Standard_Boolean IsUpdated (const Standard_CString name); 0225 0226 //! Returns a list of names of statics : 0227 //! <mode> = 0 (D) : criter is for family 0228 //! <mode> = 1 : criter is regexp on names, takes final items 0229 //! (ignore wild cards) 0230 //! <mode> = 2 : idem but take only wilded, not final items 0231 //! <mode> = 3 : idem, take all items matching criter 0232 //! idem + 100 : takes only non-updated items 0233 //! idem + 200 : takes only updated items 0234 //! criter empty (D) : returns all names 0235 //! else returns names which match the given criter 0236 //! Remark : families beginning by '$' are not listed by criter "" 0237 //! they are listed only by criter "$" 0238 //! 0239 //! This allows for instance to set new values after having loaded 0240 //! or reloaded a resource, then to update them as required 0241 Standard_EXPORT static Handle(TColStd_HSequenceOfHAsciiString) Items (const Standard_Integer mode = 0, const Standard_CString criter = ""); 0242 0243 //! Initializes all standard static parameters, which can be used 0244 //! by every function. statics specific of a norm or a function 0245 //! must be defined around it 0246 Standard_EXPORT static void Standards(); 0247 0248 //! Fills given string-to-string map with all static data 0249 Standard_EXPORT static void FillMap(NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& theMap); 0250 0251 DEFINE_STANDARD_RTTIEXT(Interface_Static,Interface_TypedValue) 0252 0253 protected: 0254 0255 0256 0257 0258 private: 0259 0260 0261 TCollection_AsciiString thefamily; 0262 TCollection_AsciiString thename; 0263 TCollection_AsciiString thelabel; 0264 Interface_ParamType thetype; 0265 Handle(Standard_Type) theotyp; 0266 Handle(Interface_Static) thewild; 0267 Standard_Integer thelims; 0268 Standard_Integer theintlow; 0269 Standard_Integer theintup; 0270 Standard_Real therealow; 0271 Standard_Real therealup; 0272 TCollection_AsciiString theunidef; 0273 Handle(TColStd_HArray1OfAsciiString) theenums; 0274 NCollection_DataMap<TCollection_AsciiString, Standard_Integer> theeadds; 0275 Interface_StaticSatisfies thesatisf; 0276 TCollection_AsciiString thesatisn; 0277 Standard_Boolean theupdate; 0278 Standard_Integer theival; 0279 Handle(TCollection_HAsciiString) thehval; 0280 Handle(Standard_Transient) theoval; 0281 0282 0283 }; 0284 0285 0286 0287 0288 0289 0290 0291 #endif // _Interface_Static_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |