1 // SALOME DataTypeCatalog : catalog of data types
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOME_DataTypeCatalog_Server.cxx
25 // Author : Estelle Deville
30 #include "SALOME_NamingService.hxx"
31 #include "SALOME_DataTypeCatalog_impl.hxx"
32 #include "utilities.h"
33 #include "SALOMETraceCollector.hxx"
34 #include "Utils_SINGLETON.hxx"
37 int main(int argc,char **argv)
40 CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv);
41 SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
44 CosNaming::NamingContext_var _rootContext, catalogContext;
47 long TIMESleep = 250000000;
48 int NumberOfTries = 40;
51 ts_req.tv_nsec=TIMESleep;
56 CosNaming::NamingContext_var inc;
57 PortableServer::POA_var poa;
58 CORBA::Object_var theObj;
59 CORBA::Object_var obj;
60 CORBA::Object_var object;
61 int DATA_TYPE_CATALOG=0;
62 const char * Env = getenv("USE_LOGGER");
64 if ((Env!=NULL) && (strlen(Env)))
68 name[0].id=CORBA::string_dup("Logger");
69 PortableServer::POAManager_var mgr;
71 for (int i = 1; i<=NumberOfTries; i++)
74 a=nanosleep(&ts_req,&ts_rem);
77 obj = orb->resolve_initial_references("RootPOA");
78 if(!CORBA::is_nil(obj))
79 poa = PortableServer::POA::_narrow(obj);
80 if(!CORBA::is_nil(poa))
81 mgr = poa->the_POAManager();
82 if(!CORBA::is_nil(orb))
83 theObj = orb->resolve_initial_references("NameService");
84 if (!CORBA::is_nil(theObj))
85 inc = CosNaming::NamingContext::_narrow(theObj);}
86 catch( CORBA::COMM_FAILURE& )
88 MESSAGE( "Data Type Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" );
90 if(!CORBA::is_nil(inc))
92 MESSAGE( "Data Type Catalog: Naming Service was found" );
95 CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ;
96 SALOME_NamingService &NS = *SINGLETON_<SALOME_NamingService>::Instance() ;
98 for(int j=1; j<=NumberOfTries; j++)
101 a=nanosleep(&ts_req, &ts_rem);
104 object = inc->resolve(name);
106 catch(CosNaming::NamingContext::NotFound)
108 MESSAGE( "Data Type Catalog: Logger Server wasn't found" );
112 MESSAGE( "Data Type Catalog: Unknown exception" );
114 if (!CORBA::is_nil(object))
116 MESSAGE( "Data Type Catalog: Logger Server was found" );
124 if ((DATA_TYPE_CATALOG==1)||((EnvL==0)&&(!CORBA::is_nil(inc))))
130 SALOME_DataTypeCatalogImpl* Catalogue_i = new SALOME_DataTypeCatalogImpl(argc, argv);
131 poa->activate_object (Catalogue_i);
136 CORBA::Object_ptr myCata = Catalogue_i->_this();
138 // initialise Naming Service
139 SALOME_NamingService *_NS;
140 _NS = new SALOME_NamingService(orb);
141 // register Catalog in Naming Service
142 _NS->Register(myCata ,"/Kernel/DataTypeCatalog");
144 MESSAGE("Running DataType Catalog Server.")
151 catch(CORBA::SystemException&) {
152 INFOS("Caught CORBA::SystemException.")
154 catch(CORBA::Exception&) {
155 INFOS("Caught CORBA::Exception.")
158 delete myThreadTrace;