|
||||
File indexing completed on 2025-01-18 10:05:29
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 0030 0031 class Transfer_Finder; 0032 DEFINE_STANDARD_HANDLE(Transfer_Finder, Standard_Transient) 0033 0034 //! a Finder allows to map any kind of object as a Key for a Map. 0035 //! This works by defining, for a Hash Code, that of the real Key, 0036 //! not of the Finder which acts only as an intermediate. 0037 //! When a Map asks for the HashCode of a Finder, this one returns 0038 //! the code it has determined at creation time 0039 class Transfer_Finder : public Standard_Transient 0040 { 0041 0042 public: 0043 0044 0045 //! Returns the HashCode which has been stored by SetHashCode 0046 //! (remark that HashCode could be deferred then be defined by 0047 //! sub-classes, the result is the same) 0048 Standard_EXPORT size_t GetHashCode() const; 0049 0050 //! Specific testof equality : to be defined by each sub-class, 0051 //! must be False if Finders have not the same true Type, else 0052 //! their contents must be compared 0053 Standard_EXPORT virtual Standard_Boolean Equates (const Handle(Transfer_Finder)& other) const = 0; 0054 0055 //! Returns the Type of the Value. By default, returns the 0056 //! DynamicType of <me>, but can be redefined 0057 Standard_EXPORT virtual Handle(Standard_Type) ValueType() const; 0058 0059 //! Returns the name of the Type of the Value. Default is name 0060 //! of ValueType, unless it is for a non-handled object 0061 Standard_EXPORT virtual Standard_CString ValueTypeName() const; 0062 0063 //! Adds an attribute with a given name (replaces the former one 0064 //! with the same name if already exists) 0065 Standard_EXPORT void SetAttribute (const Standard_CString name, const Handle(Standard_Transient)& val); 0066 0067 //! Removes an attribute 0068 //! Returns True when done, False if this attribute did not exist 0069 Standard_EXPORT Standard_Boolean RemoveAttribute (const Standard_CString name); 0070 0071 //! Returns an attribute from its name, filtered by a type 0072 //! If no attribute has this name, or if it is not kind of this 0073 //! type, <val> is Null and returned value is False 0074 //! Else, it is True 0075 Standard_EXPORT Standard_Boolean GetAttribute (const Standard_CString name, const Handle(Standard_Type)& type, Handle(Standard_Transient)& val) const; 0076 0077 //! Returns an attribute from its name. Null Handle if not recorded 0078 //! (whatever Transient, Integer, Real ...) 0079 Standard_EXPORT Handle(Standard_Transient) Attribute (const Standard_CString name) const; 0080 0081 //! Returns the type of an attribute : 0082 //! ParamInt , ParamReal , ParamText (String) , ParamIdent (any) 0083 //! or ParamVoid (not recorded) 0084 Standard_EXPORT Interface_ParamType AttributeType (const Standard_CString name) const; 0085 0086 //! Adds an integer value for an attribute 0087 Standard_EXPORT void SetIntegerAttribute (const Standard_CString name, const Standard_Integer val); 0088 0089 //! Returns an attribute from its name, as integer 0090 //! If no attribute has this name, or not an integer, 0091 //! <val> is 0 and returned value is False 0092 //! Else, it is True 0093 Standard_EXPORT Standard_Boolean GetIntegerAttribute (const Standard_CString name, 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, Standard_Real& val) const; 0106 0107 //! Returns a real attribute from its name. 0.0 if not recorded 0108 Standard_EXPORT Standard_Real RealAttribute (const Standard_CString name) const; 0109 0110 //! Adds a String value for an attribute 0111 Standard_EXPORT void SetStringAttribute (const Standard_CString name, const Standard_CString val); 0112 0113 //! Returns an attribute from its name, as String 0114 //! If no attribute has this name, or not a String 0115 //! <val> is 0.0 and returned value is False 0116 //! Else, it is True 0117 Standard_EXPORT Standard_Boolean GetStringAttribute (const Standard_CString name, Standard_CString& val) const; 0118 0119 //! Returns a String attribute from its name. "" if not recorded 0120 Standard_EXPORT Standard_CString StringAttribute (const Standard_CString name) const; 0121 0122 //! Returns the exhaustive list of attributes 0123 Standard_EXPORT NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& AttrList(); 0124 0125 //! Gets the list of attributes from <other>, as such, i.e. 0126 //! not copied : attributes are shared, any attribute edited, 0127 //! added, or removed in <other> is also in <me> and vice versa 0128 //! The former list of attributes of <me> is dropped 0129 Standard_EXPORT void SameAttributes (const Handle(Transfer_Finder)& other); 0130 0131 //! Gets the list of attributes from <other>, by copying it 0132 //! By default, considers all the attributes from <other> 0133 //! If <fromname> is given, considers only the attributes with 0134 //! name beginning by <fromname> 0135 //! 0136 //! For each attribute, if <copied> is True (D), its value is also 0137 //! copied if it is a basic type (Integer,Real,String), else it 0138 //! remains shared between <other> and <me> 0139 //! 0140 //! These new attributes are added to the existing ones in <me>, 0141 //! in case of same name, they replace the existing ones 0142 Standard_EXPORT void GetAttributes (const Handle(Transfer_Finder)& other, const Standard_CString fromname = "", const Standard_Boolean copied = Standard_True); 0143 0144 0145 0146 0147 DEFINE_STANDARD_RTTIEXT(Transfer_Finder,Standard_Transient) 0148 0149 protected: 0150 0151 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 0157 0158 private: 0159 0160 0161 size_t thecode; 0162 NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> theattrib; 0163 0164 0165 }; 0166 0167 0168 0169 0170 0171 0172 0173 #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 |