$darkmode
xmagic.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2020 Robert Bosch GmbH
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  * SPDX-License-Identifier: Apache-2.0
17  */
36 #pragma once
37 
38 #include <type_traits> // for enable_if_t, is_base_of_v
39 
40 #include <fable/fable_fwd.hpp> // for Confable
41 #include <fable/schema/confable.hpp> // for FromConfable<>
42 #include <fable/schema/interface.hpp> // for make_prototype
43 
44 namespace fable::schema {
45 
46 template <typename T, std::enable_if_t<std::is_base_of_v<Confable, T>, int>>
47 auto make_prototype(std::string desc) {
48  return FromConfable<T>(std::move(desc));
49 }
50 
51 template <typename T, std::enable_if_t<!std::is_base_of_v<Confable, T>, int>>
52 auto make_prototype(std::string desc) {
53  return make_schema(static_cast<T*>(nullptr), std::move(desc));
54 }
55 
56 } // namespace fable::schema