Visual Servoing Platform  version 3.0.0
vpXmlParserHomogeneousMatrix.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * XML parser to load and save Homogeneous Matrix in a XML file
32  *
33  * Authors:
34  * Giovanni Claudio
35  *
36  *****************************************************************************/
37 
45 #ifndef vpXMLPARSERHOMOGENEOUSMATRIX_H
46 #define vpXMLPARSERHOMOGENEOUSMATRIX_H
47 
48 #include <visp3/core/vpConfig.h>
49 
50 #ifdef VISP_HAVE_XML2
51 
52 #include <string>
53 #include <visp3/core/vpXmlParser.h>
54 #include <visp3/core/vpHomogeneousMatrix.h>
55 #include <libxml/xmlmemory.h> /* Functions of libxml. */
56 
160 class VISP_EXPORT vpXmlParserHomogeneousMatrix: public vpXmlParser
161 {
162 
163 public:
164 
165  /* --- XML Code------------------------------------------------------------ */
166  typedef enum
167  {
168  CODE_XML_BAD = -1,
178  CODE_XML_TUZ
179  } vpXmlCodeType;
180 
181  typedef enum
182  {
184  SEQUENCE_ERROR
185  } vpXmlCodeSequenceType;
186 
187 private :
188 
190  std::string m_name;
191 
192 public:
193 
197 
198  // get/set functions
199  vpHomogeneousMatrix getHomogeneousMatrix() const {return this->m_M;}
200  std::string getHomogeneousMatrixName() const {return this->m_name;}
201 
202  vpXmlParserHomogeneousMatrix& operator =(const vpXmlParserHomogeneousMatrix& twinparser);
203  int parse(vpHomogeneousMatrix &M, const std::string &filename, const std::string &name);
204 
205  int save(const vpHomogeneousMatrix &M, const std::string &filename, const std::string &name);
206 
207  void setHomogeneousMatrixName(const std::string& name){
208  this->m_name = name;
209  }
210 
211 private:
212  int read (xmlDocPtr doc, xmlNodePtr node,
213  const std::string& name);
214 
215  int count (xmlDocPtr doc, xmlNodePtr node,
216  const std::string& name);
217 
218  int read_matrix (xmlDocPtr doc, xmlNodePtr node,
219  const std::string& name);
220 
221  vpXmlCodeSequenceType read_values (xmlDocPtr doc, xmlNodePtr node,
223 
224  static vpXmlCodeSequenceType str2xmlcode (char * str, vpXmlCodeType & res);
225  void myXmlReadIntChild (xmlDocPtr doc,
226  xmlNodePtr node,
227  int &res,
228  vpXmlCodeSequenceType &code_error);
229 
230  void myXmlReadDoubleChild (xmlDocPtr doc,
231  xmlNodePtr node,
232  double &res,
233  vpXmlCodeSequenceType &code_error);
234 
235  void myXmlReadCharChild (xmlDocPtr doc,
236  xmlNodePtr node,
237  char **res);
238  int write (xmlNodePtr node, const std::string& name);
239 
240 private:
241 
247  virtual void readMainClass(xmlDocPtr , xmlNodePtr ){};
248 
254  virtual void writeMainClass(xmlNodePtr ){};
255 
256 };
257 #endif //VISP_HAVE_XML2
258 #endif
void setHomogeneousMatrixName(const std::string &name)
Implementation of an homogeneous matrix and operations on such kind of matrices.
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:174
vpHomogeneousMatrix getHomogeneousMatrix() const
XML parser to load and save an homogeneous matrix in a file.
virtual void readMainClass(xmlDocPtr doc, xmlNodePtr node)=0
void parse(const std::string &filename)