1 // Created on: 1994-11-04
2 // Created by: Christian CAILLET
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Transfer_Finder_HeaderFile
18 #define _Transfer_Finder_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22 #include <Standard_Transient.hxx>
24 #include <NCollection_DataMap.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Transient.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <Standard_Type.hxx>
29 #include <Standard_CString.hxx>
30 #include <Interface_ParamType.hxx>
31 #include <Standard_Real.hxx>
32 #include <TCollection_AsciiString.hxx>
36 class Transfer_Finder;
37 DEFINE_STANDARD_HANDLE(Transfer_Finder, Standard_Transient)
39 //! a Finder allows to map any kind of object as a Key for a Map.
40 //! This works by defining, for a Hash Code, that of the real Key,
41 //! not of the Finder which acts only as an intermediate.
42 //! When a Map asks for the HashCode of a Finder, this one returns
43 //! the code it has determined at creation time
44 class Transfer_Finder : public Standard_Transient
50 //! Returns the HashCode which has been stored by SetHashCode
51 //! (remark that HashCode could be deferred then be defined by
52 //! sub-classes, the result is the same)
53 Standard_EXPORT Standard_Integer GetHashCode() const;
55 //! Specific testof equallity : to be defined by each sub-class,
56 //! must be False if Finders have not the same true Type, else
57 //! their contents must be compared
58 Standard_EXPORT virtual Standard_Boolean Equates (const Handle(Transfer_Finder)& other) const = 0;
60 //! Returns the Type of the Value. By default, returns the
61 //! DynamicType of <me>, but can be redefined
62 Standard_EXPORT virtual Handle(Standard_Type) ValueType() const;
64 //! Returns the name of the Type of the Value. Default is name
65 //! of ValueType, unless it is for a non-handled object
66 Standard_EXPORT virtual Standard_CString ValueTypeName() const;
68 //! Adds an attribute with a given name (replaces the former one
69 //! with the same name if already exists)
70 Standard_EXPORT void SetAttribute (const Standard_CString name, const Handle(Standard_Transient)& val);
72 //! Removes an attribute
73 //! Returns True when done, False if this attribute did not exist
74 Standard_EXPORT Standard_Boolean RemoveAttribute (const Standard_CString name);
76 //! Returns an attribute from its name, filtered by a type
77 //! If no attribute has this name, or if it is not kind of this
78 //! type, <val> is Null and returned value is False
80 Standard_EXPORT Standard_Boolean GetAttribute (const Standard_CString name, const Handle(Standard_Type)& type, Handle(Standard_Transient)& val) const;
82 //! Returns an attribute from its name. Null Handle if not recorded
83 //! (whatever Transient, Integer, Real ...)
84 Standard_EXPORT Handle(Standard_Transient) Attribute (const Standard_CString name) const;
86 //! Returns the type of an attribute :
87 //! ParamInt , ParamReal , ParamText (String) , ParamIdent (any)
88 //! or ParamVoid (not recorded)
89 Standard_EXPORT Interface_ParamType AttributeType (const Standard_CString name) const;
91 //! Adds an integer value for an attribute
92 Standard_EXPORT void SetIntegerAttribute (const Standard_CString name, const Standard_Integer val);
94 //! Returns an attribute from its name, as integer
95 //! If no attribute has this name, or not an integer,
96 //! <val> is 0 and returned value is False
98 Standard_EXPORT Standard_Boolean GetIntegerAttribute (const Standard_CString name, Standard_Integer& val) const;
100 //! Returns an integer attribute from its name. 0 if not recorded
101 Standard_EXPORT Standard_Integer IntegerAttribute (const Standard_CString name) const;
103 //! Adds a real value for an attribute
104 Standard_EXPORT void SetRealAttribute (const Standard_CString name, const Standard_Real val);
106 //! Returns an attribute from its name, as real
107 //! If no attribute has this name, or not a real
108 //! <val> is 0.0 and returned value is False
110 Standard_EXPORT Standard_Boolean GetRealAttribute (const Standard_CString name, Standard_Real& val) const;
112 //! Returns a real attribute from its name. 0.0 if not recorded
113 Standard_EXPORT Standard_Real RealAttribute (const Standard_CString name) const;
115 //! Adds a String value for an attribute
116 Standard_EXPORT void SetStringAttribute (const Standard_CString name, const Standard_CString val);
118 //! Returns an attribute from its name, as String
119 //! If no attribute has this name, or not a String
120 //! <val> is 0.0 and returned value is False
122 Standard_EXPORT Standard_Boolean GetStringAttribute (const Standard_CString name, Standard_CString& val) const;
124 //! Returns a String attribute from its name. "" if not recorded
125 Standard_EXPORT Standard_CString StringAttribute (const Standard_CString name) const;
127 //! Returns the exhaustive list of attributes
128 Standard_EXPORT NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& AttrList();
130 //! Gets the list of attributes from <other>, as such, i.e.
131 //! not copied : attributes are shared, any attribute edited,
132 //! added, or removed in <other> is also in <me> and vice versa
133 //! The former list of attributes of <me> is dropped
134 Standard_EXPORT void SameAttributes (const Handle(Transfer_Finder)& other);
136 //! Gets the list of attributes from <other>, by copying it
137 //! By default, considers all the attributes from <other>
138 //! If <fromname> is given, considers only the attributes with
139 //! name beginning by <fromname>
141 //! For each attribute, if <copied> is True (D), its value is also
142 //! copied if it is a basic type (Integer,Real,String), else it
143 //! remains shared between <other> and <me>
145 //! These new attributes are added to the existing ones in <me>,
146 //! in case of same name, they replace the existing ones
147 Standard_EXPORT void GetAttributes (const Handle(Transfer_Finder)& other, const Standard_CString fromname = "", const Standard_Boolean copied = Standard_True);
152 DEFINE_STANDARD_RTTIEXT(Transfer_Finder,Standard_Transient)
157 //! Stores the HashCode which corresponds to the Value given to
158 //! create the Mapper
159 Standard_EXPORT void SetHashCode (const Standard_Integer code);
166 Standard_Integer thecode;
167 NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> theattrib;
178 #endif // _Transfer_Finder_HeaderFile