class Exposer::Impl {
public:
- explicit Impl(Exposer& exposer, const std::string& path);
+ explicit Impl(Exposer& exposer, const std::string& path)
+ {
+ auto dispatcher = [&exposer](Message message) -> Message {
+ std::string function = message.signature;
+ auto iter = exposer.functorMap.find(function);
+ if (iter == exposer.functorMap.end())
+ THROW(ErrCode::RuntimeError) << "Faild to find function.";
- void start(void);
- void stop(void);
+ DEBUG(VIST) << "Remote method invokation: " << function;
-private:
- std::unique_ptr<Server> server;
-};
+ auto functor = iter->second;
+ auto result = functor->invoke(message.buffer);
-Exposer::Impl::Impl(Exposer& exposer, const std::string& path)
-{
- auto dispatcher = [&exposer](Message message) -> Message {
- std::string function = message.signature;
- auto iter = exposer.functorMap.find(function);
- if (iter == exposer.functorMap.end())
- THROW(ErrCode::RuntimeError) << "Faild to find function.";
+ Message reply(Message::Type::Reply, function);
+ reply.enclose(result);
- DEBUG(VIST) << "Remote method invokation: " << function;
+ return reply;
+ };
- auto functor = iter->second;
- auto result = functor->invoke(message.buffer);
+ this->server = std::make_unique<Server>(path, dispatcher);
+ }
- Message reply(Message::Type::Reply, function);
- reply.enclose(result);
+ inline void start()
+ {
+ this->server->run();
+ }
- return reply;
- };
-
- this->server = std::make_unique<Server>(path, dispatcher);
-}
+ inline void stop()
+ {
+ this->server->stop();
+ }
-void Exposer::Impl::start(void)
-{
- this->server->run();
-}
-
-void Exposer::Impl::stop(void)
-{
- this->server->stop();
-}
+private:
+ std::unique_ptr<Server> server;
+};
Exposer::Exposer(const std::string& path) : pImpl(new Impl(*this, path))
{
}
+Exposer::~Exposer() = default;
+
void Exposer::start(void)
{
this->pImpl->start();
this->pImpl->stop();
}
-void Exposer::ImplDeleter::operator()(Impl* ptr)
-{
- delete ptr;
-}
-
} // namespace rmi
} // namespace vist
class Exposer final {
public:
explicit Exposer(const std::string& path);
+ ~Exposer();
+
+ Exposer(const Exposer&) = delete;
+ Exposer& operator=(const Exposer&) = delete;
+
+ Exposer(Exposer&&) = default;
+ Exposer& operator=(Exposer&&) = default;
void start(void);
void stop(void);
private:
class Impl;
- struct ImplDeleter
- {
- void operator()(Impl*);
- };
klass::FunctorMap functorMap;
- std::unique_ptr<Impl, ImplDeleter> pImpl;
+ std::unique_ptr<Impl> pImpl;
};
template<typename O, typename F>
using namespace vist::transport;
-class Remote {
+class Remote final {
public:
explicit Remote(const std::string& path);
+ ~Remote();
+
+ Remote(const Remote&) = delete;
+ Remote& operator=(const Remote&) = delete;
+
+ Remote(Remote&&) = default;
+ Remote& operator=(Remote&&) = default;
template<typename R, typename... Args>
R invoke(const std::string& name, Args&&... args);
Message request(Message message);
class Impl;
- /// Let compiler know how to destroy Impl
- struct ImplDeleter
- {
- void operator()(Impl*);
- };
-
- std::unique_ptr<Impl, ImplDeleter> pImpl;
+ std::unique_ptr<Impl> pImpl;
};
template<typename R, typename... Args>