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

Last change on this file since 991 was 591, checked in by rlacroix, 9 years ago

Remove leftovers from the XMLIO age.

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:eol-style set to native
File size: 2.7 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
[591]8#include "xios.hpp"
[325]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 -----------------------------
[545]31
[325]32   void cxios_context_handle_create (XContextPtr * _ret, const char * _id, int _id_len)
33   {
[545]34      std::string id;
[325]35      if (!cstr2string(_id, _id_len, id)) return;
[347]36      CTimer::get("XIOS").resume() ;
[545]37
[347]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   }
[545]55
[325]56   // ------------------------ Changements de contextes ------------------------
[545]57
58   void cxios_context_get_current(XContextPtr* context)
59   {
60      CTimer::get("XIOS").resume();
61      *context = CContext::getCurrent();
62      CTimer::get("XIOS").suspend();
63   }
64
[325]65   void cxios_context_set_current(XContextPtr context, bool withswap)
66   {
[347]67      CTimer::get("XIOS").resume() ;
[346]68      CContext::setCurrent(context->getId());
[347]69      CTimer::get("XIOS").suspend() ;
[325]70   }
[545]71
[325]72   // -------------------- Vérification des identifiants -----------------------
73
74   void cxios_context_valid_id (bool * _ret, const char * _id, int _id_len)
75   {
76      std::string id;
77      if (!cstr2string(_id, _id_len, id)) return;
[545]78
[520]79      CTimer::get("XIOS").resume();
[347]80      std::vector<xios::CContext*> def_vector =
[346]81            xios::CContext::getRoot()->getChildList();
[325]82
[520]83      *_ret = false;
[325]84      for (std::size_t i = 0; i < def_vector.size(); i++)
[520]85      {
86        if (def_vector[i]->getId().compare(id) == 0)
87        {
[325]88          *_ret = true;
[520]89          break;
90        }
[325]91      }
[520]92      CTimer::get("XIOS").suspend();
[325]93   }
94} // extern "C"
Note: See TracBrowser for help on using the repository browser.