/* * Copyright 2014 Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef FRUIT_PROVIDER_DEFN_H #define FRUIT_PROVIDER_DEFN_H #include // Redundant, but makes KDevelop happy. #include namespace fruit { template inline Provider::Provider(fruit::impl::InjectorStorage* storage, fruit::impl::InjectorStorage::Graph::node_iterator itr) : storage(storage), itr(itr) {} template inline C* Provider::get() { return get(); } namespace impl { namespace meta { template struct ProviderImplHelper { template using CheckGet = Eval)), If(Not(IsSame(GetClassForType(Type), RemoveConstFromType(Type))), ConstructError(Id, Type), If(And(TypeInjectionRequiresNonConstBinding(Type), Not(IsSame(Id)>, Type))), ConstructError(TypeProvidedAsConstOnlyErrorTag, Type), None)))>; }; } // namespace meta } // namespace impl template template inline T Provider::get() { using E = typename fruit::impl::meta::ProviderImplHelper::template CheckGet; (void)typename fruit::impl::meta::CheckIfError::type(); return storage->template get(itr); } template template inline Provider::operator T() { return get(); } } // namespace fruit #endif // FRUIT_PROVIDER_DEFN_H