/*
* Copyright © 2016 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef TESTING_BLOCKING_CONNECTOR_H_
#define TESTING_BLOCKING_CONNECTOR_H_
#include
#include
#include
#include
#include
namespace testing
{
/// @brief BlockingConnector is a messaging::Connector implementation
/// that simply blocks in its run() impl. until stop() is called.
class BlockingConnector : public messaging::Connector
{
public:
const messaging::Enumerator& parameters() const override;
std::shared_ptr request_connection(
const std::shared_ptr& connection_observer,
const std::shared_ptr& messaging_observer,
const std::shared_ptr& presence_observer,
const messaging::Dictionary&) override;
void run() override;
void stop() override;
bool network_monitor_enabled() override;
private:
std::mutex m;
std::condition_variable cv;
bool stop_requested{false};
messaging::StdVectorEnumerator params;
};
}
#endif // TESTING_BLOCKING_CONNECTOR_H_