#include <iostream>
#include <cstring>
#include <string>
+#include <cstdio>
using namespace std;
*
* 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 = CORBA::ORB::_duplicate(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();
}
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.
*
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;
+}
+