RestWebPlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef _GAZEBO_REST_WEB_PLUGIN_HH_
19 #define _GAZEBO_REST_WEB_PLUGIN_HH_
20 
21 #include <list>
22 #include <vector>
23 #include <string>
24 
25 #include <gazebo/gazebo.hh>
26 #include <gazebo/physics/physics.hh>
27 
28 #include "RestApi.hh"
29 
30 namespace gazebo
31 {
35  {
37  public: RestWebPlugin();
38 
40  public: virtual ~RestWebPlugin();
41 
45  public: virtual void Load(int _argc, char **_argv);
46 
49  public: void OnRestLoginRequest(ConstRestLoginPtr &_msg);
50 
53  public: void OnRestLogoutRequest(ConstRestLogoutPtr &_msg);
54 
57  public: void OnEventRestPost(ConstRestPostPtr &_msg);
58 
61  public: void OnSimEvent(ConstSimEventPtr &_msg);
62 
64  private: virtual void Init();
65 
67  private: void RunRequestQ();
68 
71  private: void ProcessLoginRequest(ConstRestLoginPtr _msg);
72 
74  private: gazebo::transport::NodePtr node;
75 
77  private: gazebo::transport::SubscriberPtr subLogin;
78 
80  private: gazebo::transport::SubscriberPtr subLogout;
81 
83  private: gazebo::transport::SubscriberPtr subEvent;
84 
86  private: gazebo::transport::SubscriberPtr subSimEvent;
87 
90 
92  private: std::vector<event::ConnectionPtr> connections;
93 
95  private: RestApi restApi;
96 
98  private: bool stopMsgProcessing;
99 
101  private: std::list<boost::shared_ptr<const gazebo::msgs::RestLogin>>
102  msgLoginQ;
103 
105  private: boost::thread *requestQThread;
106 
108  private: boost::mutex requestQMutex;
109 
111  private: std::string session;
112  };
113 }
114 
115 #endif
116 
117 
REST web plugin.
Definition: RestWebPlugin.hh:34
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
REST interface.
Definition: RestApi.hh:31
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
A plugin loaded within the gzserver on startup.
Definition: Plugin.hh:303
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:59