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