Salome HOME
dfcff2821a313fae51a5d1645c5c9435c889d87a
[modules/med.git] / src / MEDCouplingCorba / MEDCouplingFieldTemplateServant.cxx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #include "MEDCouplingFieldTemplateServant.hxx"
22 #include "MEDCouplingFieldTemplate.hxx"
23
24 #include "MEDCouplingMemArray.hxx"
25
26 using namespace MEDCoupling;
27
28 MEDCouplingFieldTemplateServant::MEDCouplingFieldTemplateServant(const MEDCouplingFieldTemplate *cppPointerOfMesh):MEDCouplingFieldServant(cppPointerOfMesh)
29 {
30 }
31
32 void MEDCouplingFieldTemplateServant::getTinyInfo(SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble_out da, SALOME_TYPES::ListOfString_out sa)
33 {
34   la=new SALOME_TYPES::ListOfLong;
35   std::vector<mcIdType> tinyInfo;
36   getPointer()->getTinySerializationIntInformation(tinyInfo);
37   la->length(tinyInfo.size());
38   for(int i=0;i<(int)tinyInfo.size();i++)
39     (*la)[i]=tinyInfo[i];
40   //
41   da=new SALOME_TYPES::ListOfDouble;
42   std::vector<double> tinyInfo2;
43   getPointer()->getTinySerializationDbleInformation(tinyInfo2);
44   da->length(tinyInfo2.size());
45   for(int i=0;i<(int)tinyInfo2.size();i++)
46     (*da)[i]=tinyInfo2[i];
47   //
48   sa=new SALOME_TYPES::ListOfString;
49   std::vector<std::string> tinyInfo3;
50   getPointer()->getTinySerializationStrInformation(tinyInfo3);
51   sa->length(tinyInfo3.size());
52   for(int i=0;i<(int)tinyInfo3.size();i++)
53     (*sa)[i]=CORBA::string_dup(tinyInfo3[i].c_str());
54 }
55
56 void MEDCouplingFieldTemplateServant::getSerialisationData(SALOME_TYPES::ListOfLong_out la)
57 {
58   DataArrayIdType *dataInt;
59   getPointer()->serialize(dataInt);
60   //
61   la=new SALOME_TYPES::ListOfLong;
62   if(dataInt)
63     {
64       mcIdType lgth=dataInt->getNbOfElems();
65       const mcIdType *ptr=dataInt->getConstPointer();
66       la->length(lgth);
67       for(mcIdType i=0;i<lgth;i++)
68         (*la)[i]=ptr[i];
69     }
70   else
71     la->length(0);
72 }
73
74 CORBA::Boolean MEDCouplingFieldTemplateServant::ExportDataAs(const char *format, SALOME::GenericObj_out exporter)
75 {
76   std::string frmCpp(format);
77   if(frmCpp=="MEDCorba")
78     {
79       exporter=getMesh();
80       return true;
81     }
82   return false;
83 }