Salome HOME
Remove traces
[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 PathPrefix of a computer
59  /*! If the wanted computer doesn't exist, the Notfound exception is thrown
60    \param machinename const char* arguments 
61    \return the prefix path
62  */
63   virtual char* GetPathPrefix(const char* machinename);
64
65   //! method to read a XML file and import new components into the component list
66  /*! If the XML file doesn't exist or is not readable, the Notfound exception is thrown
67    \param  const char* xmlFileName 
68  */
69   virtual void ImportXmlCatalogFile(const char* xmlFileName);
70
71   //! method to get a component list
72   /*!
73     \return a component list 
74   */
75   virtual SALOME_ModuleCatalog::ListOfComponents* GetComponentList();
76
77   //! method to get a component list of component name and component icone
78   /*!
79     \return a list of couple (component name, component icone) 
80   */
81   virtual SALOME_ModuleCatalog::ListOfIAPP_Affich* GetComponentIconeList();
82
83   //! method to get a component list of a wanted type
84   /*!
85     \return a component list 
86   */
87   virtual SALOME_ModuleCatalog::ListOfComponents* 
88     GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type);
89
90   //! method to get a component
91   /*!
92     \param componentname const char* arguments 
93     \return the wanted component
94   */
95   virtual SALOME_ModuleCatalog::Acomponent_ptr 
96     GetComponent(const char* componentname);
97   
98   //! method to get a component description
99   /*!
100     \param componentname const char* arguments 
101     \return the wanted component description
102   */
103   virtual SALOME_ModuleCatalog::Component *
104     GetComponentInfo(const char *name);
105
106   void ping(){};
107
108   void shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); };
109
110 private:
111   //! method to parse one module catalog
112   /*! 
113     \param file const char* arguments
114     \param modulelist ParserComponents arguments
115     \param pathlist ParserPathPrefixes arguments
116   */
117   virtual void _parse_xml_file(const char* file, 
118                           ParserComponents & modulelist, 
119                           ParserPathPrefixes & pathlist);
120
121   //! method to find component in the parser list
122   /*!
123     \param name  string argument
124     \return pointer on a component, NULL if not found
125   */
126   ParserComponent *findComponent(const std::string & name);
127
128   //! method to create a CORBA component description from parser
129   /*!
130     \param C_corba  Component argument
131     \param C_parser const ParserComponent argument
132   */
133   void duplicate(SALOME_ModuleCatalog::Component & C_corba,
134                  const ParserComponent & C_parser);
135     
136   //! method to create a CORBA interface description from parser
137   /*!
138     \param I_corba  DefinitionInterface argument
139     \param I_parser const ParserInterface argument
140   */
141   void duplicate(SALOME_ModuleCatalog::DefinitionInterface & I_corba,
142                  const ParserInterface & I_parser);
143   
144   //! method to create a CORBA service description from parser
145   /*!
146     \param S_corba  Service argument
147     \param S_parser const ParserService argument
148   */
149   void duplicate(SALOME_ModuleCatalog::Service & S_corba,
150                  const ParserService & service);
151   
152   //! method to create a CORBA parameter description from parser
153   /*!
154     \param P_corba  ServicesParameter argument
155     \param P_parser const ParserParameter argument
156   */
157   void duplicate(SALOME_ModuleCatalog::ServicesParameter & P_corba,
158                  const ParserParameter & P_parser);
159   
160   //! method to create a CORBA datastream parameter description from parser
161   /*!
162     \param P_corba  ServicesDataStreamParameter argument
163     \param P_parser const ParserDataStreamParameter argument
164   */
165   void duplicate(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
166                  const ParserDataStreamParameter & P_parser);
167   
168   //! method to create the path prefix structures from the catalog parsing
169   /*!
170     \param pathes ParserPathPrefixes arguments
171     \return the pathes
172   */
173   void duplicate(ParserPathPrefixes & p_out, const ParserPathPrefixes & P_in);
174
175  //! method to verify path prefix content
176   /*!
177     \param pathlist ListOfParserPathPrefix arguments
178     \return true if verfication is OK
179   */
180   virtual bool _verify_path_prefix(ParserPathPrefixes & pathlist);
181
182
183  //! method to parse arguments to get general and personal catalog files
184   /*!
185     \param argc int arguments
186     \param argv char** arguments
187     \param _general char** arguments
188     \return true if parsing is OK
189   */
190   virtual bool _parseArguments(int argc, char **argv, 
191                                char **_general, char** _personal);
192
193
194   // Theses variables will contain the path to the general and personal catalogs
195   char* _general_path;
196   char* _personal_path;
197
198
199   // These variables will contain the informations on the general common catalog
200   ParserComponents    _general_module_list ;
201   ParserPathPrefixes  _general_path_list ;
202
203   // These variables will contain the informations on the personal catalog
204   ParserComponents    _personal_module_list ;
205   ParserPathPrefixes  _personal_path_list ; 
206
207   std::map <std::string, SALOME_ModuleCatalog::DataStreamType> 
208   DataStreamTypeConvert;
209
210   std::map <std::string, SALOME_ModuleCatalog::DataStreamDependency> 
211   DataStreamDepConvert;
212
213   std::map <ParserComponentType, SALOME_ModuleCatalog::ComponentType> 
214   ComponentTypeConvert;
215
216   CORBA::ORB_ptr _orb;
217 };
218
219 #endif // MODULECATALOG_IMPL_H