1 /*
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
17 #ifndef FRUIT_NORMALIZED_COMPONENT_INLINES_H
18 #define FRUIT_NORMALIZED_COMPONENT_INLINES_H
19
20 #include <fruit/normalized_component.h>
21
22 #include <fruit/component.h>
23 #include <fruit/impl/util/type_info.h>
24
25 namespace fruit {
26
27 template <typename... Params>
28 template <typename... FormalArgs, typename... Args>
NormalizedComponent(Component<Params...> (* getComponent)(FormalArgs...),Args &&...args)29 inline NormalizedComponent<Params...>::NormalizedComponent(Component<Params...> (*getComponent)(FormalArgs...),
30 Args&&... args)
31 : NormalizedComponent(std::move(fruit::Component<Params...>(
32 fruit::createComponent().install(getComponent, std::forward<Args>(args)...))
33 .storage),
34 fruit::impl::MemoryPool()) {}
35
36 template <typename... Params>
NormalizedComponent(fruit::impl::ComponentStorage && storage,fruit::impl::MemoryPool memory_pool)37 inline NormalizedComponent<Params...>::NormalizedComponent(fruit::impl::ComponentStorage&& storage,
38 fruit::impl::MemoryPool memory_pool)
39 : storage(std::move(storage),
40 fruit::impl::getTypeIdsForList<typename fruit::impl::meta::Eval<fruit::impl::meta::SetToVector(
41 typename fruit::impl::meta::Eval<fruit::impl::meta::ConstructComponentImpl(
42 fruit::impl::meta::Type<Params>...)>::Ps)>>(memory_pool),
43 memory_pool, fruit::impl::NormalizedComponentStorageHolder::WithUndoableCompression()) {}
44
45 } // namespace fruit
46
47 #endif // FRUIT_NORMALIZED_COMPONENT_INLINES_H
48