0026937: Eliminate NO_CXX_EXCEPTION macro support
[occt.git] / src / TDataStd / TDataStd_NoteBook.cxx
1 // Created on: 1997-07-29
2 // Created by: Denis PASCAL
3 // Copyright (c) 1997-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
18 #include <Standard_DomainError.hxx>
19 #include <Standard_GUID.hxx>
20 #include <Standard_Type.hxx>
21 #include <TDataStd_Integer.hxx>
22 #include <TDataStd_NoteBook.hxx>
23 #include <TDataStd_Real.hxx>
24 #include <TDF_Attribute.hxx>
25 #include <TDF_Label.hxx>
26 #include <TDF_RelocationTable.hxx>
27 #include <TDF_TagSource.hxx>
28
29 IMPLEMENT_STANDARD_RTTIEXT(TDataStd_NoteBook,TDF_Attribute)
30
31 //=======================================================================
32 //function : Find
33 //purpose  : 
34 //=======================================================================
35 Standard_Boolean TDataStd_NoteBook::Find (const TDF_Label& current,
36                                           Handle(TDataStd_NoteBook)& N) 
37 {  
38   TDF_Label L = current;
39   Handle(TDataStd_NoteBook) NB;
40   if (L.IsNull()) return Standard_False; 
41
42   for(;;) {
43     if(L.FindAttribute(TDataStd_NoteBook::GetID(), NB)) break; 
44     L = L.Father();
45     if (L.IsNull()) break; 
46   }
47
48   if (!NB.IsNull()) { 
49     N = NB;
50     return Standard_True; 
51   }
52   return Standard_False; 
53 }
54
55
56 //=======================================================================
57 //function : New
58 //purpose  : 
59 //=======================================================================
60
61 Handle(TDataStd_NoteBook) TDataStd_NoteBook::New (const TDF_Label& label)
62 {  
63   if (label.HasAttribute()) {
64     throw Standard_DomainError("TDataStd_NoteBook::New : not an empty label");
65   }
66   Handle(TDataStd_NoteBook) NB = new TDataStd_NoteBook ();  
67   label.AddAttribute(NB);
68   TDF_TagSource::Set(label);    // distributeur de sous label
69   return NB;
70 }
71
72 //=======================================================================
73 //function : GetID
74 //purpose  : 
75 //=======================================================================
76
77 const Standard_GUID& TDataStd_NoteBook::GetID() 
78 {
79   static Standard_GUID TDataStd_NoteBookID("2a96b609-ec8b-11d0-bee7-080009dc3333");
80   return TDataStd_NoteBookID;
81 }
82
83
84 //=======================================================================
85 //function : TDataStd_NoteBook
86 //purpose  : 
87 //=======================================================================
88
89 TDataStd_NoteBook::TDataStd_NoteBook()
90 {
91 }
92
93
94 //=======================================================================
95 //function : Append Real Variable
96 //purpose  : 
97 //=======================================================================
98
99 Handle(TDataStd_Real) TDataStd_NoteBook::Append(const Standard_Real value,
100                                                 const Standard_Boolean ) 
101 {
102   TDF_Label newlabel =  TDF_TagSource::NewChild (Label());
103   Handle(TDataStd_Real) variable = TDataStd_Real::Set ( newlabel, value); 
104   return variable;
105 }
106
107 //=======================================================================
108 //function : Append Integer Variable
109 //purpose  : 
110 //=======================================================================
111
112 Handle(TDataStd_Integer) TDataStd_NoteBook::Append(const Standard_Integer value,
113                                                    const Standard_Boolean ) 
114 {
115   TDF_Label newlabel =  TDF_TagSource::NewChild (Label());
116   Handle(TDataStd_Integer) variable = TDataStd_Integer::Set ( newlabel, value); 
117   return variable;
118 }
119
120 //=======================================================================
121 //function : ID
122 //purpose  : 
123 //=======================================================================
124
125 const Standard_GUID& TDataStd_NoteBook::ID() const
126 { return GetID(); }
127
128
129 //=======================================================================
130 //function : NewEmpty
131 //purpose  : 
132 //=======================================================================
133
134 Handle(TDF_Attribute) TDataStd_NoteBook::NewEmpty () const
135 {  
136   return new TDataStd_NoteBook(); 
137 }
138
139 //=======================================================================
140 //function : Restore
141 //purpose  : 
142 //=======================================================================
143
144 void TDataStd_NoteBook::Restore(const Handle(TDF_Attribute)& ) 
145 {
146 }
147
148 //=======================================================================
149 //function : Paste
150 //purpose  : 
151 //=======================================================================
152
153 void TDataStd_NoteBook::Paste (const Handle(TDF_Attribute)& ,
154                                const Handle(TDF_RelocationTable)& ) const
155 {
156 }
157
158 //=======================================================================
159 //function : Dump
160 //purpose  : 
161 //=======================================================================
162
163 Standard_OStream& TDataStd_NoteBook::Dump (Standard_OStream& anOS) const
164 {  
165   anOS << "NoteBook";
166   return anOS;
167 }
168
169