Salome HOME
bos #26460 Add SSL mode
[samples/atomsolv.git] / src / ATOMSOLV / ATOMSOLV.cxx
1 // Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
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
20 #include "ATOMSOLV.hxx"
21 #include "ATOMSOLV_version.h"
22 #include "utilities.h"
23
24 #include <string>
25
26 using namespace std;
27
28
29 ATOMSOLV_Abstract::ATOMSOLV_Abstract(CORBA::ORB_ptr orb,
30         PortableServer::POA_ptr poa,
31         PortableServer::ObjectId * contId, 
32         const char *instanceName, 
33         const char *interfaceName,
34   bool withRegistry) :
35   Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, withRegistry)
36 {
37   MESSAGE("activate object");
38   _thisObj = this ;
39   _id = _poa->activate_object(_thisObj);
40   myData = new ATOMSOLV_ORB::TMoleculeList();
41 }
42
43 ATOMSOLV_Abstract::~ATOMSOLV_Abstract()
44 {
45 }
46
47 CORBA::Boolean ATOMSOLV_Abstract::setData( const ATOMSOLV_ORB::TMoleculeList& theData )
48 {
49   const int n = theData.length();
50   ATOMSOLV_ORB::TMoleculeList_var data = new ATOMSOLV_ORB::TMoleculeList();
51   data->length( n );
52   for ( int i = 0; i < n; i++ )
53     data[ i ] = theData[ i ];
54
55   //  printf( " -- ATOMSOLV::setData() length = %d\n", data->length() );
56   myData = data._retn();
57
58   return (bool)n;
59 }
60
61 CORBA::Boolean ATOMSOLV_Abstract::getData( ATOMSOLV_ORB::TMoleculeList_out outData )
62 {
63   ATOMSOLV_ORB::TMoleculeList* data = myData;
64   //    printf( " -- ATOMSOLV_Abstract::getData() length = %d\n", data->length() );
65   const int n = data->length();
66   outData = new ATOMSOLV_ORB::TMoleculeList();
67   outData->length( n );
68   for ( int i = 0; i < n; i++ )
69     (*outData)[ i ] = (*data)[ i ];
70   return true;
71 }
72
73 CORBA::Boolean ATOMSOLV_Abstract::processData()
74 {
75   ATOMSOLV_ORB::TMoleculeList* data = myData;
76   for ( int i = 0, n = data->length(); i < n; i++ )
77     (*data)[i].temperature = rand();
78   return true;
79 }
80
81 char* ATOMSOLV_Abstract::getVersion()
82 {
83 #if defined(ATOMSOLV_DEVELOPMENT)
84   return CORBA::string_dup(ATOMSOLV_VERSION_STR"dev");
85 #else
86   return CORBA::string_dup(ATOMSOLV_VERSION_STR);
87 #endif
88 }
89
90 extern "C"
91 {
92   PortableServer::ObjectId * ATOMSOLVEngine_factory(
93                                CORBA::ORB_ptr orb,
94                                PortableServer::POA_ptr poa, 
95                                PortableServer::ObjectId * contId,
96                                const char *instanceName, 
97                                const char *interfaceName)
98   {
99     MESSAGE("PortableServer::ObjectId * ATOMSOLVEngine_factory()");
100     SCRUTE(interfaceName);
101     ATOMSOLV_Session * myATOMSOLV 
102       = new ATOMSOLV_Session(orb, poa, contId, instanceName, interfaceName);
103     return myATOMSOLV->getId() ;
104   }
105 }