source: XIOS3/trunk/src/interface/c/iccontext.cpp @ 2629

Last change on this file since 2629 was 2629, checked in by jderouillat, 2 months ago

Delete boost dependencies, the few features used are replaced by functions stored in extern/boost_extraction

  • 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.8 KB
RevLine 
[325]1/* ************************************************************************** *
[335]2 *      Copyright © IPSL/LSCE, xios, Avril 2010 - Octobre 2011         *
[325]3 * ************************************************************************** */
4
5
[2629]6
[1542]7#include <memory>
8
[591]9#include "xios.hpp"
[325]10
[352]11#include "attribute_template.hpp"
12#include "object_template.hpp"
13#include "group_template.hpp"
[325]14
15#include "calendar_type.hpp"
16
17#include "icutil.hpp"
[347]18#include "timer.hpp"
[352]19#include "context.hpp"
[325]20
21extern "C"
22{
23// /////////////////////////////// Définitions ////////////////////////////// //
24
25   // ----------------------- Redéfinition de types ----------------------------
26
27   typedef enum { D360 = 0 , ALLLEAP, NOLEAP, JULIAN, GREGORIAN } XCalendarType ;
28
[345]29   typedef xios::CContext * XContextPtr;
[325]30
31   // ------------------------ Création des handle -----------------------------
[545]32
[325]33   void cxios_context_handle_create (XContextPtr * _ret, const char * _id, int _id_len)
[1622]34   TRY
[325]35   {
[545]36      std::string id;
[325]37      if (!cstr2string(_id, _id_len, id)) return;
[347]38      CTimer::get("XIOS").resume() ;
[545]39
[2603]40      xios_map<StdString, CContext* > def_map =
41            xios::CContext::getRoot()->getChildMap();
42     
43      if (def_map.count(id))
[393]44      {
[2603]45        *_ret = def_map[id];
46        CTimer::get("XIOS").suspend() ;
47        return;
[325]48      }
[347]49       CTimer::get("XIOS").suspend() ;
[393]50       ERROR("void cxios_context_handle_create (XContextPtr * _ret, const char * _id, int _id_len)",
51             << "Context "<<id<<"  unknown");
[325]52      // Lever une exeception ici
53   }
[1622]54   CATCH_DUMP_STACK
[545]55
[325]56   // ------------------------ Changements de contextes ------------------------
[545]57
58   void cxios_context_get_current(XContextPtr* context)
[1622]59   TRY
[545]60   {
61      CTimer::get("XIOS").resume();
62      *context = CContext::getCurrent();
63      CTimer::get("XIOS").suspend();
64   }
[1622]65   CATCH_DUMP_STACK
[545]66
[2121]67   void cxios_context_get_id(XContextPtr context, char * _id, int _id_len)
68   TRY
69   {
70      string_copy(context->getId(),_id,_id_len);
71   }
72   CATCH_DUMP_STACK
73   
[325]74   void cxios_context_set_current(XContextPtr context, bool withswap)
[1622]75   TRY
[325]76   {
[347]77      CTimer::get("XIOS").resume() ;
[346]78      CContext::setCurrent(context->getId());
[347]79      CTimer::get("XIOS").suspend() ;
[325]80   }
[1622]81   CATCH_DUMP_STACK
[545]82
[325]83   // -------------------- Vérification des identifiants -----------------------
84
85   void cxios_context_valid_id (bool * _ret, const char * _id, int _id_len)
[1622]86   TRY
[325]87   {
88      std::string id;
89      if (!cstr2string(_id, _id_len, id)) return;
[545]90
[520]91      CTimer::get("XIOS").resume();
[325]92
[2603]93      xios_map<StdString, CContext* > def_map =
94            xios::CContext::getRoot()->getChildMap();
95
[520]96      *_ret = false;
[2603]97      if (def_map.count(id))
[520]98      {
[2603]99        *_ret = true;
[2607]100        CTimer::get("XIOS").suspend();
[2603]101        return;
[325]102      }
[520]103      CTimer::get("XIOS").suspend();
[325]104   }
[1622]105   CATCH_DUMP_STACK
[325]106} // extern "C"
Note: See TracBrowser for help on using the repository browser.