genode/repos/os/include/os/single_session_service.h
Norman Feske b44f0554bd Adapt high-level components to new parent API
This patch adjusts the various users of the 'Child' API to the changes
on the account of the new non-blocking parent interface. It also removes
the use of the no-longer-available 'Connection::KEEP_OPEN' feature.

With the adjustment, we took the opportunity to redesign several
components to fit the non-blocking execution model much better, in
particular the demo applications.

Issue #2120
2016-11-30 13:37:03 +01:00

62 lines
1.5 KiB
C++

/*
* \brief Utility for implementing a local service with a single session
* \author Norman Feske
* \date 2014-02-14
*/
/*
* Copyright (C) 2014 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__OS__SINGLE_SESSION_SERVICE_H_
#define _INCLUDE__OS__SINGLE_SESSION_SERVICE_H_
/* Genode includes */
#include <base/service.h>
namespace Genode { template <typename> class Single_session_service; }
template <typename SESSION>
class Genode::Single_session_service
{
public:
typedef Capability<SESSION> Session_capability;
private:
/*
* Wrap client object to be compabile with 'Rpc_object::cap' calls
*
* We hand out the capability via 'cap' method to be compatible with
* the interface normally provided by server-side component objects.
* The 'Single_session_factory' requests the capability via this
* method.
*/
struct Client : SESSION::Client
{
Client(Session_capability cap) : SESSION::Client(cap) { }
Session_capability cap() const { return *this; }
};
typedef Local_service<Client> Service;
typedef typename Service::Single_session_factory Factory;
Client _client;
Factory _factory { _client };
Service _service { _factory };
public:
Single_session_service(Session_capability cap) : _client(cap) { }
Service &service() { return _service; }
};
#endif /* _INCLUDE__OS__SINGLE_SESSION_SERVICE_H_ */