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