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>
23 #include <Standard_Integer.hxx>
24 #include <MMgt_TShared.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Type.hxx>
27 #include <Standard_CString.hxx>
28 #include <Interface_ParamType.hxx>
29 #include <Standard_Real.hxx>
30 class Dico_DictionaryOfTransient;
31 class Standard_Transient;
34 class Transfer_Finder;
35 DEFINE_STANDARD_HANDLE(Transfer_Finder, MMgt_TShared)
37 //! a Finder allows to map any kind of object as a Key for a Map.
38 //! This works by defining, for a Hash Code, that of the real Key,
39 //! not of the Finder which acts only as an intermediate.
40 //! When a Map asks for the HashCode of a Finder, this one returns
41 //! the code it has determined at creation time
42 class Transfer_Finder : public MMgt_TShared
48 //! Returns the HashCode which has been stored by SetHashCode
49 //! (remark that HashCode could be deferred then be defined by
50 //! sub-classes, the result is the same)
51 Standard_EXPORT Standard_Integer GetHashCode() const;
53 //! Specific testof equallity : to be defined by each sub-class,
54 //! must be False if Finders have not the same true Type, else
55 //! their contents must be compared
56 Standard_EXPORT virtual Standard_Boolean Equates (const Handle(Transfer_Finder)& other) const = 0;
58 //! Returns the Type of the Value. By default, returns the
59 //! DynamicType of <me>, but can be redefined
60 Standard_EXPORT virtual Handle(Standard_Type) ValueType() const;
62 //! Returns the name of the Type of the Value. Default is name
63 //! of ValueType, unless it is for a non-handled object
64 Standard_EXPORT virtual Standard_CString ValueTypeName() const;
66 //! Adds an attribute with a given name (replaces the former one
67 //! with the same name if already exists)
68 Standard_EXPORT void SetAttribute (const Standard_CString name, const Handle(Standard_Transient)& val);
70 //! Removes an attribute
71 //! Returns True when done, False if this attribute did not exist
72 Standard_EXPORT Standard_Boolean RemoveAttribute (const Standard_CString name);
74 //! Returns an attribute from its name, filtered by a type
75 //! If no attribute has this name, or if it is not kind of this
76 //! type, <val> is Null and returned value is False
78 Standard_EXPORT Standard_Boolean GetAttribute (const Standard_CString name, const Handle(Standard_Type)& type, Handle(Standard_Transient)& val) const;
80 //! Returns an attribute from its name. Null Handle if not recorded
81 //! (whatever Transient, Integer, Real ...)
82 Standard_EXPORT Handle(Standard_Transient) Attribute (const Standard_CString name) const;
84 //! Returns the type of an attribute :
85 //! ParamInt , ParamReal , ParamText (String) , ParamIdent (any)
86 //! or ParamVoid (not recorded)
87 Standard_EXPORT Interface_ParamType AttributeType (const Standard_CString name) const;
89 //! Adds an integer value for an attribute
90 Standard_EXPORT void SetIntegerAttribute (const Standard_CString name, const Standard_Integer val);
92 //! Returns an attribute from its name, as integer
93 //! If no attribute has this name, or not an integer,
94 //! <val> is 0 and returned value is False
96 Standard_EXPORT Standard_Boolean GetIntegerAttribute (const Standard_CString name, Standard_Integer& val) const;
98 //! Returns an integer attribute from its name. 0 if not recorded
99 Standard_EXPORT Standard_Integer IntegerAttribute (const Standard_CString name) const;
101 //! Adds a real value for an attribute
102 Standard_EXPORT void SetRealAttribute (const Standard_CString name, const Standard_Real val);
104 //! Returns an attribute from its name, as real
105 //! If no attribute has this name, or not a real
106 //! <val> is 0.0 and returned value is False
108 Standard_EXPORT Standard_Boolean GetRealAttribute (const Standard_CString name, Standard_Real& val) const;
110 //! Returns a real attribute from its name. 0.0 if not recorded
111 Standard_EXPORT Standard_Real RealAttribute (const Standard_CString name) const;
113 //! Adds a String value for an attribute
114 Standard_EXPORT void SetStringAttribute (const Standard_CString name, const Standard_CString val);
116 //! Returns an attribute from its name, as String
117 //! If no attribute has this name, or not a String
118 //! <val> is 0.0 and returned value is False
120 Standard_EXPORT Standard_Boolean GetStringAttribute (const Standard_CString name, Standard_CString& val) const;
122 //! Returns a String attribute from its name. "" if not recorded
123 Standard_EXPORT Standard_CString StringAttribute (const Standard_CString name) const;
125 //! Returns the exhaustive list of attributes
126 Standard_EXPORT Handle(Dico_DictionaryOfTransient) AttrList() const;
128 //! Gets the list of attributes from <other>, as such, i.e.
129 //! not copied : attributes are shared, any attribute edited,
130 //! added, or removed in <other> is also in <me> and vice versa
131 //! The former list of attributes of <me> is dropped
132 Standard_EXPORT void SameAttributes (const Handle(Transfer_Finder)& other);
134 //! Gets the list of attributes from <other>, by copying it
135 //! By default, considers all the attributes from <other>
136 //! If <fromname> is given, considers only the attributes with
137 //! name beginning by <fromname>
139 //! For each attribute, if <copied> is True (D), its value is also
140 //! copied if it is a basic type (Integer,Real,String), else it
141 //! remains shared between <other> and <me>
143 //! These new attributes are added to the existing ones in <me>,
144 //! in case of same name, they replace the existing ones
145 Standard_EXPORT void GetAttributes (const Handle(Transfer_Finder)& other, const Standard_CString fromname = "", const Standard_Boolean copied = Standard_True);
150 DEFINE_STANDARD_RTTIEXT(Transfer_Finder,MMgt_TShared)
155 //! Stores the HashCode which corresponds to the Value given to
156 //! create the Mapper
157 Standard_EXPORT void SetHashCode (const Standard_Integer code);
164 Standard_Integer thecode;
165 Handle(Dico_DictionaryOfTransient) theattrib;
176 #endif // _Transfer_Finder_HeaderFile