RestWebPlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 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_PLUGINS_REST_WEB_RESTWEBPLUGIN_HH_
19 #define GAZEBO_PLUGINS_REST_WEB_RESTWEBPLUGIN_HH_
20 
21 #include <list>
22 #include <mutex>
23 #include <vector>
24 #include <string>
25 #include <thread>
26 
27 #include <gazebo/gazebo.hh>
28 #include <gazebo/physics/physics.hh>
29 
30 #include "RestApi.hh"
31 
32 namespace gazebo
33 {
37  {
39  public: RestWebPlugin();
40 
42  public: virtual ~RestWebPlugin();
43 
47  public: virtual void Load(int _argc, char **_argv);
48 
51  public: void OnRestLoginRequest(ConstRestLoginPtr &_msg);
52 
55  public: void OnRestLogoutRequest(ConstRestLogoutPtr &_msg);
56 
59  public: void OnEventRestPost(ConstRestPostPtr &_msg);
60 
63  public: void OnSimEvent(ConstSimEventPtr &_msg);
64 
66  private: virtual void Init();
67 
69  private: void RunRequestQ();
70 
73  private: void ProcessLoginRequest(ConstRestLoginPtr _msg);
74 
76  private: gazebo::transport::NodePtr node;
77 
79  private: gazebo::transport::SubscriberPtr subLogin;
80 
82  private: gazebo::transport::SubscriberPtr subLogout;
83 
85  private: gazebo::transport::SubscriberPtr subEvent;
86 
88  private: gazebo::transport::SubscriberPtr subSimEvent;
89 
92 
94  private: std::vector<event::ConnectionPtr> connections;
95 
97  private: RestApi restApi;
98 
100  private: bool stopMsgProcessing;
101 
103  private: std::list<boost::shared_ptr<const gazebo::msgs::RestLogin>>
104  msgLoginQ;
105 
107  private: std::thread *requestQThread;
108 
110  private: std::mutex requestQMutex;
111 
113  private: std::string session;
114  };
115 }
116 
117 #endif
REST web plugin.
Definition: RestWebPlugin.hh:36
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
REST interface.
Definition: RestApi.hh:32
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:318
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