Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpXmlParserHomogeneousMatrix.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 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 
163 class VISP_EXPORT vpXmlParserHomogeneousMatrix: public vpXmlParser
164 {
165 
166 public:
167 
168  /* --- XML Code------------------------------------------------------------ */
169  typedef enum
170  {
171  CODE_XML_BAD = -1,
181  CODE_XML_TUZ
182  } vpXmlCodeType;
183 
184  typedef enum
185  {
187  SEQUENCE_ERROR
188  } vpXmlCodeSequenceType;
189 
190 private :
191 
193  std::string m_name;
194 
195 public:
196 
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)
virtual ~vpXmlParserHomogeneousMatrix()
Default destructor.
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:175
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)