class renamed in coherence with library name.
+++ /dev/null
-// Copyright (C) 2004 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
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : LocalTrace_WaitForServerReadiness.cxx
-// Author : Paul RASCLE (EDF)
-// Module : KERNEL
-// $Header$
-
-#include "LocalTrace_WaitForServerReadiness.hxx"
-#include <iostream>
-#include <ctime>
-
-using namespace std;
-
-// ============================================================================
-/*!
- * Wait until a server is registered in naming service.
- * \param serverName name of the server to find.
- * When SALOME_NamingService is available,
- * use NamingService_WaitForServerReadiness instead.
- * This function is needed when macro MESSAGE used by SALOME_NamingService
- * is not available (inside LocalTrace methods, for instance !).
- * Direct access to CORBA Name Service. Look for serverName at Name service
- * Root without extensions.
- */
-// ============================================================================
-
-CORBA::Object_ptr LocalTrace_WaitForServerReadiness(CORBA::ORB_ptr orb,
- string serverName)
-{
- long TIMESleep = 250000000;
- int NumberOfTries = 40;
-
- timespec ts_req;
- ts_req.tv_nsec=TIMESleep;
- ts_req.tv_sec=0;
- timespec ts_rem;
- ts_rem.tv_nsec=0;
- ts_rem.tv_sec=0;
-
- CORBA::Object_var obj;
-
- try
- {
- // NB. You can't use SALOME_NamingService class because
- // it uses MESSAGE macro
- // Otherwise, you will get segmentation fault.
-
- CosNaming::NamingContext_var inc;
- CosNaming::Name name;
- name.length(1);
- name[0].id = CORBA::string_dup(serverName.c_str());
- CORBA::Object_var theObj;
-
- for (int itry=0; itry < NumberOfTries; itry++)
- {
- try
- {
- if(!CORBA::is_nil(orb))
- theObj = orb->resolve_initial_references("NameService");
- if (!CORBA::is_nil(theObj))
- inc = CosNaming::NamingContext::_narrow(theObj);
- }
- catch( CORBA::COMM_FAILURE& )
- {
- cout << "LocalTrace_WaitForServerReadiness: "
- << "CORBA::COMM_FAILURE: "
- << "Unable to contact the Naming Service" << endl;
- }
- catch(...)
- {
- cout << "LocalTrace_WaitForServerReadiness: "
- << "Unknown exception dealing with Naming Service" << endl;
- }
-
- if(!CORBA::is_nil(inc))
- {
- obj = inc->resolve(name);
- if (!CORBA::is_nil(obj))
- {
- cout << "LocalTrace_WaitForServerReadiness: "
- << serverName << " found in CORBA Name Service" << endl;
- break;
- }
- }
- int a = nanosleep(&ts_req,&ts_rem);
- cout << "LocalTrace_WaitForServerReadiness: retry look for"
- << serverName << endl;
- }
- }
- catch (const CosNaming::NamingContext::NotFound&)
- {
- cout << "Caught exception: Naming Service can't found Logger";
- }
- catch (CORBA::COMM_FAILURE&)
- {
- cout << "Caught CORBA::SystemException CommFailure.";
- }
- catch (CORBA::SystemException&)
- {
- cout << "Caught CORBA::SystemException.";
- }
- catch (CORBA::Exception&)
- {
- cout << "Caught CORBA::Exception.";
- }
- catch (...)
- {
- cout << "Caught unknown exception.";
- }
- return obj._retn();
-}
-
+++ /dev/null
-// Copyright (C) 2004 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
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : LocalTrace_WaitForServerReadiness.hxx
-// Author : Paul RASCLE (EDF)
-// Module : KERNEL
-// $Header$
-
-#ifndef _LOCALTRACE_WAITFORSERVERREADINESS_HXX_
-#define _LOCALTRACE_WAITFORSERVERREADINESS_HXX_
-
-#include <CORBA.h>
-#include <string>
-
-CORBA::Object_ptr LocalTrace_WaitForServerReadiness(CORBA::ORB_ptr theOrb,
- std::string serverName);
-
-#endif
# header files
EXPORT_HEADERS= SALOMETraceCollector.hxx \
- LocalTrace_WaitForServerReadiness.hxx
+ TraceCollector_WaitForServerReadiness.hxx
EXPORT_PYSCRIPTS =
LIB = libSALOMETraceCollector.la
LIB_SRC = SALOMETraceCollector.cxx \
- LocalTrace_WaitForServerReadiness.cxx
+ TraceCollector_WaitForServerReadiness.cxx
LIB_CLIENT_IDL = Logger.idl
LDFLAGS+=
using namespace std;
#include "SALOMETraceCollector.hxx"
-#include "LocalTrace_WaitForServerReadiness.hxx"
+#include "TraceCollector_WaitForServerReadiness.hxx"
//#include "SALOME_Log.hxx"
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(Logger)
// ============================================================================
/*!
+ * This class replaces LocalTraceCollector, which is to use outside SALOME,
+ * without CORBA.
+ *
* guarantees a unique object instance of the class (singleton thread safe)
* a separate thread for loop to print traces is launched.
* \param typeTrace 0=standard out, 1=file(/tmp/tracetest.log), 2=CORBA log
}
break;
case 2 : // --- trace collection via CORBA
- obj = LocalTrace_WaitForServerReadiness(_orb,"Logger");
+ obj = TraceCollector_WaitForServerReadiness(_orb,"Logger");
if (!CORBA::is_nil(obj))
m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj);
if (CORBA::is_nil(m_pInterfaceLogger))
#include <CORBA.h>
#include "LocalTraceBufferPool.hxx"
+//! See LocalTraceCollector instead of SALOMETraceCollector for usage without CORBA
+
class SALOMETraceCollector
{
public:
--- /dev/null
+// Copyright (C) 2004 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
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : TraceCollector_WaitForServerReadiness.cxx
+// Author : Paul RASCLE (EDF)
+// Module : KERNEL
+// $Header$
+
+#include "TraceCollector_WaitForServerReadiness.hxx"
+#include <iostream>
+#include <ctime>
+
+using namespace std;
+
+// ============================================================================
+/*!
+ * Wait until a server is registered in naming service.
+ * \param serverName name of the server to find.
+ * When SALOME_NamingService is available,
+ * use NamingService_WaitForServerReadiness instead.
+ * This function is needed when macro MESSAGE used by SALOME_NamingService
+ * is not available (inside LocalTrace methods, for instance !).
+ * Direct access to CORBA Name Service. Look for serverName at Name service
+ * Root without extensions.
+ */
+// ============================================================================
+
+CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr orb,
+ string serverName)
+{
+ long TIMESleep = 500000000;
+ int NumberOfTries = 40;
+
+ timespec ts_req;
+ ts_req.tv_nsec=TIMESleep;
+ ts_req.tv_sec=0;
+ timespec ts_rem;
+ ts_rem.tv_nsec=0;
+ ts_rem.tv_sec=0;
+
+ CORBA::Object_var obj;
+
+ try
+ {
+ // NB. You can't use SALOME_NamingService class because
+ // it uses MESSAGE macro
+ // Otherwise, you will get segmentation fault.
+
+ CosNaming::NamingContext_var inc;
+ CosNaming::Name name;
+ name.length(1);
+ name[0].id = CORBA::string_dup(serverName.c_str());
+ CORBA::Object_var theObj=CORBA::Object::_nil();
+
+ for (int itry=0; itry < NumberOfTries; itry++)
+ {
+ try
+ {
+ if(!CORBA::is_nil(orb))
+ theObj = orb->resolve_initial_references("NameService");
+ if (!CORBA::is_nil(theObj))
+ inc = CosNaming::NamingContext::_narrow(theObj);
+ }
+ catch( CORBA::COMM_FAILURE& )
+ {
+ cout << "TraceCollector_WaitForServerReadiness: "
+ << "CORBA::COMM_FAILURE: "
+ << "Unable to contact the Naming Service" << endl;
+ }
+ catch(...)
+ {
+ cout << "TraceCollector_WaitForServerReadiness: "
+ << "Unknown exception dealing with Naming Service" << endl;
+ }
+
+ obj=CORBA::Object::_nil();
+ if(!CORBA::is_nil(inc))
+ {
+ try
+ {
+ obj = inc->resolve(name);
+ if (!CORBA::is_nil(obj))
+ {
+ cout << "TraceCollector_WaitForServerReadiness: "
+ << serverName << " found in CORBA Name Service" << endl;
+ break;
+ }
+ }
+ catch (const CosNaming::NamingContext::NotFound&)
+ {
+ cout << "Caught exception: Naming Service can't found Logger";
+ }
+ }
+ int a = nanosleep(&ts_req,&ts_rem);
+ cout << "TraceCollector_WaitForServerReadiness: retry look for"
+ << serverName << endl;
+ }
+ }
+ catch (const CosNaming::NamingContext::NotFound&)
+ {
+ cout << "Caught exception: Naming Service can't found Logger";
+ }
+ catch (CORBA::COMM_FAILURE&)
+ {
+ cout << "Caught CORBA::SystemException CommFailure.";
+ }
+ catch (CORBA::SystemException&)
+ {
+ cout << "Caught CORBA::SystemException.";
+ }
+ catch (CORBA::Exception&)
+ {
+ cout << "Caught CORBA::Exception.";
+ }
+ catch (...)
+ {
+ cout << "Caught unknown exception.";
+ }
+ return obj._retn();
+}
+
--- /dev/null
+// Copyright (C) 2004 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
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : LocalTrace_WaitForServerReadiness.hxx
+// Author : Paul RASCLE (EDF)
+// Module : KERNEL
+// $Header$
+
+#ifndef _TRACECOLLECTOR_WAITFORSERVERREADINESS_HXX_
+#define _TRACECOLLECTOR_WAITFORSERVERREADINESS_HXX_
+
+#include <CORBA.h>
+#include <string>
+
+CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr theOrb,
+ std::string serverName);
+
+#endif