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

Last change on this file since 501 was 501, checked in by ymipsl, 10 years ago

Add licence copyright to all file ond directory src using the command :
svn propset -R copyright -F header_licence src

XIOS is now officialy under CeCILL licence

YM

  • 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.6 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          {
45            *_ret = def_vector[i];
46             CTimer::get("XIOS").suspend() ;
47            return;
48          }
49      }
50       CTimer::get("XIOS").suspend() ;
51       ERROR("void cxios_context_handle_create (XContextPtr * _ret, const char * _id, int _id_len)",
52             << "Context "<<id<<"  unknown");
53      // Lever une exeception ici
54   }
55   
56   // ------------------------ Changements de contextes ------------------------
57   
58   void cxios_context_set_current(XContextPtr context, bool withswap)
59   {
60      CTimer::get("XIOS").resume() ;
61      CContext::setCurrent(context->getId());
62      CTimer::get("XIOS").suspend() ;
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;
72     
73      CTimer::get("XIOS").resume() ;
74      std::vector<xios::CContext*> def_vector =
75            xios::CContext::getRoot()->getChildList();
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;
83     CTimer::get("XIOS").suspend() ;
84   }
85} // extern "C"
Note: See TracBrowser for help on using the repository browser.