/*
* \brief Compile-time-defined parent-service registry
* \author Norman Feske
* \date 2017-01-23
*
* Child-management utilities such as 'Slave::Policy' take a registry of
* permitted parent services as construction argument. As a special form of
* such a registry, a 'Static_parent_services' object is statically defined at
* compile time instead of populated during runtime. It thereby allows the
* creation of a parent-service registry without the need for dynamic memory
* allocations if the types of the registered services are known at compile
* time.
*/
/*
* Copyright (C) 2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _INCLUDE__OS__STATIC_PARENT_SERVICES_H_
#define _INCLUDE__OS__STATIC_PARENT_SERVICES_H_
#include
#include
namespace Genode { template class Static_parent_services; }
template
class Genode::Static_parent_services : public Registry >
{
private:
template
struct Service_recursive;
template
struct Service_recursive
{
Registered service;
Service_recursive tail;
Service_recursive(Env &env, Registry > ®istry)
: service(registry, env, HEAD::service_name()), tail(env, registry) { }
};
template
struct Service_recursive
{
Registered service;
Service_recursive(Env &env, Registry > ®istry)
: service(registry, env, LAST::service_name()) { }
};
Service_recursive _service_recursive;
public:
Static_parent_services(Env &env) : _service_recursive(env, *this) { }
};
#endif /* _INCLUDE__OS__STATIC_PARENT_SERVICES_H_ */