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

Last change on this file since 1622 was 1622, checked in by oabramkina, 5 years ago

Exception handling on trunk.

To activate it, compilation flag -DXIOS_EXCEPTION should be added.

  • 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
Line 
1/* ************************************************************************** *
2 *      Copyright © IPSL/LSCE, xios, Avril 2010 - Octobre 2011         *
3 * ************************************************************************** */
4
5#include <boost/multi_array.hpp>
6
7#include <memory>
8
9#include "xios.hpp"
10
11#include "attribute_template.hpp"
12#include "object_template.hpp"
13#include "group_template.hpp"
14
15#include "calendar_type.hpp"
16
17#include "icutil.hpp"
18#include "timer.hpp"
19#include "context.hpp"
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
29   typedef xios::CContext * XContextPtr;
30
31   // ------------------------ Création des handle -----------------------------
32
33   void cxios_context_handle_create (XContextPtr * _ret, const char * _id, int _id_len)
34   TRY
35   {
36      std::string id;
37      if (!cstr2string(_id, _id_len, id)) return;
38      CTimer::get("XIOS").resume() ;
39
40      std::vector<xios::CContext*> def_vector =
41            xios::CContext::getRoot()->getChildList();
42
43      for (std::size_t i = 0; i < def_vector.size(); i++)
44      {
45          if (def_vector[i]->getId().compare(id) == 0)
46          {
47            *_ret = def_vector[i];
48             CTimer::get("XIOS").suspend() ;
49            return;
50          }
51      }
52       CTimer::get("XIOS").suspend() ;
53       ERROR("void cxios_context_handle_create (XContextPtr * _ret, const char * _id, int _id_len)",
54             << "Context "<<id<<"  unknown");
55      // Lever une exeception ici
56   }
57   CATCH_DUMP_STACK
58
59   // ------------------------ Changements de contextes ------------------------
60
61   void cxios_context_get_current(XContextPtr* context)
62   TRY
63   {
64      CTimer::get("XIOS").resume();
65      *context = CContext::getCurrent();
66      CTimer::get("XIOS").suspend();
67   }
68   CATCH_DUMP_STACK
69
70   void cxios_context_set_current(XContextPtr context, bool withswap)
71   TRY
72   {
73      CTimer::get("XIOS").resume() ;
74      CContext::setCurrent(context->getId());
75      CTimer::get("XIOS").suspend() ;
76   }
77   CATCH_DUMP_STACK
78
79   // -------------------- Vérification des identifiants -----------------------
80
81   void cxios_context_valid_id (bool * _ret, const char * _id, int _id_len)
82   TRY
83   {
84      std::string id;
85      if (!cstr2string(_id, _id_len, id)) return;
86
87      CTimer::get("XIOS").resume();
88      std::vector<xios::CContext*> def_vector =
89            xios::CContext::getRoot()->getChildList();
90
91      *_ret = false;
92      for (std::size_t i = 0; i < def_vector.size(); i++)
93      {
94        if (def_vector[i]->getId().compare(id) == 0)
95        {
96          *_ret = true;
97          break;
98        }
99      }
100      CTimer::get("XIOS").suspend();
101   }
102   CATCH_DUMP_STACK
103} // extern "C"
Note: See TracBrowser for help on using the repository browser.