hpp-util  4.9.0
Debugging tools for the HPP project.
sequence.hh
Go to the documentation of this file.
1 // Copyright (c) 2014, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of hpp-manipulation-urdf.
5 // hpp-manipulation-urdf is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-manipulation-urdf is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-manipulation-urdf. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HPP_UTIL_FACTORIES_SEQUENCE_HH
18 # define HPP_UTIL_FACTORIES_SEQUENCE_HH
19 
20 # include "hpp/util/parser.hh"
21 
22 # include <vector>
23 
24 namespace hpp {
25  namespace util {
26  namespace parser {
29 
35  template <typename ValueType>
36  class SequenceFactory : public ObjectFactory {
37  public:
38  typedef std::vector <ValueType> OutType;
39  SequenceFactory (ObjectFactory* parent, const XMLElement* element, const unsigned int nbValue = 0) :
40  ObjectFactory (parent, element), size_ (nbValue)
41  {}
42 
43  virtual void addTextChild (const XMLText* text);
44 
45  const OutType& values () const
46  {
47  return values_;
48  }
49 
50  SequenceFactory (const std::string& tagName, ObjectFactory* parent = NULL)
51  : ObjectFactory (tagName, parent)
52  {}
53 
54  void values (const OutType& v)
55  {
56  values_ = v;
57  }
58 
59  protected:
60  virtual void impl_write (XMLElement* element) const;
61 
62  private:
63  std::vector <ValueType> values_;
64  unsigned int size_;
65  };
66 
68  } // namespace parser
69  } // namespace manipulation
70 } // namespace hpp
71 
72 #endif // HPP_UTIL_FACTORIES_SEQUENCE_HH
void values(const OutType &v)
Definition: sequence.hh:54
TiXmlText XMLText
Definition: parser.hh:36
Definition: assertion.hh:24
Class that catch XML Parser events for a specific tag and build the corresponding Object...
Definition: parser.hh:77
ObjectFactory * parent()
Definition: parser.cc:230
const OutType & values() const
Definition: sequence.hh:45
SequenceFactory(const std::string &tagName, ObjectFactory *parent=NULL)
Definition: sequence.hh:50
Factory parsing sequence of values.
Definition: sequence.hh:36
TiXmlElement XMLElement
Definition: parser.hh:31
std::string tagName() const
Definition: parser.cc:210
virtual void impl_write(XMLElement *element) const
Definition: sequence.cc:123
virtual void addTextChild(const XMLText *text)
Add Text child.
Definition: sequence.cc:97
SequenceFactory(ObjectFactory *parent, const XMLElement *element, const unsigned int nbValue=0)
Definition: sequence.hh:39
std::vector< ValueType > OutType
Definition: sequence.hh:38