0024710: Avoid including Handle_Class.hxx headers except where necessary
[occt.git] / src / VrmlData / VrmlData_Node.hxx
CommitLineData
b311480e 1// Created on: 2006-05-25
2// Created by: Alexander GRIGORIEV
973c2be1 3// Copyright (c) 2006-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
16#ifndef VrmlData_Node_HeaderFile
17#define VrmlData_Node_HeaderFile
18
cb389a77 19#include <Standard_Type.hxx>
7fd59977 20#include <NCollection_List.hxx>
21#include <Standard_DefineHandle.hxx>
22#include <Standard_TypeDef.hxx>
23#include <TCollection_AsciiString.hxx>
24#include <VrmlData_ErrorStatus.hxx>
25
26#define VRMLDATA_LCOMPARE(aa, bb) \
b311480e 27((strncmp (aa, bb, sizeof(bb)-1)) ? 0L : (aa += sizeof(bb)-1))
7fd59977 28
29struct VrmlData_InBuffer;
30class VrmlData_Scene;
31class gp_XY;
32class gp_XYZ;
33class Handle_VrmlData_Node;
34class TCollection_AsciiString;
35
36/**
37 * Abstract VRML Node
38 */
39class VrmlData_Node : public Standard_Transient
40{
41 public:
42 // ---------- PUBLIC METHODS ----------
43
44 /**
45 * Empty constructor
46 */
47 Standard_EXPORT VrmlData_Node ();
48
49 /**
50 * Destructor
51 */
52 virtual ~VrmlData_Node () {}
53
54 /**
55 * Query the Scene that contains this Node
56 */
57 inline const VrmlData_Scene& Scene () const
58 { return * myScene; }
59
60 /**
61 * Query the name
62 */
63 inline const char * Name () const { return myName; }
64
65 /**
66 * Read a complete node definition from VRML stream
67 * @param theBuffer
68 * Buffer receiving the input data.
69 * @param theNode
70 * <tt>[out]</tt> Node restored from the buffer data
71 * @param Type
72 * Node type to be checked. If it is NULL(default) no type checking is done.
73 * Otherwise the created node is matched and an error is returned if
74 * no match detected.
75 */
76 Standard_EXPORT VrmlData_ErrorStatus
77 ReadNode (VrmlData_InBuffer& theBuffer,
78 Handle(VrmlData_Node)&theNode,
79 const Handle(Standard_Type)& Type
80 = NULL);
81
82 /**
83 * Read the Node from input stream.
84 */
85 Standard_EXPORT virtual VrmlData_ErrorStatus
86 Read (VrmlData_InBuffer& theBuffer) = 0;
87
88 /**
89 * Write the Node to output stream.
90 */
91 Standard_EXPORT virtual VrmlData_ErrorStatus
92 Write (const char * thePrefix) const;
93
94 /**
95 * Returns True if the node is default, then it would not be written.
96 */
97 Standard_EXPORT virtual Standard_Boolean
98 IsDefault () const;
99
100 /**
101 * Write the closing brace in the end of a node output.
102 */
103 Standard_EXPORT VrmlData_ErrorStatus
104 WriteClosing () const;
105
106 /**
107 * Create a copy of this node.
108 * If the parameter is null, a new copied node is created. Otherwise new node
109 * is not created, but rather the given one is modified.<p>
110 * This method nullifies the argument node if its member myScene differs
111 * from that one of the current instance.
112 */
113 Standard_EXPORT virtual Handle(VrmlData_Node)
114 Clone (const Handle(VrmlData_Node)&)const;
115
116 /**
117 * Read one boolean value (TRUE or FALSE).
118 */
119 Standard_EXPORT static VrmlData_ErrorStatus
120 ReadBoolean (VrmlData_InBuffer& theBuffer,
121 Standard_Boolean& theResult);
122
123 /**
124 * Read one quoted string, the quotes are removed.
125 */
126 Standard_EXPORT static VrmlData_ErrorStatus
127 ReadString (VrmlData_InBuffer& theBuffer,
128 TCollection_AsciiString& theRes);
129
130 /**
131 * Read one quoted string, the quotes are removed.
132 */
133 Standard_EXPORT static VrmlData_ErrorStatus
134 ReadMultiString
135 (VrmlData_InBuffer& theBuffer,
136 NCollection_List<TCollection_AsciiString>& theRes);
137
138 /**
139 * Read one integer value.
140 */
141 Standard_EXPORT static VrmlData_ErrorStatus
142 ReadInteger (VrmlData_InBuffer& theBuffer,
143 long& theResult);
144
145 static inline Standard_Boolean OK (const VrmlData_ErrorStatus theStat)
146 { return theStat == VrmlData_StatusOK; }
147
148 static inline Standard_Boolean OK (VrmlData_ErrorStatus& outStat,
149 const VrmlData_ErrorStatus theStat)
150 { return (outStat = theStat) == VrmlData_StatusOK; }
151
152 /**
153 * Define the common Indent in spaces, for writing all nodes.
154 */
155 static inline Standard_Integer GlobalIndent ()
156 { return 2; }
157
158 protected:
159 // ---------- PROTECTED METHODS ----------
160
161 /**
162 * Constructor
163 */
164 Standard_EXPORT VrmlData_Node (const VrmlData_Scene& theScene,
165 const char * theName);
166
167 /**
168 * Read the closing brace. If successful, theBufrfer is incremented.
169 * If no brace is found, theBuffer stays in untouched and the method returns
170 * VrmlFormatError.
171 */
172 Standard_EXPORT static VrmlData_ErrorStatus
173 readBrace (VrmlData_InBuffer& theBuffer);
174
175 private:
176 // ---------- PRIVATE METHODS ----------
177
178 /**
179 * Method called from VrmlData_Scene when a name should be assigned
180 * automatically.
181 */
182 Standard_EXPORT void setName (const char * theName,
183 const char * theSuffix = 0L);
184
185 private:
186 // ---------- PRIVATE FIELDS ----------
187
188 const VrmlData_Scene * myScene;
189 const char * myName; ///< name of the node
190#ifdef _DEBUG
191 Standard_Integer myLineCount;
192#endif
193
194 friend class VrmlData_Group;
195 friend class VrmlData_Scene;
196
197 public:
198// Declaration of CASCADE RTTI
199 DEFINE_STANDARD_RTTI (VrmlData_Node)
200};
201
202// Definition of HANDLE object using Standard_DefineHandle.hxx
203DEFINE_STANDARD_HANDLE (VrmlData_Node, Standard_Transient)
204
205Standard_EXPORT Standard_Integer HashCode(const Handle_VrmlData_Node& theNode,
206 const Standard_Integer theUpper);
207Standard_EXPORT Standard_Boolean IsEqual (const Handle(VrmlData_Node)& theOne,
208 const Handle(VrmlData_Node)& theTwo);
209
210#endif