Salome HOME
61cc0a61ee6890159b9a3b62a47222936fc8fc00
[modules/med.git] / src / MEDCouplingCorba / MEDCouplingFieldTemplateServant.cxx
1 // Copyright (C) 2007-2012  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.
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
20 #include "MEDCouplingFieldTemplateServant.hxx"
21 #include "MEDCouplingFieldTemplate.hxx"
22
23 #include "MEDCouplingMemArray.hxx"
24
25 using namespace ParaMEDMEM;
26
27 MEDCouplingFieldTemplateServant::MEDCouplingFieldTemplateServant(const MEDCouplingFieldTemplate *cppPointerOfMesh):MEDCouplingFieldServant(cppPointerOfMesh)
28 {
29 }
30
31 void MEDCouplingFieldTemplateServant::getTinyInfo(SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble_out da, SALOME_TYPES::ListOfString_out sa)
32 {
33   la=new SALOME_TYPES::ListOfLong;
34   std::vector<int> tinyInfo;
35   getPointer()->getTinySerializationIntInformation(tinyInfo);
36   la->length(tinyInfo.size());
37   for(int i=0;i<(int)tinyInfo.size();i++)
38     (*la)[i]=tinyInfo[i];
39   //
40   da=new SALOME_TYPES::ListOfDouble;
41   std::vector<double> tinyInfo2;
42   getPointer()->getTinySerializationDbleInformation(tinyInfo2);
43   da->length(tinyInfo2.size());
44   for(int i=0;i<(int)tinyInfo2.size();i++)
45     (*da)[i]=tinyInfo2[i];
46   //
47   sa=new SALOME_TYPES::ListOfString;
48   std::vector<std::string> tinyInfo3;
49   getPointer()->getTinySerializationStrInformation(tinyInfo3);
50   sa->length(tinyInfo3.size());
51   for(int i=0;i<(int)tinyInfo3.size();i++)
52     (*sa)[i]=CORBA::string_dup(tinyInfo3[i].c_str());
53 }
54
55 void MEDCouplingFieldTemplateServant::getSerialisationData(SALOME_TYPES::ListOfLong_out la)
56 {
57   DataArrayInt *dataInt;
58   getPointer()->serialize(dataInt);
59   //
60   la=new SALOME_TYPES::ListOfLong;
61   if(dataInt)
62     {
63       int lgth=dataInt->getNbOfElems();
64       const int *ptr=dataInt->getConstPointer();
65       la->length(lgth);
66       for(int i=0;i<lgth;i++)
67         (*la)[i]=ptr[i];
68     }
69   else
70     la->length(0);
71 }
72
73 CORBA::Boolean MEDCouplingFieldTemplateServant::ExportDataAs(const char *format, SALOME::GenericObj_out exporter)
74 {
75   std::string frmCpp(format);
76   if(frmCpp=="MEDCorba")
77     {
78       exporter=getMesh();
79       return true;
80     }
81   return false;
82 }