xmlRpcTreeItem.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, C. Dornhege, University of Freiburg
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * * Neither the name of the University of Freiburg nor the names
14  * of its contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef XML_RPC_TREE_ITEM_H
30 #define XML_RPC_TREE_ITEM_H
31 
32 #include <ros/ros.h>
33 #include <QVariant>
34 #include <deque>
35 using std::deque;
36 
38 
50 {
51  public:
55  XmlRpcTreeItem(XmlRpc::XmlRpcValue* data, XmlRpcTreeItem* parent, const std::string & path,
56  ros::NodeHandle* nh);
58 
59  XmlRpcTreeItem* parent() { return _parent; }
60 
61  unsigned int childCount() const;
62  XmlRpcTreeItem* child(unsigned int i) {
63  if(i >= _children.size())
64  return NULL;
65  return _children[i];
66  }
67  int childIndexOf(const XmlRpcTreeItem* child) const;
68 
70  int row() const;
71 
73  QVariant data(int row, int column) const;
75  bool isBool(int row, int column) const;
76 
78  bool setData(QVariant val);
79 
80  protected:
82  void createChildren();
83 
85  void addChild(const std::string & name, XmlRpc::XmlRpcValue* childData);
86 
88  QVariant xmlToVariant(XmlRpc::XmlRpcValue & val) const;
89 
91  void setParam();
92 
93  protected:
95 
97 
98  std::string _path;
99 
101 
102  deque<XmlRpcTreeItem*> _children;
103 };
104 
105 #endif
106 
QVariant xmlToVariant(XmlRpc::XmlRpcValue &val) const
Convert a XmlRpcValue to QVariant - only leaf values are supported.
A wrapper around the XmlRpcValue including a parent pointer and convenience functions for the qt mode...
XmlRpcTreeItem * parent()
bool setData(QVariant val)
set data for this item
void setParam()
write this XmlRpcValue to parameter server (for array childs).
deque< XmlRpcTreeItem * > _children
bool isBool(int row, int column) const
is the stored data a bool
void addChild(const std::string &name, XmlRpc::XmlRpcValue *childData)
Create a child from its data.
QVariant data(int row, int column) const
return the data in the map
int childIndexOf(const XmlRpcTreeItem *child) const
void createChildren()
Create all children based on data.
XmlRpc::XmlRpcValue * _data
XmlRpcTreeItem * child(unsigned int i)
int row() const
Figure out which row/nth child we are for the parent.
std::string _path
unsigned int childCount() const
ros::NodeHandle * _nh
XmlRpcTreeItem(XmlRpc::XmlRpcValue *data, XmlRpcTreeItem *parent, const std::string &path, ros::NodeHandle *nh)
XmlRpcTreeItem * _parent


qt_paramedit
Author(s): Christian Dornhege
autogenerated on Mon Feb 28 2022 23:37:51