0030773: Application Framework - To allow to inherit existing attributes to reuse...
[occt.git] / src / TDF / TDF_AttributeIterator.hxx
1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1998-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //              -------------------------
17
18 // Version:     0.0
19 //Version       Date            Purpose
20 //              0.0     Feb 16 1998     Creation
21
22 #ifndef TDF_AttributeIterator_HeaderFile
23 #define TDF_AttributeIterator_HeaderFile
24
25 #include <TDF_Attribute.hxx>
26 #include <TDF_Label.hxx>
27 #include <TDF_LabelNodePtr.hxx>
28
29 // This class provides a way to iterates on the
30 // up-to-date (current) valid attributes of a label.
31 //
32 // This class should not be used for standard attributes workflow.
33 // Application allways knows what to search at particular label.
34 // So, use IsAttribute and FindAttibute methods of
35 // TDF_Label to check and get attributes in usual way.
36 // This class may be used for processing of content of labels
37 // in generic way, like copy-tool, specific save/restore algorithms,
38 // etc.
39 //
40 // Even a forgotten attribute may be found if this
41 // option is set. To use this possibility, look at
42 // the constructor.
43
44 class TDF_AttributeIterator  {
45
46 public:
47
48   // Methods PUBLIC
49   // 
50   Standard_EXPORT TDF_AttributeIterator();
51   Standard_EXPORT TDF_AttributeIterator
52     (const TDF_Label& aLabel,
53      const Standard_Boolean withoutForgotten = Standard_True);
54   Standard_EXPORT TDF_AttributeIterator
55     (const TDF_LabelNodePtr aLabelNode,
56      const Standard_Boolean withoutForgotten = Standard_True);
57   Standard_EXPORT   void Initialize
58     (const TDF_Label& aLabel,
59      const Standard_Boolean withoutForgotten = Standard_True) ;
60   inline   Standard_Boolean More() const;
61   Standard_EXPORT   void Next() ;
62   inline   Handle(TDF_Attribute) Value() const;
63
64   //! Provides an access to the internal pointer of the current attribute.
65   //! The method has better performance as not-creating handle.
66   inline const TDF_Attribute* PtrValue() const { return myValue; }
67
68 protected:
69
70  // Methods PROTECTED
71  // 
72
73
74  // Fields PROTECTED
75  //
76
77
78 private: 
79
80  // Methods PRIVATE
81  // 
82   void goToNext (const Handle(TDF_Attribute)& anAttr);
83
84
85  // Fields PRIVATE
86  //
87   TDF_Attribute    * myValue;
88   Standard_Boolean myWithoutForgotten;
89 };
90
91
92 // other inline functions and methods (like "C++: function call" methods)
93 //
94
95 inline Standard_Boolean TDF_AttributeIterator::More() const
96 { return (myValue != 0L); }
97
98 inline Handle(TDF_Attribute) TDF_AttributeIterator::Value() const
99 { return myValue; }
100
101 #endif