Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_Server.cxx
1 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOMEDS_Server.cxx
25 //  Author : Yves FRICAUD
26 //  Module : SALOME
27 //  $Header$
28
29 using namespace std;
30 #include <SALOMEconfig.h>
31 #include CORBA_SERVER_HEADER(SALOMEDS)
32 #include "SALOMEDS_StudyManager_i.hxx"
33 #include "utilities.h"
34
35 //#define CHECKTIME
36 #ifdef CHECKTIME
37 #include <Utils_Timer.hxx>
38 #endif
39
40 // extern "C"
41 // { // for ccmalloc memory debug
42 // void ccmalloc_static_initialization(void);
43 // }
44
45 ///////////////////////////// MAIN ///////////////////////////////////////
46 //////////////////////////////////////////////////////////////////////////
47 int main(int argc, char** argv)
48 {
49 //   ccmalloc_static_initialization();
50
51   MESSAGE("SALOMEDS_Server - main");
52   try {
53     // Initialise the ORB.
54     CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3");
55     omniORB::MaxMessageSize(100 * 1024 * 1024);
56     
57     // Obtain a reference to the root POA.
58     CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
59     PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
60
61
62     // We allocate the objects on the heap.  Since these are reference
63     // counted objects, they will be deleted by the POA when they are no
64     // longer needed.    
65     SALOMEDS_StudyManager_i * myStudyManager_i = new  SALOMEDS_StudyManager_i(orb);
66  
67     // Activate the objects.  This tells the POA that the objects are
68     // ready to accept requests.
69     PortableServer::ObjectId_var myStudyManager_iid = poa->activate_object(myStudyManager_i);
70     myStudyManager_i->register_name("/myStudyManager");
71        
72     // Obtain a POAManager, and tell the POA to start accepting
73     // requests on its objects.
74     PortableServer::POAManager_var pman = poa->the_POAManager();
75     pman->activate();
76
77 #ifdef CHECKTIME
78     Utils_Timer timer;
79     timer.Start();
80     timer.Stop();
81     MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
82     timer.ShowAbsolute();
83 #endif
84     orb->run();
85     orb->destroy();
86   }
87   catch(CORBA::SystemException&) {
88     MESSAGE( "Caught CORBA::SystemException." )
89   }
90   catch(CORBA::Exception&) {
91     MESSAGE( "Caught CORBA::Exception." )
92   }
93   catch(omniORB::fatalException& fe) {
94     MESSAGE( "Caught omniORB::fatalException:" )
95     MESSAGE( "  file: " << fe.file() )
96     MESSAGE( "  line: " << fe.line() )
97     MESSAGE( "  mesg: " << fe.errmsg() )
98   }
99   catch(...) {
100     MESSAGE( "Caught unknown exception." )
101   }
102   return 0;
103 }