Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/kernel.git] / src / ModuleCatalog / SALOME_ModuleCatalog_impl.hxx
1 //  SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules
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   : SALOME_ModuleCatalog_impl.hxx
25 //  Author : Estelle Deville
26 //  Module : SALOME
27 //  $Header$
28
29
30 #ifndef MODULECATALOG_IMPL_H
31 #define MODULECATALOG_IMPL_H
32
33 #include <string>
34 #include <map>
35
36 #include "SALOME_ModuleCatalog_Handler.hxx"
37
38 #include <SALOMEconfig.h>
39 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
40
41
42 #if defined MODULECATALOG_EXPORTS
43 #if defined WIN32
44 #define MODULECATALOG_EXPORT __declspec( dllexport )
45 #else
46 #define MODULECATALOG_EXPORT
47 #endif
48 #else
49 #if defined WNT
50 #define MODULECATALOG_EXPORT __declspec( dllimport )
51 #else
52 #define MODULECATALOG_EXPORT
53 #endif
54 #endif
55
56 class MODULECATALOG_EXPORT SALOME_ModuleCatalogImpl: public POA_SALOME_ModuleCatalog::ModuleCatalog,
57                                 public PortableServer::RefCountServantBase 
58 {
59 public:
60   //! standard constructor
61   SALOME_ModuleCatalogImpl(int artgc, char** argv, CORBA::ORB_ptr orb = NULL);
62
63   //! standard destructor
64   virtual ~SALOME_ModuleCatalogImpl();
65
66   //! method to get a component list
67   /*!
68     \return a component list 
69   */
70   virtual SALOME_ModuleCatalog::ListOfComputers* GetComputerList();
71
72   //! method to get the PathPrefix of a computer
73  /*! If the wanted computer doesn't exist, the Notfound exception is thrown
74    \param machinename const char* arguments 
75    \return the prefix path
76  */
77   virtual char* GetPathPrefix(const char* machinename);
78
79   //! method to read a XML file and import new components into the component list
80  /*! If the XML file doesn't exist or is not readable, the Notfound exception is thrown
81    \param  const char* xmlFileName 
82  */
83   virtual void ImportXmlCatalogFile(const char* xmlFileName);
84
85   //! method to get a component list
86   /*!
87     \return a component list 
88   */
89   virtual SALOME_ModuleCatalog::ListOfComponents* GetComponentList();
90
91   //! method to get a component list of component name and component icone
92   /*!
93     \return a list of couple (component name, component icone) 
94   */
95   virtual SALOME_ModuleCatalog::ListOfIAPP_Affich* GetComponentIconeList();
96
97   //! method to get a component list of a wanted type
98   /*!
99     \return a component list 
100   */
101   virtual SALOME_ModuleCatalog::ListOfComponents* 
102     GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type);
103
104   //! method to get a component
105   /*!
106     \param componentname const char* arguments 
107     \return the wanted component
108   */
109   virtual SALOME_ModuleCatalog::Acomponent_ptr 
110     GetComponent(const char* componentname);
111   
112   //! method to get a component description
113   /*!
114     \param componentname const char* arguments 
115     \return the wanted component description
116   */
117   virtual SALOME_ModuleCatalog::Component *
118     GetComponentInfo(const char *name);
119
120   void ping(){};
121
122   void shutdown() { if (_orb) _orb->shutdown(1); };
123
124 private:
125   //! method to parse one module catalog
126   /*! 
127     \param file const char* arguments
128     \param modulelist ParserComponents arguments
129     \param pathlist ParserPathPrefixes arguments
130   */
131   virtual void _parse_xml_file(const char* file, 
132                           ParserComponents & modulelist, 
133                           ParserPathPrefixes & pathlist);
134
135   //! method to find component in the parser list
136   /*!
137     \param name  string argument
138     \return pointer on a component, NULL if not found
139   */
140   ParserComponent *findComponent(const std::string & name);
141
142   //! method to create a CORBA component description from parser
143   /*!
144     \param C_corba  Component argument
145     \param C_parser const ParserComponent argument
146   */
147   void duplicate(SALOME_ModuleCatalog::Component & C_corba,
148                  const ParserComponent & C_parser);
149     
150   //! method to create a CORBA interface description from parser
151   /*!
152     \param I_corba  DefinitionInterface argument
153     \param I_parser const ParserInterface argument
154   */
155   void duplicate(SALOME_ModuleCatalog::DefinitionInterface & I_corba,
156                  const ParserInterface & I_parser);
157   
158   //! method to create a CORBA service description from parser
159   /*!
160     \param S_corba  Service argument
161     \param S_parser const ParserService argument
162   */
163   void duplicate(SALOME_ModuleCatalog::Service & S_corba,
164                  const ParserService & service);
165   
166   //! method to create a CORBA parameter description from parser
167   /*!
168     \param P_corba  ServicesParameter argument
169     \param P_parser const ParserParameter argument
170   */
171   void duplicate(SALOME_ModuleCatalog::ServicesParameter & P_corba,
172                  const ParserParameter & P_parser);
173   
174   //! method to create a CORBA datastream parameter description from parser
175   /*!
176     \param P_corba  ServicesDataStreamParameter argument
177     \param P_parser const ParserDataStreamParameter argument
178   */
179   void duplicate(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
180                  const ParserDataStreamParameter & P_parser);
181   
182   //! method to create the path prefix structures from the catalog parsing
183   /*!
184     \param pathes ParserPathPrefixes arguments
185     \return the pathes
186   */
187   void duplicate(ParserPathPrefixes & p_out, const ParserPathPrefixes & P_in);
188
189  //! method to verify path prefix content
190   /*!
191     \param pathlist ListOfParserPathPrefix arguments
192     \return true if verfication is OK
193   */
194   virtual bool _verify_path_prefix(ParserPathPrefixes & pathlist);
195
196
197  //! method to parse arguments to get general and personal catalog files
198   /*!
199     \param argc int arguments
200     \param argv char** arguments
201     \param _general char** arguments
202     \return true if parsing is OK
203   */
204   virtual bool _parseArguments(int argc, char **argv, 
205                                char **_general, char** _personal);
206
207
208   // Theses variables will contain the path to the general and personal catalogs
209   char* _general_path;
210   char* _personal_path;
211
212
213   // These variables will contain the informations on the general common catalog
214   ParserComponents    _general_module_list ;
215   ParserPathPrefixes  _general_path_list ;
216
217   // These variables will contain the informations on the personal catalog
218   ParserComponents    _personal_module_list ;
219   ParserPathPrefixes  _personal_path_list ; 
220
221   std::map <std::string, SALOME_ModuleCatalog::DataStreamType> 
222   DataStreamTypeConvert;
223
224   std::map <std::string, SALOME_ModuleCatalog::DataStreamDependency> 
225   DataStreamDepConvert;
226
227   std::map <ParserComponentType, SALOME_ModuleCatalog::ComponentType> 
228   ComponentTypeConvert;
229
230   CORBA::ORB_ptr _orb;
231 };
232
233 #endif // MODULECATALOG_IMPL_H