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