1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author: Guillaume Boulant (EDF/R&D)
21 #ifndef __KERNEL_SERVICES_H__
22 #define __KERNEL_SERVICES_H__
24 #include "KernelHelpers.hxx"
26 #include "SALOMEconfig.h"
27 #include CORBA_SERVER_HEADER(SALOMEDS)
28 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
29 #include CORBA_SERVER_HEADER(SALOME_ContainerManager)
30 #include CORBA_CLIENT_HEADER(SALOME_Session)
31 #include CORBA_SERVER_HEADER(SALOME_Exception)
33 #include "SALOME_NamingService.hxx"
34 #include "SALOME_LifeCycleCORBA.hxx"
38 // ---------------------------------------------
39 // SALOME KERNEL main services
40 KERNELHELPERS_EXPORT CORBA::ORB_ptr getORB();
41 KERNELHELPERS_EXPORT SALOME_NamingService * getNamingService();
42 KERNELHELPERS_EXPORT SALOME_LifeCycleCORBA * getLifeCycleCORBA();
43 KERNELHELPERS_EXPORT SALOME::Session_ptr getSalomeSession();
44 KERNELHELPERS_EXPORT SALOMEDS::StudyManager_ptr getStudyManager();
45 KERNELHELPERS_EXPORT Engines::SalomeLauncher_ptr getSalomeLauncher();
46 KERNELHELPERS_EXPORT Engines::ResourcesManager_ptr getResourcesManager();
48 // ---------------------------------------------
49 // SALOME KERNEL services to deal with a SALOME study, SObject and
52 KERNELHELPERS_EXPORT SALOMEDS::Study_ptr getStudyById(int aStudyId);
53 KERNELHELPERS_EXPORT int getStudyId(SALOMEDS::Study_ptr study);
54 KERNELHELPERS_EXPORT CORBA::Object_ptr IORToObject(char * IOR);
55 KERNELHELPERS_EXPORT CORBA::Object_ptr SObjectToObject(SALOMEDS::SObject_ptr);
60 * This template function provides you with the servant (CORBA
61 * object narrowed to its interface) corresponding to the specified
62 * CORBA object (naked CORBA pointer).
64 template<class TInterface> typename TInterface::_var_type
65 ObjectToInterface(CORBA::Object_ptr object) {
66 if(!CORBA::is_nil(object))
67 return TInterface::_narrow(object);
68 return TInterface::_nil();
71 template<class TInterface> typename TInterface::_var_type
72 SObjectToInterface(SALOMEDS::SObject_ptr sobject) {
73 CORBA::Object_ptr object = SObjectToObject(sobject);
74 return ObjectToInterface<TInterface>(object);
77 // _MEM_: note that template functions have to be declared AND
78 // implemented in the header because they are not compiled in this
79 // library but in every client library that includes this header
80 // file. The effective compilation depends on the particular class
81 // used for TInterface.
83 // ---------------------------------------------
84 // To create a standard SALOME exception embedding a simple text
85 KERNELHELPERS_EXPORT SALOME::SALOME_Exception createSalomeException(const char * text);
90 // =============================================================
91 // SALOME Logger macros
92 // =============================================================
94 // We can use the macros defined by SALOMELocalTrace/utilities.h
95 #include "utilities.h"
96 #define SALOMELOG(msg) {MESS_BEGIN("[XSALOME]") << msg << MESS_END}
99 // This can help to LOG (or use in stream) the CORBA exceptions
100 // Ex: LOG("An exception occurs: "<<e) will log the data of the exception e
103 static std::ostream &
104 operator<<(std::ostream & os, const CORBA::Exception & e)
108 CORBA::TypeCode_var tc = tmp.type();
109 const char * p = tc->name ();
118 #endif // KERNEL_SERVICES