Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:17

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 _MoniTool_AttrList_HeaderFile
0018 #define _MoniTool_AttrList_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <MoniTool_ValueType.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <Standard_Real.hxx>
0027 #include <NCollection_DataMap.hxx>
0028 #include <Standard_Transient.hxx>
0029 #include <TCollection_AsciiString.hxx>
0030 
0031 //! a AttrList allows to record a list of attributes as Transients
0032 //! which can be edited, changed ...
0033 //! Each one is identified by a name
0034 class MoniTool_AttrList 
0035 {
0036 public:
0037 
0038   DEFINE_STANDARD_ALLOC
0039 
0040   
0041   //! Creates an AttrList, empty
0042   Standard_EXPORT MoniTool_AttrList();
0043   
0044   //! Creates an AttrList from another one, definitions are shared
0045   //! (calls SameAttributes)
0046   Standard_EXPORT MoniTool_AttrList(const MoniTool_AttrList& other);
0047   
0048   //! Adds an attribute with a given name (replaces the former one
0049   //! with the same name if already exists)
0050   Standard_EXPORT void SetAttribute (const Standard_CString name, const Handle(Standard_Transient)& val);
0051   
0052   //! Removes an attribute
0053   //! Returns True when done, False if this attribute did not exist
0054   Standard_EXPORT Standard_Boolean RemoveAttribute (const Standard_CString name);
0055   
0056   //! Returns an attribute from its name, filtered by a type
0057   //! If no attribute has this name, or if it is not kind of this
0058   //! type, <val> is Null and returned value is False
0059   //! Else, it is True
0060   Standard_EXPORT Standard_Boolean GetAttribute (const Standard_CString name, const Handle(Standard_Type)& type, Handle(Standard_Transient)& val) const;
0061   
0062   //! Returns an attribute from its name. Null Handle if not
0063   //! recorded         (whatever Transient, Integer, Real ...)
0064   //! Integer is recorded as IntVal
0065   //! Real is recorded as RealVal
0066   //! Text is recorded as HAsciiString
0067   Standard_EXPORT Handle(Standard_Transient) Attribute (const Standard_CString name) const;
0068   
0069   //! Returns the type of an attribute :
0070   //! ValueInt , ValueReal , ValueText (String) , ValueIdent (any)
0071   //! or ValueVoid (not recorded)
0072   Standard_EXPORT MoniTool_ValueType AttributeType (const Standard_CString name) const;
0073   
0074   //! Adds an integer value for an attribute
0075   Standard_EXPORT void SetIntegerAttribute (const Standard_CString name, const Standard_Integer val);
0076   
0077   //! Returns an attribute from its name, as integer
0078   //! If no attribute has this name, or not an integer,
0079   //! <val> is 0 and returned value is False
0080   //! Else, it is True
0081   Standard_EXPORT Standard_Boolean GetIntegerAttribute (const Standard_CString name, Standard_Integer& val) const;
0082   
0083   //! Returns an integer attribute from its name. 0 if not recorded
0084   Standard_EXPORT Standard_Integer IntegerAttribute (const Standard_CString name) const;
0085   
0086   //! Adds a real value for an attribute
0087   Standard_EXPORT void SetRealAttribute (const Standard_CString name, const Standard_Real val);
0088   
0089   //! Returns an attribute from its name, as real
0090   //! If no attribute has this name, or not a real
0091   //! <val> is 0.0 and returned value is False
0092   //! Else, it is True
0093   Standard_EXPORT Standard_Boolean GetRealAttribute (const Standard_CString name, Standard_Real& val) const;
0094   
0095   //! Returns a real attribute from its name. 0.0 if not recorded
0096   Standard_EXPORT Standard_Real RealAttribute (const Standard_CString name) const;
0097   
0098   //! Adds a String value for an attribute
0099   Standard_EXPORT void SetStringAttribute (const Standard_CString name, const Standard_CString val);
0100   
0101   //! Returns an attribute from its name, as String
0102   //! If no attribute has this name, or not a String
0103   //! <val> is 0.0 and returned value is False
0104   //! Else, it is True
0105   Standard_EXPORT Standard_Boolean GetStringAttribute (const Standard_CString name, Standard_CString& val) const;
0106   
0107   //! Returns a String attribute from its name. "" if not recorded
0108   Standard_EXPORT Standard_CString StringAttribute (const Standard_CString name) const;
0109   
0110   //! Returns the exhaustive list of attributes
0111   Standard_EXPORT const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& AttrList() const;
0112   
0113   //! Gets the list of attributes from <other>, as such, i.e.
0114   //! not copied : attributes are shared, any attribute edited,
0115   //! added, or removed in <other> is also in <me> and vice versa
0116   //! The former list of attributes of <me> is dropped
0117   Standard_EXPORT void SameAttributes (const MoniTool_AttrList& other);
0118   
0119   //! Gets the list of attributes from <other>, by copying it
0120   //! By default, considers all the attributes from <other>
0121   //! If <fromname> is given, considers only the attributes with
0122   //! name beginning by <fromname>
0123   //!
0124   //! For each attribute, if <copied> is True (D), its value is also
0125   //! copied if it is a basic type (Integer,Real,String), else it
0126   //! remains shared between <other> and <me>
0127   //!
0128   //! These new attributes are added to the existing ones in <me>,
0129   //! in case of same name, they replace the existing ones
0130   Standard_EXPORT void GetAttributes (const MoniTool_AttrList& other, const Standard_CString fromname = "", const Standard_Boolean copied = Standard_True);
0131 
0132 
0133 
0134 
0135 protected:
0136 
0137 
0138 
0139 
0140 
0141 private:
0142 
0143 
0144 
0145   NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> theattrib;
0146 
0147 
0148 };
0149 
0150 
0151 
0152 
0153 
0154 
0155 
0156 #endif // _MoniTool_AttrList_HeaderFile