ViSP  2.10.0
vpXmlParserHomogeneousMatrix.h
1 /****************************************************************************
2  *
3  * $Id: vpXmlParserHomogeneousMatrix.h 4649 2014-02-07 14:57:11Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * XML parser to load and save Homogeneous Matrix in a XML file
36  *
37  * Authors:
38  * Giovanni Claudio
39  *
40  *****************************************************************************/
41 
49 #ifndef vpXMLPARSERHOMOGENEOUSMATRIX_H
50 #define vpXMLPARSERHOMOGENEOUSMATRIX_H
51 
52 #include <visp/vpConfig.h>
53 
54 #ifdef VISP_HAVE_XML2
55 
56 #include <string>
57 #include <visp/vpXmlParser.h>
58 #include <visp/vpHomogeneousMatrix.h>
59 #include <libxml/xmlmemory.h> /* Functions of libxml. */
60 
164 class VISP_EXPORT vpXmlParserHomogeneousMatrix: public vpXmlParser
165 {
166 
167 public:
168 
169  /* --- XML Code------------------------------------------------------------ */
170  typedef enum
171  {
172  CODE_XML_BAD = -1,
182  CODE_XML_TUZ
183  } vpXmlCodeType;
184 
185  typedef enum
186  {
188  SEQUENCE_ERROR
189  } vpXmlCodeSequenceType;
190 
191 private :
192 
194  std::string m_name;
195 
196 public:
197 
201 
202  // get/set functions
203  vpHomogeneousMatrix getHomogeneousMatrix() const {return this->m_M;}
204  std::string getHomogeneousMatrixName() const {return this->m_name;}
205 
206  vpXmlParserHomogeneousMatrix& operator =(const vpXmlParserHomogeneousMatrix& twinparser);
207  int parse(vpHomogeneousMatrix &M, const std::string &filename, const std::string &name);
208 
209  int save(const vpHomogeneousMatrix &M, const std::string &filename, const std::string &name);
210 
211  void setHomogeneousMatrixName(const std::string& name){
212  this->m_name = name;
213  }
214 
215 private:
216  int read (xmlDocPtr doc, xmlNodePtr node,
217  const std::string& name);
218 
219  int count (xmlDocPtr doc, xmlNodePtr node,
220  const std::string& name);
221 
222  int read_matrix (xmlDocPtr doc, xmlNodePtr node,
223  const std::string& name);
224 
225  vpXmlCodeSequenceType read_values (xmlDocPtr doc, xmlNodePtr node,
227 
228  static vpXmlCodeSequenceType str2xmlcode (char * str, vpXmlCodeType & res);
229  void myXmlReadIntChild (xmlDocPtr doc,
230  xmlNodePtr node,
231  int &res,
232  vpXmlCodeSequenceType &code_error);
233 
234  void myXmlReadDoubleChild (xmlDocPtr doc,
235  xmlNodePtr node,
236  double &res,
237  vpXmlCodeSequenceType &code_error);
238 
239  void myXmlReadCharChild (xmlDocPtr doc,
240  xmlNodePtr node,
241  char **res);
242  int write (xmlNodePtr node, const std::string& name);
243 
244 private:
245 
251  virtual void readMainClass(xmlDocPtr , xmlNodePtr ){};
252 
258  virtual void writeMainClass(xmlNodePtr ){};
259 
260 };
261 #endif //VISP_HAVE_XML2
262 #endif
void setHomogeneousMatrixName(const std::string &name)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
virtual void writeMainClass(xmlNodePtr node)=0
void save(const std::string &filename, const bool append=false)
This class intends to simplify the creation of xml parser based on the libxml2 third party library...
Definition: vpXmlParser.h:178
vpHomogeneousMatrix getHomogeneousMatrix() const
XML parser to load and save an homogenous matrix in a file.
virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node)=0
void parse(const std::string &filename)