Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/MoniTool_AttrList.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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