source: XIOS/trunk/src/interface/c/iccontext.cpp @ 382

Last change on this file since 382 was 352, checked in by ymipsl, 12 years ago
  • Property svn:eol-style set to native
File size: 2.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.hpp"
11#include "object_template.hpp"
12#include "group_template.hpp"
13
14#include "calendar_type.hpp"
15
16#include "icutil.hpp"
17#include "timer.hpp"
18#include "context.hpp"
19
20extern "C"
21{
22// /////////////////////////////// Définitions ////////////////////////////// //
23
24   // ----------------------- Redéfinition de types ----------------------------
25
26   typedef enum { D360 = 0 , ALLLEAP, NOLEAP, JULIAN, GREGORIAN } XCalendarType ;
27
28   typedef xios::CContext * XContextPtr;
29
30   // ------------------------ Création des handle -----------------------------
31   
32   void cxios_context_handle_create (XContextPtr * _ret, const char * _id, int _id_len)
33   {
34      std::string id; 
35      if (!cstr2string(_id, _id_len, id)) return;
36      CTimer::get("XIOS").resume() ;
37     
38      std::vector<xios::CContext*> def_vector =
39            xios::CContext::getRoot()->getChildList();
40
41      for (std::size_t i = 0; i < def_vector.size(); i++)
42           {
43          if (def_vector[i]->getId().compare(id) == 0)
44          *_ret = def_vector[i];
45           CTimer::get("XIOS").suspend() ;
46          return;
47      }
48       CTimer::get("XIOS").suspend() ;
49      // Lever une exeception ici
50   }
51   
52   // ------------------------ Changements de contextes ------------------------
53   
54   void cxios_context_set_current(XContextPtr context, bool withswap)
55   {
56      CTimer::get("XIOS").resume() ;
57      CContext::setCurrent(context->getId());
58      CTimer::get("XIOS").suspend() ;
59   }
60   
61 
62   // -------------------- Vérification des identifiants -----------------------
63
64   void cxios_context_valid_id (bool * _ret, const char * _id, int _id_len)
65   {
66      std::string id;
67      if (!cstr2string(_id, _id_len, id)) return;
68     
69      CTimer::get("XIOS").resume() ;
70      std::vector<xios::CContext*> def_vector =
71            xios::CContext::getRoot()->getChildList();
72
73      for (std::size_t i = 0; i < def_vector.size(); i++)
74           {
75          if (def_vector[i]->getId().compare(id) == 0)
76          *_ret = true;
77      }
78     *_ret = false;
79     CTimer::get("XIOS").suspend() ;
80   }
81} // extern "C"
Note: See TracBrowser for help on using the repository browser.