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

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

bug fix : regression for finding registred context

YM

  • Property svn:eol-style set to native
File size: 2.6 KB
RevLine 
[325]1/* ************************************************************************** *
[335]2 *      Copyright © IPSL/LSCE, xios, Avril 2010 - Octobre 2011         *
[325]3 * ************************************************************************** */
4
5#include <boost/multi_array.hpp>
6#include <boost/shared_ptr.hpp>
7
8#include "xmlioserver.hpp"
9
[352]10#include "attribute_template.hpp"
11#include "object_template.hpp"
12#include "group_template.hpp"
[325]13
14#include "calendar_type.hpp"
15
16#include "icutil.hpp"
[347]17#include "timer.hpp"
[352]18#include "context.hpp"
[325]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
[345]28   typedef xios::CContext * XContextPtr;
[325]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;
[347]36      CTimer::get("XIOS").resume() ;
37     
38      std::vector<xios::CContext*> def_vector =
[346]39            xios::CContext::getRoot()->getChildList();
[325]40
41      for (std::size_t i = 0; i < def_vector.size(); i++)
[393]42      {
[325]43          if (def_vector[i]->getId().compare(id) == 0)
[393]44          {
45            *_ret = def_vector[i];
46             CTimer::get("XIOS").suspend() ;
47            return;
48          }
[325]49      }
[347]50       CTimer::get("XIOS").suspend() ;
[393]51       ERROR("void cxios_context_handle_create (XContextPtr * _ret, const char * _id, int _id_len)",
52             << "Context "<<id<<"  unknown");
[325]53      // Lever une exeception ici
54   }
55   
56   // ------------------------ Changements de contextes ------------------------
57   
58   void cxios_context_set_current(XContextPtr context, bool withswap)
59   {
[347]60      CTimer::get("XIOS").resume() ;
[346]61      CContext::setCurrent(context->getId());
[347]62      CTimer::get("XIOS").suspend() ;
[325]63   }
64   
65 
66   // -------------------- Vérification des identifiants -----------------------
67
68   void cxios_context_valid_id (bool * _ret, const char * _id, int _id_len)
69   {
70      std::string id;
71      if (!cstr2string(_id, _id_len, id)) return;
[347]72     
73      CTimer::get("XIOS").resume() ;
74      std::vector<xios::CContext*> def_vector =
[346]75            xios::CContext::getRoot()->getChildList();
[325]76
77      for (std::size_t i = 0; i < def_vector.size(); i++)
78           {
79          if (def_vector[i]->getId().compare(id) == 0)
80          *_ret = true;
81      }
82     *_ret = false;
[347]83     CTimer::get("XIOS").suspend() ;
[325]84   }
85} // extern "C"
Note: See TracBrowser for help on using the repository browser.