1 // Created on: 2008-06-22
2 // Created by: Vladislav ROMASHKO
3 // Copyright (c) 2008-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 #ifndef _TFunction_Scope_HeaderFile
17 #define _TFunction_Scope_HeaderFile
18 
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
21 
22 #include <TFunction_DoubleMapOfIntegerLabel.hxx>
23 #include <TFunction_Logbook.hxx>
24 #include <Standard_Integer.hxx>
25 #include <TDF_Attribute.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_OStream.hxx>
28 class TDF_Label;
29 class Standard_GUID;
30 class TFunction_Logbook;
31 class TDF_Attribute;
32 class TDF_RelocationTable;
33 
34 
35 class TFunction_Scope;
36 DEFINE_STANDARD_HANDLE(TFunction_Scope, TDF_Attribute)
37 
38 //! Keeps a scope of functions.
39 class TFunction_Scope : public TDF_Attribute
40 {
41 
42 public:
43 
44 
45   //! Static methods
46   //! ==============
47   //! Finds or Creates a TFunction_Scope attribute at the root label accessed by <Access>.
48   //! Returns the attribute.
49   Standard_EXPORT static Handle(TFunction_Scope) Set (const TDF_Label& Access);
50 
51   //! Returns the GUID for Scope attribute.
52   //! Instant methods
53   //! ===============
54   //! Constructor (empty).
55   Standard_EXPORT static const Standard_GUID& GetID();
56 
57   Standard_EXPORT TFunction_Scope();
58 
59   //! Adds a function to the scope of functions.
60   Standard_EXPORT Standard_Boolean AddFunction (const TDF_Label& L);
61 
62   //! Removes a function from the scope of functions.
63   Standard_EXPORT Standard_Boolean RemoveFunction (const TDF_Label& L);
64 
65   //! Removes a function from the scope of functions.
66   Standard_EXPORT Standard_Boolean RemoveFunction (const Standard_Integer ID);
67 
68   //! Removes all functions from the scope of functions.
69   Standard_EXPORT void RemoveAllFunctions();
70 
71   //! Returns true if the function exists with such an ID.
72   Standard_EXPORT Standard_Boolean HasFunction (const Standard_Integer ID) const;
73 
74   //! Returns true if the label contains a function of this scope.
75   Standard_EXPORT Standard_Boolean HasFunction (const TDF_Label& L) const;
76 
77   //! Returns an ID of the function.
78   Standard_EXPORT Standard_Integer GetFunction (const TDF_Label& L) const;
79 
80   //! Returns the label of the function with this ID.
81   Standard_EXPORT const TDF_Label& GetFunction (const Standard_Integer ID) const;
82 
83   //! Returns the Logbook used in TFunction_Driver methods.
84   //! Implementation of Attribute methods
85   //! ===================================
86   Standard_EXPORT Handle(TFunction_Logbook) GetLogbook() const;
87 
88   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
89 
90   Standard_EXPORT virtual void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
91 
92   Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
93 
94   Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
95 
96   Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
97 
98   //! Returns the scope of functions.
99   Standard_EXPORT const TFunction_DoubleMapOfIntegerLabel& GetFunctions() const;
100 
101   //! Returns the scope of functions for modification.
102   //! Warning: Don't use this method if You are not sure what You do!
103   Standard_EXPORT TFunction_DoubleMapOfIntegerLabel& ChangeFunctions();
104 
105   Standard_EXPORT void SetFreeID (const Standard_Integer ID);
106 
107   Standard_EXPORT Standard_Integer GetFreeID() const;
108 
109 
110 
111 
112   DEFINE_STANDARD_RTTIEXT(TFunction_Scope,TDF_Attribute)
113 
114 protected:
115 
116 
117 
118 
119 private:
120 
121 
122   TFunction_DoubleMapOfIntegerLabel myFunctions;
123   Standard_Integer myFreeID;
124 
125 
126 };
127 
128 
129 
130 
131 
132 
133 
134 #endif // _TFunction_Scope_HeaderFile
135