|
|
|||
File indexing completed on 2026-06-16 08:29:34
0001 // Created on: 1994-11-04 0002 // Created by: Christian CAILLET 0003 // Copyright (c) 1994-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 _Transfer_Finder_HeaderFile 0018 #define _Transfer_Finder_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_Type.hxx> 0022 #include <Standard_Transient.hxx> 0023 0024 #include <NCollection_DataMap.hxx> 0025 #include <Standard_Integer.hxx> 0026 #include <Interface_ParamType.hxx> 0027 #include <TCollection_AsciiString.hxx> 0028 0029 class Transfer_Finder; 0030 DEFINE_STANDARD_HANDLE(Transfer_Finder, Standard_Transient) 0031 0032 //! a Finder allows to map any kind of object as a Key for a Map. 0033 //! This works by defining, for a Hash Code, that of the real Key, 0034 //! not of the Finder which acts only as an intermediate. 0035 //! When a Map asks for the HashCode of a Finder, this one returns 0036 //! the code it has determined at creation time 0037 class Transfer_Finder : public Standard_Transient 0038 { 0039 0040 public: 0041 //! Returns the HashCode which has been stored by SetHashCode 0042 //! (remark that HashCode could be deferred then be defined by 0043 //! sub-classes, the result is the same) 0044 Standard_EXPORT size_t GetHashCode() const; 0045 0046 //! Specific testof equality : to be defined by each sub-class, 0047 //! must be False if Finders have not the same true Type, else 0048 //! their contents must be compared 0049 Standard_EXPORT virtual Standard_Boolean Equates(const Handle(Transfer_Finder)& other) const = 0; 0050 0051 //! Returns the Type of the Value. By default, returns the 0052 //! DynamicType of <me>, but can be redefined 0053 Standard_EXPORT virtual Handle(Standard_Type) ValueType() const; 0054 0055 //! Returns the name of the Type of the Value. Default is name 0056 //! of ValueType, unless it is for a non-handled object 0057 Standard_EXPORT virtual Standard_CString ValueTypeName() const; 0058 0059 //! Adds an attribute with a given name (replaces the former one 0060 //! with the same name if already exists) 0061 Standard_EXPORT void SetAttribute(const Standard_CString name, 0062 const Handle(Standard_Transient)& val); 0063 0064 //! Removes an attribute 0065 //! Returns True when done, False if this attribute did not exist 0066 Standard_EXPORT Standard_Boolean RemoveAttribute(const Standard_CString name); 0067 0068 //! Returns an attribute from its name, filtered by a type 0069 //! If no attribute has this name, or if it is not kind of this 0070 //! type, <val> is Null and returned value is False 0071 //! Else, it is True 0072 Standard_EXPORT Standard_Boolean GetAttribute(const Standard_CString name, 0073 const Handle(Standard_Type)& type, 0074 Handle(Standard_Transient)& val) const; 0075 0076 //! Returns an attribute from its name. Null Handle if not recorded 0077 //! (whatever Transient, Integer, Real ...) 0078 Standard_EXPORT Handle(Standard_Transient) Attribute(const Standard_CString name) const; 0079 0080 //! Returns the type of an attribute : 0081 //! ParamInt , ParamReal , ParamText (String) , ParamIdent (any) 0082 //! or ParamVoid (not recorded) 0083 Standard_EXPORT Interface_ParamType AttributeType(const Standard_CString name) const; 0084 0085 //! Adds an integer value for an attribute 0086 Standard_EXPORT void SetIntegerAttribute(const Standard_CString name, const Standard_Integer val); 0087 0088 //! Returns an attribute from its name, as integer 0089 //! If no attribute has this name, or not an integer, 0090 //! <val> is 0 and returned value is False 0091 //! Else, it is True 0092 Standard_EXPORT Standard_Boolean GetIntegerAttribute(const Standard_CString name, 0093 Standard_Integer& val) const; 0094 0095 //! Returns an integer attribute from its name. 0 if not recorded 0096 Standard_EXPORT Standard_Integer IntegerAttribute(const Standard_CString name) const; 0097 0098 //! Adds a real value for an attribute 0099 Standard_EXPORT void SetRealAttribute(const Standard_CString name, const Standard_Real val); 0100 0101 //! Returns an attribute from its name, as real 0102 //! If no attribute has this name, or not a real 0103 //! <val> is 0.0 and returned value is False 0104 //! Else, it is True 0105 Standard_EXPORT Standard_Boolean GetRealAttribute(const Standard_CString name, 0106 Standard_Real& val) const; 0107 0108 //! Returns a real attribute from its name. 0.0 if not recorded 0109 Standard_EXPORT Standard_Real RealAttribute(const Standard_CString name) const; 0110 0111 //! Adds a String value for an attribute 0112 Standard_EXPORT void SetStringAttribute(const Standard_CString name, const Standard_CString val); 0113 0114 //! Returns an attribute from its name, as String 0115 //! If no attribute has this name, or not a String 0116 //! <val> is 0.0 and returned value is False 0117 //! Else, it is True 0118 Standard_EXPORT Standard_Boolean GetStringAttribute(const Standard_CString name, 0119 Standard_CString& val) const; 0120 0121 //! Returns a String attribute from its name. "" if not recorded 0122 Standard_EXPORT Standard_CString StringAttribute(const Standard_CString name) const; 0123 0124 //! Returns the exhaustive list of attributes 0125 Standard_EXPORT NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& 0126 AttrList(); 0127 0128 //! Gets the list of attributes from <other>, as such, i.e. 0129 //! not copied : attributes are shared, any attribute edited, 0130 //! added, or removed in <other> is also in <me> and vice versa 0131 //! The former list of attributes of <me> is dropped 0132 Standard_EXPORT void SameAttributes(const Handle(Transfer_Finder)& other); 0133 0134 //! Gets the list of attributes from <other>, by copying it 0135 //! By default, considers all the attributes from <other> 0136 //! If <fromname> is given, considers only the attributes with 0137 //! name beginning by <fromname> 0138 //! 0139 //! For each attribute, if <copied> is True (D), its value is also 0140 //! copied if it is a basic type (Integer,Real,String), else it 0141 //! remains shared between <other> and <me> 0142 //! 0143 //! These new attributes are added to the existing ones in <me>, 0144 //! in case of same name, they replace the existing ones 0145 Standard_EXPORT void GetAttributes(const Handle(Transfer_Finder)& other, 0146 const Standard_CString fromname = "", 0147 const Standard_Boolean copied = Standard_True); 0148 0149 DEFINE_STANDARD_RTTIEXT(Transfer_Finder, Standard_Transient) 0150 0151 protected: 0152 //! Stores the HashCode which corresponds to the Value given to 0153 //! create the Mapper 0154 Standard_EXPORT void SetHashCode(const size_t code); 0155 0156 private: 0157 size_t thecode; 0158 NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> theattrib; 0159 }; 0160 0161 #endif // _Transfer_Finder_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|