##

RestApi.hh
Go to the documentation of this file.
/*
* copyright (C) 2015 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_PLUGINS_REST_WEB_RESTAPI_HH_
#define GAZEBO_PLUGINS_REST_WEB_RESTAPI_HH_
#include <string>
#include <list>
#include <mutex>
#include <gazebo/common/Console.hh>
#include "RestException.hh"
namespace gazebo
{
class RestApi
{
public: RestApi();
public: virtual ~RestApi();
public: std::string Login(const std::string &_url,
const std::string &_route,
const std::string &_user,
const std::string &_pass);
public: void Logout();
public: void PostJsonData(const char *_route, const char *_json);
public: std::string GetUser() const;
private: std::string Request(const std::string &_requestUrl,
const std::string &_postStr);
private: void SendUnpostedPosts();
private: std::string url;
private: std::string user;
private: std::string pass;
private: std::string loginRoute;
private: bool isLoggedIn;
private: struct Post
{
std::string route;
std::string json;
};
private: std::list<Post> posts;
private: std::mutex postsMutex;
};
}
#endif
gazebo::RestApi::Login
std::string Login(const std::string &_url, const std::string &_route, const std::string &_user, const std::string &_pass)
Connects to the REST service.
gazebo::RestApi::Logout
void Logout()
Stops sending messages to the REST service.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
RestException.hh
Console.hh
gazebo::RestApi::~RestApi
virtual ~RestApi()
Destructor.
gazebo::RestApi::RestApi
RestApi()
Constructor.
gazebo::RestApi
REST interface.
Definition: RestApi.hh:32
gazebo::RestApi::PostJsonData
void PostJsonData(const char *_route, const char *_json)
Notify the service with a http POST.
gazebo::RestApi::GetUser
std::string GetUser() const
Returns the username.