Salome HOME
b52fa758d2ac2e712f5982d7daa12d6cadbe12e5
[modules/kernel.git] / src / Registry / RegistryService.hxx
1 //  SALOME Registry : Registry server implementation
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : RegistryService.hxx
25 //  Author : Pascale NOYRET - Antoine YESSAYAN, EDF
26 //  Module : SALOME
27 //  $Header$
28
29 # ifndef __RegistryService_h__
30 # define __RegistryService_h__
31
32 #include <SALOMEconfig.h>
33 #include CORBA_SERVER_HEADER(SALOME_Registry)
34
35 # include <map>
36
37 #if defined REGISTRY_EXPORTS
38 #if defined WIN32
39 #define REGISTRY_EXPORT __declspec( dllexport )
40 #else
41 #define REGISTRY_EXPORT
42 #endif
43 #else
44 #if defined WNT
45 #define REGISTRY_EXPORT __declspec( dllimport )
46 #else
47 #define REGISTRY_EXPORT
48 #endif
49 #endif
50
51 class REGISTRY_EXPORT RegistryService : public POA_Registry::Components  //, public PortableServer::RefCountServantBase
52 {
53
54 public :
55         enum Status { UNDEF=-1 , TERMINATED=0 , RUNNING=1 } ;
56
57         class client_infos
58         {
59         protected :
60                 const char* const       _ior;
61                 const char* const       _name;
62                 const long              _pid ;
63                 const char* const       _machine;
64                 const char* const       _adip;
65                 const long              _uid;
66                 const char* const       _pwname;
67                 const long              _ts_start ;
68                 const long              _difftime;
69                 const char* const       _cdir ;
70                       long              _ts_hello ;
71                       long              _ts_end ;
72                       Status            _status;
73         public :
74                 friend class RegistryService ;
75
76                 client_infos( const Registry::Infos &infos );
77                 ~client_infos();
78         }; 
79
80
81
82 public :
83         RegistryService(void);
84         virtual ~RegistryService(void);
85
86         void ping();
87         virtual CORBA::ULong add (const Registry::Infos & infos);
88         virtual CORBA::ULong size ( void );
89 #ifndef WNT
90         virtual void remove( const CORBA::ULong id );
91         virtual void hello( const CORBA::ULong id );
92 #else
93         virtual void remove( CORBA::ULong id );
94         virtual void hello( CORBA::ULong id );
95 #endif
96         virtual void end(void);
97
98         virtual Registry::AllInfos *getall(void);
99         virtual Registry::AllInfos *history(void);
100
101         void SessionName( const char *sessionName ) ;
102
103
104 protected :
105
106         const char              *_SessionName ;
107         int                      _Compteur ;
108         std::map<int,client_infos *>     _reg ;
109         std::map<int,client_infos *>     _fin ;
110
111         Registry::AllInfos* makeseq(std::map<int,client_infos *> &mymap );
112
113 } ;
114
115 # endif