NGL  6.5
The NCCA Graphics Library
XMLSerializer.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 Jon Macey
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #ifndef XML_SERIALIZER_H_
18 #define XML_SERIALIZER_H_
19 #include "AbstractSerializer.h"
22 #include "rapidxml/rapidxml.hpp"
23 #include <stack>
24 
25 namespace ngl
26 {
27 //----------------------------------------------------------------------------------------------------------------------
33 //----------------------------------------------------------------------------------------------------------------------
35 {
36 
37 public :
38  enum ACCESSMODE{READ,WRITE};
39  //----------------------------------------------------------------------------------------------------------------------
42  //----------------------------------------------------------------------------------------------------------------------
43  XMLSerializer(const std::string &_fname,ACCESSMODE _mode);
44  //----------------------------------------------------------------------------------------------------------------------
46  //----------------------------------------------------------------------------------------------------------------------
47  virtual ~XMLSerializer();
48 
49  //----------------------------------------------------------------------------------------------------------------------
52  //----------------------------------------------------------------------------------------------------------------------
53  virtual void read(AABB &_s);
54  //----------------------------------------------------------------------------------------------------------------------
57  //----------------------------------------------------------------------------------------------------------------------
58  virtual void write(const AABB &_s);
59  //----------------------------------------------------------------------------------------------------------------------
62  //----------------------------------------------------------------------------------------------------------------------
63  virtual void read(BBox &_s);
64  //----------------------------------------------------------------------------------------------------------------------
67  //----------------------------------------------------------------------------------------------------------------------
68  virtual void write(const BBox &_s);
69  //----------------------------------------------------------------------------------------------------------------------
72  //----------------------------------------------------------------------------------------------------------------------
73  virtual void read(BezierCurve &_s);
74  //----------------------------------------------------------------------------------------------------------------------
77  //----------------------------------------------------------------------------------------------------------------------
78  virtual void write(const BezierCurve &_s);
79  //----------------------------------------------------------------------------------------------------------------------
82  //----------------------------------------------------------------------------------------------------------------------
83  virtual void read(Camera &_s);
84  //----------------------------------------------------------------------------------------------------------------------
87  //----------------------------------------------------------------------------------------------------------------------
88  virtual void write(const Camera &_s, const std::string &_tag);
89  //----------------------------------------------------------------------------------------------------------------------
92  //----------------------------------------------------------------------------------------------------------------------
93  virtual void read(Colour &_s);
94  //----------------------------------------------------------------------------------------------------------------------
97  //----------------------------------------------------------------------------------------------------------------------
98  virtual void write(const Colour &_s,std::string _tag="Colour");
99  virtual void write(const Colour &_s,rapidxml::xml_node<> *_parent,std::string _tag="Colour");
100 
101  //----------------------------------------------------------------------------------------------------------------------
104  //----------------------------------------------------------------------------------------------------------------------
105  virtual void read(Light &_s);
106  //----------------------------------------------------------------------------------------------------------------------
109  //----------------------------------------------------------------------------------------------------------------------
110  virtual void write(const Light &_s, const std::string &_tag) ;
111  //----------------------------------------------------------------------------------------------------------------------
114  //----------------------------------------------------------------------------------------------------------------------
115  virtual void read(Mat3 &_s);
116  //----------------------------------------------------------------------------------------------------------------------
119  //----------------------------------------------------------------------------------------------------------------------
120  virtual void write(Mat3 &_s, std::string _tag="Mat3");
121  //----------------------------------------------------------------------------------------------------------------------
124  //----------------------------------------------------------------------------------------------------------------------
125  virtual void read(Mat4 &_s);
126  //----------------------------------------------------------------------------------------------------------------------
129  //----------------------------------------------------------------------------------------------------------------------
130  virtual void write( Mat4 &_s, std::string _tag="Mat4");
131  //----------------------------------------------------------------------------------------------------------------------
134  //----------------------------------------------------------------------------------------------------------------------
135  virtual void read(Material &_s);
136  //----------------------------------------------------------------------------------------------------------------------
139  //----------------------------------------------------------------------------------------------------------------------
140  virtual void write(const Material &_s, const std::string &_tag);
141  //----------------------------------------------------------------------------------------------------------------------
144  //----------------------------------------------------------------------------------------------------------------------
145  virtual void read(PathCamera &_s);
146  //----------------------------------------------------------------------------------------------------------------------
149  //----------------------------------------------------------------------------------------------------------------------
150  virtual void write(const PathCamera &_s, const std::string &_tag);
151  //----------------------------------------------------------------------------------------------------------------------
154  //----------------------------------------------------------------------------------------------------------------------
155  virtual void read(Plane &_s);
156  //----------------------------------------------------------------------------------------------------------------------
159  //----------------------------------------------------------------------------------------------------------------------
160  virtual void write(const Plane &_s, const std::string &_tag);
161  //----------------------------------------------------------------------------------------------------------------------
164  //----------------------------------------------------------------------------------------------------------------------
165  virtual void read(Quaternion &_s);
166  //----------------------------------------------------------------------------------------------------------------------
169  //----------------------------------------------------------------------------------------------------------------------
170  virtual void write(const Quaternion &_s,const std::string &_tag="Quat");
171  //----------------------------------------------------------------------------------------------------------------------
174  //----------------------------------------------------------------------------------------------------------------------
175  virtual void read(SpotLight &_s);
176  //----------------------------------------------------------------------------------------------------------------------
179  //----------------------------------------------------------------------------------------------------------------------
180  virtual void write(const SpotLight &_s, const std::string &_tag);
181  //----------------------------------------------------------------------------------------------------------------------
184  //----------------------------------------------------------------------------------------------------------------------
185  virtual void read(Transformation &_s);
186  //----------------------------------------------------------------------------------------------------------------------
189  //----------------------------------------------------------------------------------------------------------------------
190  virtual void write(const Transformation &_s,const std::string &_tag);
191  //----------------------------------------------------------------------------------------------------------------------
194  //----------------------------------------------------------------------------------------------------------------------
195  virtual void read(Vec2 &_s);
196  //----------------------------------------------------------------------------------------------------------------------
199  //----------------------------------------------------------------------------------------------------------------------
200  virtual void write(const Vec2 &_s,std::string _tag="Vec2");
201  void write(const Vec2 &_s,rapidxml::xml_node<> *_parent,std::string _tag) ;
202 
203  //----------------------------------------------------------------------------------------------------------------------
206  //----------------------------------------------------------------------------------------------------------------------
207  virtual void read(Vec3 &_s);
208  //----------------------------------------------------------------------------------------------------------------------
211  //----------------------------------------------------------------------------------------------------------------------
212  virtual void write(const Vec3 &_s, std::string _tag="Vec3");
213  void write(const Vec3 &_s,rapidxml::xml_node<> *_parent,std::string _tag) ;
214 
215  //----------------------------------------------------------------------------------------------------------------------
218  //----------------------------------------------------------------------------------------------------------------------
219  virtual void read(Vec4 &_s);
220  //----------------------------------------------------------------------------------------------------------------------
223  //----------------------------------------------------------------------------------------------------------------------
224  virtual void write(const Vec4 &_s,std::string _tag="Vec4") ;
225  void write(const Vec4 &_s,rapidxml::xml_node<> *_parent,std::string _tag) ;
226  void writeToXML(const std::string &_s, const std::string &_tag);
227  void writeToXML(const std::string &_s, rapidxml::xml_node<> *_parent,const std::string &_tag);
228  void addNode(const std::string &_tag);
229  void addNode(const std::string &_tag,rapidxml::xml_node<> *_parent);
230 
231 
232  rapidxml::xml_node<>* getCurrentNode() const {return m_currentNode;}
233 private :
237  XMLSerializer &operator=(const XMLSerializer &);
238 
239 private :
241 
244 
247 
248 };
249 
250 
251 
252 } // end of namespace ngl
253 
254 
255 #endif // end of the class
rapidxml::xml_node * getCurrentNode() const
This file contains rapidxml parser and DOM implementation.
Mat3 basic 3x3 matrix for certain glsl ops.
Definition: Mat3.h:43
Generic Bezier Curve Class allowing the user to generate basic curves using a number of different con...
Definition: BezierCurve.h:45
simple Vec2 encapsulates a 3 float object like glsl Vec2 but not maths use the Vec2 class for maths a...
Definition: Vec2.h:49
rapidxml::xml_document m_doc
simple class to hold colour information and set the basic opengl colour state. also has overloaded me...
Definition: Colour.h:40
simple Vector class for OpenGL graphics, contains overloaded operators for most math functions...
Definition: Vec4.h:57
#define NGL_DLLEXPORT
Definition: Types.h:65
Simple class to encapsulate OpenGL Light functions this will fill in the following structure...
Definition: Light.h:68
this class is the base class for all NGL serialisation code
FMT_FUNC void write(std::ostream &os, Writer &w)
Definition: ostream.cc:15
an abstract base clase for all serialization in NGL
Definition: AABB.h:42
Inherits from Camera and adds a path for both eye and look using two Bezier Curves.
Definition: PathCamera.h:33
simple Vec3 encapsulates a 3 float object like glsl vec3 but not maths use the Vec3 class for maths a...
Definition: Vec3.h:51
implementation files for RibExport class
Definition: AABB.cpp:22
Encapsulation of OpenGL spotlight inherits from the Light class.
Definition: SpotLight.h:58
XMLSerializer(const AbstractSerializer &)
make sure we can&#39;t copy this class;
simple camera class to allow movement in an opengl scene. a lot of this stuff is from the HILL book C...
Definition: Camera.h:54
rapidxml::xml_node * m_parent
Transformation describes a transformation (translate, scale, rotation) modifed by j macey and include...
Simple Bounding box class used in various parts of ngl and other example programs.
Definition: BBox.h:40
Matrix Class to do simple matrix operations included operator overloaded functions for maths and matr...
Definition: Mat4.h:58
std::string m_fname
rapidxml::xml_node * m_currentNode
GLsizei const GLchar *const * string
Definition: glew.h:1847