source: XIOS/trunk/src/fortran/iccontext.cpp @ 313

Last change on this file since 313 was 313, checked in by ymipsl, 12 years ago

Fortran attribut interface are now automaticaly generated.
Add get attribut fonctionnality from fortran.

YM

File size: 2.2 KB
Line 
1/* ************************************************************************** *
2 *      Copyright © IPSL/LSCE, XMLIOServer, 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 "calendar_type.hpp"
15
16#include "icutil.hpp"
17
18extern "C"
19{
20// /////////////////////////////// Définitions ////////////////////////////// //
21
22   // ----------------------- Redéfinition de types ----------------------------
23
24   typedef enum { D360 = 0 , ALLLEAP, NOLEAP, JULIAN, GREGORIAN } XCalendarType ;
25
26   typedef xmlioserver::tree::CContext * XContextPtr;
27
28   // ------------------------ Création des handle -----------------------------
29   
30   void cxios_context_handle_create (XContextPtr * _ret, const char * _id, int _id_len)
31   {
32      std::string id; 
33      if (!cstr2string(_id, _id_len, id)) return;
34
35      std::vector<boost::shared_ptr<xmlioserver::tree::CContext> > def_vector =
36            xmlioserver::tree::CContext::GetContextGroup()->getChildList();
37
38      for (std::size_t i = 0; i < def_vector.size(); i++)
39           {
40          if (def_vector[i]->getId().compare(id) == 0)
41          *_ret = def_vector[i].get();
42          return;
43      }
44      // Lever une exeception ici
45   }
46   
47   // ------------------------ Changements de contextes ------------------------
48   
49   void cxios_context_set_current(XContextPtr context, bool withswap)
50   {
51      CTreeManager::SetCurrentContextId(context->getId());
52   }
53   
54 
55   // -------------------- Vérification des identifiants -----------------------
56
57   void cxios_context_valid_id (bool * _ret, const char * _id, int _id_len)
58   {
59      std::string id;
60      if (!cstr2string(_id, _id_len, id)) return;
61
62      std::vector<boost::shared_ptr<xmlioserver::tree::CContext> > def_vector =
63            xmlioserver::tree::CContext::GetContextGroup()->getChildList();
64
65      for (std::size_t i = 0; i < def_vector.size(); i++)
66           {
67          if (def_vector[i]->getId().compare(id) == 0)
68          *_ret = true;
69      }
70     *_ret = false;
71   }
72} // extern "C"
Note: See TracBrowser for help on using the repository browser.