Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:16:24

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