blob: 1f452dc4c7d555e627816e8f7cccb90e110114c0 [file] [log] [blame]
Marco Polettia5f49d42014-06-29 10:41:12 +01001/*
2 * Copyright 2014 Google Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Marco Poletti7f35b652014-11-01 10:11:37 +000017#ifndef FRUIT_PROVIDER_DEFN_H
18#define FRUIT_PROVIDER_DEFN_H
Marco Polettia5f49d42014-06-29 10:41:12 +010019
Marco Polettifdbfcbe2014-08-31 08:57:47 +010020#include "injector_storage.h"
Marco Polettia5f49d42014-06-29 10:41:12 +010021
22// Redundant, but makes KDevelop happy.
23#include "../provider.h"
24
25namespace fruit {
26
27template <typename... P>
Marco Poletti59946a82014-09-07 19:56:35 +010028inline Provider<P...>::Provider(fruit::impl::InjectorStorage* storage)
Marco Polettia5f49d42014-06-29 10:41:12 +010029 : storage(storage) {
30}
31
32template <typename... P>
33template <typename T>
Marco Poletti59946a82014-09-07 19:56:35 +010034inline T Provider<P...>::get() {
Marco Poletti4406e322014-10-04 10:53:59 +010035 FruitDelegateCheck(fruit::impl::TypeNotProvidedError<T, fruit::impl::is_in_list<impl::GetClassForType<T>, typename Comp::Ps>::value>);
Marco Polettia5f49d42014-06-29 10:41:12 +010036 return storage->template get<T>();
37}
38
39template <typename... P>
40template <typename T>
Marco Poletti59946a82014-09-07 19:56:35 +010041inline Provider<P...>::operator T() {
Marco Polettia5f49d42014-06-29 10:41:12 +010042 return get<T>();
43}
44
45
46} // namespace fruit
47
48
Marco Poletti7f35b652014-11-01 10:11:37 +000049#endif // FRUIT_PROVIDER_DEFN_H