-// SALOME NamingService : wrapping NamingService services
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// SALOME NamingService : wrapping NamingService services
// File : SALOME_NamingService.cxx
// Author : Estelle Deville
// Module : SALOME
// $Header$
-
+//
#include "SALOME_NamingService.hxx"
#include "ServiceUnreachable.hxx"
#include <iostream>
#include <cstring>
#include <string>
+#include <cstdio>
using namespace std;
+/*! \class SALOME_NamingService
+ \brief A class to manage the SALOME naming service
+
+*/
+
// ============================================================================
/*! \brief Default Constructor without ORB reference.
*
SALOME_NamingService::SALOME_NamingService(CORBA::ORB_ptr orb)
{
MESSAGE("SALOME_NamingService creation");
- _orb = orb ;
+ _orb = CORBA::ORB::_duplicate(orb);
_initialize_root_context();
}
*
* Initializes ORB reference and naming service root context.
* For use after default constructor.
+ * If param orb is null, the orb is initialized
* \param orb CORBA::ORB_ptr arguments
*/
// ============================================================================
MESSAGE("SALOME_NamingService initialisation");
Utils_Locker lock (&_myMutex);
- _orb = orb;
+ if(orb)
+ _orb = CORBA::ORB::_duplicate(orb);
+ else
+ {
+ int argc=0;
+ _orb = CORBA::ORB_init(argc, 0); // Here we make the assumption that the orb has already been initialized
+ }
_initialize_root_context();
}
CosNaming::Name context_name;
vector<string> splitPath;
- int dimension_resultat = _createContextNameDir(Path,
+ _createContextNameDir(Path,
context_name,
splitPath,
false);
else
{
SCRUTE(name);
- if (Change_Directory(name.c_str()))
+ string basename = name;
+ if (Change_Directory(basename.c_str()))
{
vector<string> contList = list_subdirs();
if ( !CORBA::is_nil(obj) )
return obj;
+ else
+ Change_Directory(basename.c_str());
}
}
return ret;
}
+string
+SALOME_NamingService::ContainerName(const Engines::ContainerParameters& params)
+{
+ int nbproc;
+
+ if ( !params.isMPI )
+ nbproc = 0;
+ else if ( (params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0) )
+ nbproc = 1;
+ else if ( params.resource_params.nb_node == 0 )
+ nbproc = params.resource_params.nb_proc_per_node;
+ else if ( params.resource_params.nb_proc_per_node == 0 )
+ nbproc = params.resource_params.nb_node;
+ else
+ nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node;
+
+ string ret = ContainerName(params.container_name);
+
+ if ( nbproc >= 1 )
+ {
+ char *suffix = new char[8];
+ sprintf(suffix, "_%d", nbproc);
+ ret += suffix;
+ }
+
+ return ret;
+}
+
// ============================================================================
/*! \brief build a string representing a container in Naming Service.
*
return ret;
}
+string
+SALOME_NamingService::
+BuildContainerNameForNS(const Engines::ContainerParameters& params,
+ const char *hostname)
+{
+ string ret = "/Containers/";
+ ret += hostname;
+ ret += "/";
+ ret += ContainerName(params);
+
+ return ret;
+}
+
// ============================================================================
/*! \brief search a name in current directory.
*
// SCRUTE(path);
CosNaming::Name context_name;
vector<string> splitPath;
- int dimension_resultat = _createContextNameDir(path.c_str(),
+ _createContextNameDir(path.c_str(),
context_name,
splitPath,
true);
return _orb->object_to_string(_root_context);
}
+/*! \brief get the orb used by the naming service
+ *
+ * \return the orb
+ */
+CORBA::ORB_ptr SALOME_NamingService::orb()
+{
+ return _orb;
+}
+