Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
VectorConverterRegisterer.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
29namespace
30{
31static std::vector<Alien::IVectorConverter*>* vector_converter_db = nullptr;
32}
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37namespace Alien
38{
39
40using namespace Arccore;
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
46{
47 if (!vector_converter_db)
48 vector_converter_db = new std::vector<IVectorConverter*>();
49 vector_converter_db->push_back(func());
50}
51
52/*---------------------------------------------------------------------------*/
53/*---------------------------------------------------------------------------*/
54
56VectorConverterRegisterer::getConverter(BackEndId from, BackEndId to)
57{
58 if (!vector_converter_db) {
59 throw FatalErrorException(A_FUNCINFO, "There is no converter registered");
60 }
61
62 for (std::vector<IVectorConverter*>::const_iterator i = vector_converter_db->begin();
63 i != vector_converter_db->end(); ++i) {
64 IVectorConverter* c = *i;
65 if (c->sourceBackend() == from and c->targetBackend() == to) {
66 return c;
67 }
68 }
69 return nullptr;
70}
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
75} // namespace Alien
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
VectorConverterRegisterer.h.
virtual BackEndId targetBackend() const =0
Get the target backend id.
virtual BackEndId sourceBackend() const =0
Get the source backend id.
static IVectorConverter * getConverter(BackEndId from, BackEndId to)
Get the converter from one vector format to another one.
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