Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
MatrixConverterRegisterer.cc
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
20/* Author : havep at Sat Nov 1 21:35:22 2014
21 * Generated by createNew
22 */
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27#include <vector>
28
29using namespace Alien;
30using namespace Arccore;
31
32namespace
33{ // Unnamed namespace for local "global" variables
34static std::vector<IMatrixConverter*>* matrix_converter_db = nullptr;
35}
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
41{
42 if (matrix_converter_db == 0)
43 matrix_converter_db = new std::vector<IMatrixConverter*>();
44 matrix_converter_db->push_back(func());
45}
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
52{
53 if (!matrix_converter_db) {
54 throw FatalErrorException(A_FUNCINFO, "There is no converter registered");
55 }
56
57 for (std::vector<IMatrixConverter*>::const_iterator i = matrix_converter_db->begin();
58 i != matrix_converter_db->end(); ++i) {
59 IMatrixConverter* c = *i;
60 if (c->sourceBackend() == from and c->targetBackend() == to) {
61 return c;
62 }
63 }
64 return nullptr;
65}
66
67/*---------------------------------------------------------------------------*/
68/*---------------------------------------------------------------------------*/
MatrixConverterRegisterer.h.
Matrices converter.
virtual BackEndId sourceBackend() const =0
Get the source backend id.
virtual BackEndId targetBackend() const =0
Get the target backend id.
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.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17