source: XIOS/trunk/src/interface/c/icxml_tree.cpp @ 347

Last change on this file since 347 was 347, checked in by ymipsl, 12 years ago
  • Supress lot of shared_ptr
  • instrument code for vampir-trace and timer diagnostic

YM

  • Property svn:eol-style set to native
File size: 9.4 KB
Line 
1/* ************************************************************************** *
2 *      Copyright © IPSL/LSCE, xios, Avril 2010 - Octobre 2011         *
3 * ************************************************************************** */
4
5#include <boost/multi_array.hpp>
6#include <boost/shared_ptr.hpp>
7
8#include "xmlioserver.hpp"
9
10#include "attribute_template_impl.hpp"
11#include "object_template_impl.hpp"
12#include "group_template_impl.hpp"
13
14#include "icutil.hpp"
15#include "timer.hpp"
16
17extern "C"
18{
19// /////////////////////////////// Définitions ////////////////////////////// //
20
21   // ----------------------- Redéfinition de types ----------------------------
22
23   typedef xios::CContext * XContextPtr;
24
25   typedef xios::CGrid      * XGridPtr;
26   typedef xios::CGridGroup * XGridGroupPtr;
27
28   typedef xios::CFile      * XFilePtr;
29   typedef xios::CFileGroup * XFileGroupPtr;
30
31   typedef xios::CField      * XFieldPtr;
32   typedef xios::CFieldGroup * XFieldGroupPtr;
33
34   typedef xios::CDomain      * XDomainPtr;
35   typedef xios::CDomainGroup * XDomainGroupPtr;
36
37   typedef xios::CAxis      * XAxisPtr;
38   typedef xios::CAxisGroup * XAxisGroupPtr;
39   
40   // ----------------------- Ajout d'enfant à un parent -----------------------
41   
42   void cxios_xml_tree_add_field
43      (XFieldGroupPtr  parent_, XFieldPtr * child_, const char * child_id, int child_id_size)
44   {
45      std::string child_id_str; 
46      CTimer::get("XIOS").resume() ;
47      if (cstr2string(child_id, child_id_size, child_id_str))
48      {
49         *child_ = parent_->createChild(child_id_str) ;
50         parent_->sendCreateChild(child_id_str) ;
51      }
52      else
53      {
54         *child_ = parent_->createChild() ;
55         parent_->sendCreateChild() ;
56      }
57      CTimer::get("XIOS").suspend() ;
58  }
59   
60   void cxios_xml_tree_add_grid
61      (XGridGroupPtr   parent_, XGridPtr * child_, const char * child_id, int child_id_size)
62   {
63      std::string child_id_str; 
64      CTimer::get("XIOS").resume() ;
65      if (cstr2string(child_id, child_id_size, child_id_str))
66      {
67         *child_ = parent_->createChild(child_id_str) ;
68         parent_->sendCreateChild(child_id_str) ;
69      }
70      else
71      {
72         *child_ = parent_->createChild() ;
73         parent_->sendCreateChild() ;
74      }
75      CTimer::get("XIOS").suspend() ;
76   }
77   
78   void cxios_xml_tree_add_file
79      (XFileGroupPtr parent_, XFilePtr * child_, const char * child_id, int child_id_size)
80   {
81      std::string child_id_str; 
82      CTimer::get("XIOS").resume() ;
83      if (cstr2string(child_id, child_id_size, child_id_str))
84      {
85         *child_ = parent_->createChild(child_id_str) ;
86         parent_->sendCreateChild(child_id_str) ;
87      }
88      else
89      {
90         *child_ = parent_->createChild() ;
91         parent_->sendCreateChild() ;
92      }
93      CTimer::get("XIOS").suspend() ;
94   }
95   
96   void cxios_xml_tree_add_axis
97      (XAxisGroupPtr parent_, XAxisPtr * child_, const char * child_id, int child_id_size)
98   {
99      std::string child_id_str; 
100      CTimer::get("XIOS").resume() ;
101      if (cstr2string(child_id, child_id_size, child_id_str))
102      {
103         *child_ = parent_->createChild(child_id_str) ;
104         parent_->sendCreateChild(child_id_str) ;
105      }
106      else
107      {
108         *child_ = parent_->createChild() ;
109         parent_->sendCreateChild() ;
110      }
111      CTimer::get("XIOS").suspend() ;
112   }
113   
114   void cxios_xml_tree_add_domain
115      (XDomainGroupPtr parent_, XDomainPtr * child_, const char * child_id, int child_id_size)
116   {
117      std::string child_id_str;
118      CTimer::get("XIOS").resume() ;
119      if (cstr2string(child_id, child_id_size, child_id_str))
120      {
121         *child_ = parent_->createChild(child_id_str) ;
122         parent_->sendCreateChild(child_id_str) ;
123      }
124      else
125      {
126         *child_ = parent_->createChild() ;
127         parent_->sendCreateChild() ;
128      }
129      CTimer::get("XIOS").suspend() ;
130   }
131   
132   void cxios_xml_tree_add_fieldtofile
133      (XFilePtr parent_, XFieldPtr * child_, const char * child_id, int child_id_size)
134   {
135      std::string child_id_str;
136      CTimer::get("XIOS").resume() ;
137 
138      if (cstr2string(child_id, child_id_size, child_id_str))
139      {
140         *child_ = parent_->addField(child_id_str);
141         parent_->sendAddField(child_id_str) ;
142      }
143      else
144      {
145         *child_ = parent_->addField();
146         parent_->sendAddField() ;
147      }
148      CTimer::get("XIOS").suspend() ;
149   }
150
151   // ----------------------- Ajout de groupe à un parent ----------------------
152
153   void cxios_xml_tree_add_fieldgroup
154      (XFieldGroupPtr  parent_, XFieldGroupPtr * child_, const char * child_id, int child_id_size)
155   {
156     std::string child_id_str; 
157      CTimer::get("XIOS").resume() ;
158      if (cstr2string(child_id, child_id_size, child_id_str))
159      {
160         *child_ = parent_->createChildGroup(child_id_str) ;
161         parent_->sendCreateChildGroup(child_id_str) ;
162      }
163      else
164      {
165         *child_ = parent_->createChildGroup() ;
166         parent_->sendCreateChildGroup(child_id_str) ;
167      }
168      CTimer::get("XIOS").suspend() ;
169   }
170
171   void cxios_xml_tree_add_gridgroup
172      (XGridGroupPtr   parent_, XGridGroupPtr * child_, const char * child_id, int child_id_size)
173   {
174      std::string child_id_str;
175      CTimer::get("XIOS").resume() ;
176      if (cstr2string(child_id, child_id_size, child_id_str))
177      {
178         *child_ = parent_->createChildGroup(child_id_str) ;
179         parent_->sendCreateChildGroup(child_id_str) ;
180      }
181      else
182      {
183         *child_ = parent_->createChildGroup() ;
184         parent_->sendCreateChildGroup(child_id_str) ;
185      }
186      CTimer::get("XIOS").suspend() ;
187   }
188
189   void cxios_xml_tree_add_filegroup
190      (XFileGroupPtr parent_, XFileGroupPtr * child_, const char * child_id, int child_id_size)
191   {
192      std::string child_id_str;
193      CTimer::get("XIOS").resume() ;
194      if (cstr2string(child_id, child_id_size, child_id_str))
195      {
196         *child_ = parent_->createChildGroup(child_id_str) ;
197         parent_->sendCreateChildGroup(child_id_str) ;
198      }
199      else
200      {
201         *child_ = parent_->createChildGroup() ;
202         parent_->sendCreateChildGroup(child_id_str) ;
203      }
204      CTimer::get("XIOS").suspend() ;
205   }
206
207   void cxios_xml_tree_add_axisgroup
208      (XAxisGroupPtr parent_, XAxisGroupPtr * child_, const char * child_id, int child_id_size)
209   {
210      std::string child_id_str;
211      CTimer::get("XIOS").resume() ;
212      if (cstr2string(child_id, child_id_size, child_id_str))
213      {
214         *child_ = parent_->createChildGroup(child_id_str) ;
215         parent_->sendCreateChildGroup(child_id_str) ;
216      }
217      else
218      {
219         *child_ = parent_->createChildGroup() ;
220         parent_->sendCreateChildGroup(child_id_str) ;
221      }
222      CTimer::get("XIOS").suspend() ;
223   }
224
225   void cxios_xml_tree_add_domaingroup
226      (XDomainGroupPtr parent_, XDomainGroupPtr * child_, const char * child_id, int child_id_size)
227   {
228      std::string child_id_str;
229      CTimer::get("XIOS").resume() ;
230      if (cstr2string(child_id, child_id_size, child_id_str))
231      {
232         *child_ = parent_->createChildGroup(child_id_str) ;
233         parent_->sendCreateChildGroup(child_id_str) ;
234      }
235      else
236      {
237         *child_ = parent_->createChildGroup() ;
238         parent_->sendCreateChildGroup(child_id_str) ;
239      }
240      CTimer::get("XIOS").suspend() ;
241   }
242
243   void cxios_xml_tree_add_fieldgrouptofile
244      (XFilePtr parent_, XFieldGroupPtr * child_, const char * child_id, int child_id_size)
245   {
246      std::string child_id_str; 
247      CTimer::get("XIOS").resume() ;
248      if (cstr2string(child_id, child_id_size, child_id_str))
249      {
250         *child_ = parent_->addFieldGroup(child_id_str);
251         parent_->sendAddFieldGroup(child_id_str) ;
252      }
253      else
254      {
255         *child_ = parent_->addFieldGroup();
256         parent_->sendAddFieldGroup() ;
257      }
258      CTimer::get("XIOS").suspend() ;
259   }
260   
261   
262   // ----------------------- Affichage de l'arborescence ----------------------
263   
264//   void cxios_xml_tree_show   (const char * filename, int filename_size)
265//   {
266//      std::string filename_str;
267//      try
268//      {
269//         if (cstr2string(filename, filename_size, filename_str))
270//            xios::CTreeManager::PrintTreeToFile(filename_str);
271//         else
272//            xios::CTreeManager::PrintTreeToStream(std::clog);
273//      }
274//      catch (xios::CException & exc)
275//      {
276//         std::cerr << exc.getMessage() << std::endl;
277//         exit (EXIT_FAILURE);
278//      }
279//  }
280     
281   
282   // ----------------------- Parsing de document xml --------------------------
283   
284//   void cxios_xml_parse_file  (const char * filename  , int filename_size)//
285//   {
286//      std::string filename_str;
287//      if (!cstr2string(filename, filename_size, filename_str)) return;
288//
289//      try
290//      {
291//         xios::CTreeManager::ParseFile(filename_str);
292//      }
293//      catch (xios::CException & exc)
294//      {
295//         std::cerr << exc.getMessage() << std::endl;
296//         exit (EXIT_FAILURE);
297//      }
298//   }
299   
300//   void cxios_xml_parse_string(const char * xmlcontent, int xmlcontent_size)
301//   {
302//      std::string xmlcontent_str;
303//      if (!cstr2string(xmlcontent, xmlcontent_size, xmlcontent_str)) return;
304//
305//      try
306//      {
307//         xios::CTreeManager::ParseString(xmlcontent_str);
308//      }
309//      catch (xios::CException & exc)
310//      {
311//         std::cerr << exc.getMessage() << std::endl;
312//         exit (EXIT_FAILURE);
313//      }
314//   }
315   
316
317
318} // extern "C"
Note: See TracBrowser for help on using the repository browser.