Back to index

salome-kernel  6.5.0
SALOME_TestComponent_i.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME TestContainer : test of container creation and its life cycle
00024 //  File   : SALOME_TestComponent_i.cxx
00025 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
00026 //  Module : SALOME
00027 //  $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/TestContainer/SALOME_TestComponent_i.cxx,v 1.10.2.1.10.2.12.1 2012-04-12 14:05:31 vsr Exp $
00028 //
00029 #ifndef WIN32
00030 # define private protected
00031 #endif
00032 #include "utilities.h"
00033 #include "SALOME_TestComponent_i.hxx"
00034 #include <stdio.h>
00035 #include <cstdlib>
00036 #include <map>
00037 
00038 Engines_TestComponent_i::Engines_TestComponent_i(CORBA::ORB_ptr orb,
00039                                                  PortableServer::POA_ptr poa,
00040                                                  PortableServer::ObjectId * contId, 
00041                                                  const char *instanceName, 
00042                                                  const char *interfaceName) :
00043   Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
00044 {
00045   MESSAGE("activate object");
00046   _thisObj = this ;
00047   _id = _poa->activate_object(_thisObj);
00048   //does not work with 4.0.6 (too bad)
00049   //SCRUTE(_pd_refCount);
00050   //SCRUTE(_refcount_value());
00051 }
00052 
00053 Engines_TestComponent_i::Engines_TestComponent_i()
00054 {
00055 }
00056 
00057 Engines_TestComponent_i::~Engines_TestComponent_i()
00058 {
00059   MESSAGE("~Engines_TestComponent_i()");
00060 }
00061 
00062 char* Engines_TestComponent_i::Coucou(CORBA::Long L)
00063 {
00064   char s[100];
00065   sprintf(s, "TestComponent_i : L = %ld", (long) L);
00066   //does not work with 4.0.6 (too bad)
00067   //SCRUTE(_pd_refCount);
00068   //SCRUTE(_refcount_value());
00069 
00070   return CORBA::string_dup(s);
00071 }
00072 
00073 void Engines_TestComponent_i::Setenv()
00074 {
00075   // bool overwrite = true;
00076   std::map<std::string,CORBA::Any>::iterator it;
00077   MESSAGE("set environment associated with keys in map _fieldsDict");
00078   for (it = _fieldsDict.begin(); it != _fieldsDict.end(); it++)
00079     {
00080       std::string cle((*it).first);
00081       if ((*it).second.type()->kind() == CORBA::tk_string)
00082         {
00083           const char* value;
00084           (*it).second >>= value;
00085           //CCRT porting : setenv not defined in stdlib.h
00086           std::string s(cle);
00087           s+='=';
00088           s+=value;
00089           //char* cast because 1st arg of linux putenv function is not a const char* !!!
00090           putenv((char *)s.c_str());
00091           //End of CCRT porting
00092           //int ret = setenv(cle.c_str(), value, overwrite);
00093           MESSAGE("--- setenv: "<<cle<<" = "<< value);
00094         }
00095     }
00096   MESSAGE("read environment associated with keys in map _fieldsDict");
00097   for (it = _fieldsDict.begin(); it != _fieldsDict.end(); it++)
00098     {
00099       std::string cle((*it).first);
00100       char* valenv= getenv(cle.c_str());
00101       if (valenv)
00102         MESSAGE("--- getenv: "<<cle<<" = "<< valenv);
00103     }
00104 }
00105 
00106 extern "C"
00107 {
00108   PortableServer::ObjectId * SalomeTestComponentEngine_factory(
00109                                  CORBA::ORB_ptr orb,
00110                                  PortableServer::POA_ptr poa, 
00111                                  PortableServer::ObjectId * contId,
00112                                  const char *instanceName, 
00113                                  const char *interfaceName)
00114   {
00115     MESSAGE("PortableServer::ObjectId * TestComponent_factory()");
00116     SCRUTE(interfaceName);
00117     Engines_TestComponent_i * myTestComponent 
00118       = new Engines_TestComponent_i(orb, poa, contId, instanceName, interfaceName);
00119     return myTestComponent->getId() ;
00120   }
00121 }
00122