Ariles
common.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4 
5  @copyright 2018-2020 Alexander Sherikov, Licensed under the Apache License, Version 2.0.
6  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
7 
8  @brief
9 */
10 
11 #pragma once
12 
13 
14 #include <ariles/visitors/ros.h>
15 
16 
17 // http://docs.ros.org/api/xmlrpcpp/html/classXmlRpc_1_1XmlRpcValue.html
18 #include <XmlRpcValue.h>
19 
20 
21 namespace ariles
22 {
23  namespace ns_ros
24  {
26 
27 
28  class ARILES_LIB_LOCAL ImplBase
29  {
30  public:
31  /// Stack of nodes.
32  std::vector<NodeWrapper> node_stack_;
33 
34  std::string root_name_;
35  XmlRpc::XmlRpcValue root_value_;
36 
37  ::ros::NodeHandle nh_;
38 
39 
40  public:
41  /**
42  * @brief Get current node
43  *
44  * @return pointer to the current node
45  */
46  XmlRpc::XmlRpcValue &getRawNode(const std::size_t depth)
47  {
48  if (node_stack_[depth].isArray())
49  {
50  return (getRawNode(depth - 1)[node_stack_[depth].index_]);
51  }
52  else
53  {
54  return (*node_stack_[depth].node_);
55  }
56  }
57 
58 
59  XmlRpc::XmlRpcValue &getRawNode()
60  {
61  return (getRawNode(node_stack_.size() - 1));
62  }
63  };
64  } // namespace ns_ros
65 } // namespace ariles
std::vector< NodeWrapper > node_stack_
Stack of nodes.
Definition: common.h:32
ariles::Node< XmlRpc::XmlRpcValue * > NodeWrapper
Definition: common.h:25
XmlRpc::XmlRpcValue & getRawNode()
Definition: common.h:59
::ros::NodeHandle nh_
Definition: common.h:37
std::string root_name_
Definition: common.h:34
XmlRpc::XmlRpcValue & getRawNode(const std::size_t depth)
Get current node.
Definition: common.h:46
XmlRpc::XmlRpcValue root_value_
Definition: common.h:35
Definition: basic.h:17