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