[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 | |
---|
| 10 | #include "attribute_template_impl.hpp" |
---|
| 11 | #include "object_template_impl.hpp" |
---|
| 12 | #include "group_template_impl.hpp" |
---|
| 13 | |
---|
| 14 | #include "calendar_type.hpp" |
---|
| 15 | |
---|
| 16 | #include "icutil.hpp" |
---|
| 17 | |
---|
| 18 | extern "C" |
---|
| 19 | { |
---|
| 20 | // /////////////////////////////// Définitions ////////////////////////////// // |
---|
| 21 | |
---|
| 22 | // ----------------------- Redéfinition de types ---------------------------- |
---|
| 23 | |
---|
| 24 | typedef enum { D360 = 0 , ALLLEAP, NOLEAP, JULIAN, GREGORIAN } XCalendarType ; |
---|
| 25 | |
---|
[335] | 26 | typedef xios::tree::CContext * XContextPtr; |
---|
[325] | 27 | |
---|
| 28 | // ------------------------ Création des handle ----------------------------- |
---|
| 29 | |
---|
| 30 | void cxios_context_handle_create (XContextPtr * _ret, const char * _id, int _id_len) |
---|
| 31 | { |
---|
| 32 | std::string id; |
---|
| 33 | if (!cstr2string(_id, _id_len, id)) return; |
---|
| 34 | |
---|
[335] | 35 | std::vector<boost::shared_ptr<xios::tree::CContext> > def_vector = |
---|
| 36 | xios::tree::CContext::GetContextGroup()->getChildList(); |
---|
[325] | 37 | |
---|
| 38 | for (std::size_t i = 0; i < def_vector.size(); i++) |
---|
| 39 | { |
---|
| 40 | if (def_vector[i]->getId().compare(id) == 0) |
---|
| 41 | *_ret = def_vector[i].get(); |
---|
| 42 | return; |
---|
| 43 | } |
---|
| 44 | // Lever une exeception ici |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | // ------------------------ Changements de contextes ------------------------ |
---|
| 48 | |
---|
| 49 | void cxios_context_set_current(XContextPtr context, bool withswap) |
---|
| 50 | { |
---|
| 51 | CTreeManager::SetCurrentContextId(context->getId()); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | // -------------------- Vérification des identifiants ----------------------- |
---|
| 56 | |
---|
| 57 | void cxios_context_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
| 58 | { |
---|
| 59 | std::string id; |
---|
| 60 | if (!cstr2string(_id, _id_len, id)) return; |
---|
| 61 | |
---|
[335] | 62 | std::vector<boost::shared_ptr<xios::tree::CContext> > def_vector = |
---|
| 63 | xios::tree::CContext::GetContextGroup()->getChildList(); |
---|
[325] | 64 | |
---|
| 65 | for (std::size_t i = 0; i < def_vector.size(); i++) |
---|
| 66 | { |
---|
| 67 | if (def_vector[i]->getId().compare(id) == 0) |
---|
| 68 | *_ret = true; |
---|
| 69 | } |
---|
| 70 | *_ret = false; |
---|
| 71 | } |
---|
| 72 | } // extern "C" |
---|