Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
VectorConverterRegisterer.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 IFPEN-CEA
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 */
18
19/*!
20 * \file VectorConverterRegisterer.h
21 * \brief VectorConverterRegisterer.h
22 */
23#pragma once
24
25#include <alien/core/backend/IVectorConverter.h>
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace Alien
31{
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36/*!
37 * \ingroup core
38 * \brief Vector converter registerer
39 *
40 * Allows to register a vector converter to convert a vector from a format to another
41 */
42class ALIEN_EXPORT VectorConverterRegisterer
43{
44 public:
45 //! Type of the vector converter function
46 typedef IVectorConverter* (*ConverterCreateFunc)();
47
48 public:
49 /*!
50 * \brief Creates a vector converter registerer
51 * \param[in] func vector converter function
52 */
54
55 //! Free resources
57
58 public:
59 /*!
60 * \brief Get the converter from one vector format to another one
61 * \param[in] from Backend id of the source format
62 * \param[in] to Backend id of the target format
63 * \returns vector format converter
64 */
65 static IVectorConverter* getConverter(BackEndId from, BackEndId to);
66};
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
70
71} // namespace Alien
72
73/*---------------------------------------------------------------------------*/
74/*---------------------------------------------------------------------------*/
75
76/*!
77 * \brief Macro to register a vector converter
78 */
79#define REGISTER_VECTOR_CONVERTER(converter) \
80 extern "C++" Alien::IVectorConverter* alienCreateVectorConverter_##converter() \
81 { \
82 return new converter(); \
83 } \
84 Alien::VectorConverterRegisterer globaliVectorConverterRegisterer_##converter( \
85 alienCreateVectorConverter_##converter)
86
87/*---------------------------------------------------------------------------*/
88/*---------------------------------------------------------------------------*/
static IVectorConverter * getConverter(BackEndId from, BackEndId to)
Get the converter from one vector format to another one.
~VectorConverterRegisterer()=default
Free resources.
VectorConverterRegisterer(ConverterCreateFunc func)
Creates a vector converter registerer.
IVectorConverter *(* ConverterCreateFunc)()
Type of the vector converter function.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17