0031313: Foundation Classes - Dump improvement for classes
[occt.git] / src / TDataStd / TDataStd_Directory.cxx
1 // Created on: 1999-06-25
2 // Created by: Sergey RUIN
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <TDataStd_Directory.hxx>
18
19 #include <Standard_DomainError.hxx>
20 #include <Standard_Dump.hxx>
21 #include <Standard_GUID.hxx>
22 #include <Standard_Type.hxx>
23 #include <TDataStd.hxx>
24 #include <TDF_Attribute.hxx>
25 #include <TDF_DataSet.hxx>
26 #include <TDF_Label.hxx>
27 #include <TDF_RelocationTable.hxx>
28 #include <TDF_TagSource.hxx>
29
30 IMPLEMENT_STANDARD_RTTIEXT(TDataStd_Directory,TDF_Attribute)
31
32 //=======================================================================
33 //function : Find
34 //purpose  : 
35 //=======================================================================
36 Standard_Boolean TDataStd_Directory::Find (const TDF_Label& current,
37                                           Handle(TDataStd_Directory)& D) 
38 {  
39   TDF_Label L = current;
40   Handle(TDataStd_Directory) dir;
41   if (L.IsNull()) return Standard_False; 
42
43   for(;;) {
44     if(L.FindAttribute(TDataStd_Directory::GetID(), dir)) break; 
45     L = L.Father();
46     if (L.IsNull()) break; 
47   }
48   
49   if (!dir.IsNull()) { 
50     D = dir;
51     return Standard_True; 
52   }
53   return Standard_False; 
54 }
55
56
57 //=======================================================================
58 //function : GetID
59 //purpose  : 
60 //=======================================================================
61
62 const Standard_GUID& TDataStd_Directory::GetID() 
63 {
64   static Standard_GUID TDataStd_DirectoryID("2a96b61f-ec8b-11d0-bee7-080009dc3333");
65   return TDataStd_DirectoryID;
66 }
67
68
69 //=======================================================================
70 //function : New
71 //purpose  : 
72 //=======================================================================
73
74 Handle(TDataStd_Directory) TDataStd_Directory::New (const TDF_Label& L)
75 {  
76   if (L.HasAttribute()) {
77     throw Standard_DomainError("TDataStd_Directory::New : not an empty label");
78   }
79   Handle(TDataStd_Directory) A = new TDataStd_Directory ();
80   L.AddAttribute(A);                        
81   TDF_TagSource::Set(L);     
82   return A;
83 }
84
85
86 //=======================================================================
87 //function : TDataStd_AddDirectory
88 //purpose  : 
89 //=======================================================================
90
91 Handle(TDataStd_Directory) TDataStd_Directory::AddDirectory(const Handle(TDataStd_Directory)& dir)
92 {
93   TDF_Label newLabel = TDF_TagSource::NewChild ( dir->Label() );
94   Handle(TDataStd_Directory) A = TDataStd_Directory::New (newLabel );
95   return A;
96 }
97
98
99 //=======================================================================
100 //function : TDataStd_MakeObjectLabel
101 //purpose  : 
102 //=======================================================================
103
104 TDF_Label TDataStd_Directory::MakeObjectLabel(const Handle(TDataStd_Directory)& dir)
105 {
106   return TDF_TagSource::NewChild ( dir->Label() );
107 }
108
109 //=======================================================================
110 //function : TDataStd_Directory
111 //purpose  : 
112 //=======================================================================
113
114 TDataStd_Directory::TDataStd_Directory()
115 {
116 }
117
118
119 //=======================================================================
120 //function : ID
121 //purpose  : 
122 //=======================================================================
123
124 const Standard_GUID& TDataStd_Directory::ID() const
125 { return GetID(); }
126
127
128 //=======================================================================
129 //function : NewEmpty
130 //purpose  : 
131 //=======================================================================
132
133 Handle(TDF_Attribute) TDataStd_Directory::NewEmpty () const
134 {  
135   return new TDataStd_Directory(); 
136 }
137
138 //=======================================================================
139 //function : Restore
140 //purpose  : 
141 //=======================================================================
142
143 void TDataStd_Directory::Restore(const Handle(TDF_Attribute)&) 
144 {  
145 }
146
147 //=======================================================================
148 //function : Paste
149 //purpose  : 
150 //=======================================================================
151
152 void TDataStd_Directory::Paste (const Handle(TDF_Attribute)&,
153                                             const Handle(TDF_RelocationTable)& ) const
154 {  
155 }
156
157 //=======================================================================
158 //function : References
159 //purpose  : 
160 //=======================================================================
161
162 void TDataStd_Directory::References (const Handle(TDF_DataSet)&) const
163 {  
164 }
165
166 //=======================================================================
167 //function : Dump
168 //purpose  : 
169 //=======================================================================
170
171 Standard_OStream& TDataStd_Directory::Dump (Standard_OStream& anOS) const
172 {  
173   anOS << "Directory";
174   return anOS;
175 }
176
177 //=======================================================================
178 //function : DumpJson
179 //purpose  : 
180 //=======================================================================
181 void TDataStd_Directory::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
182 {
183   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
184
185   OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
186 }