[274] | 1 | /* ************************************************************************** * |
---|
| 2 | * Copyright © IPSL/LSCE, XMLIOServer, 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_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 | |
---|
| 26 | typedef xmlioserver::tree::CContext * XContextPtr; |
---|
| 27 | |
---|
| 28 | // ------------------------- Attributs des contextes ------------------------ |
---|
| 29 | |
---|
| 30 | |
---|
[286] | 31 | void cxios_set_context_calendar_type(XContextPtr context_hdl, const char * calendar_type, int calendar_type_size) |
---|
[274] | 32 | { |
---|
| 33 | std::string calendar_type_str; |
---|
| 34 | if (!cstr2string(calendar_type, calendar_type_size, calendar_type_str)) return; |
---|
| 35 | context_hdl->calendar_type.setValue(calendar_type_str); |
---|
[300] | 36 | context_hdl->sendAttributToServer(context_hdl->calendar_type) ; |
---|
[274] | 37 | } |
---|
| 38 | |
---|
[286] | 39 | void cxios_set_context_start_date(XContextPtr context_hdl, const char * start_date, int start_date_size) |
---|
[274] | 40 | { |
---|
| 41 | std::string start_date_str; |
---|
| 42 | if (!cstr2string(start_date, start_date_size, start_date_str)) return; |
---|
| 43 | |
---|
| 44 | context_hdl->start_date.setValue(start_date_str); |
---|
[300] | 45 | context_hdl->sendAttributToServer(context_hdl->start_date) ; |
---|
[274] | 46 | } |
---|
| 47 | |
---|
[286] | 48 | void cxios_set_context_output_dir(XContextPtr context_hdl, const char * output_dir, int output_dir_size) |
---|
[274] | 49 | { |
---|
| 50 | std::string output_dir_str; |
---|
| 51 | if (!cstr2string(output_dir, output_dir_size, output_dir_str)) return; |
---|
| 52 | |
---|
| 53 | context_hdl->output_dir.setValue(output_dir_str); |
---|
[300] | 54 | context_hdl->sendAttributToServer(context_hdl->output_dir) ; |
---|
[274] | 55 | } |
---|
| 56 | |
---|
| 57 | // ------------------------ Création des handle ----------------------------- |
---|
| 58 | |
---|
[286] | 59 | void cxios_context_handle_create (XContextPtr * _ret, const char * _id, int _id_len) |
---|
[274] | 60 | { |
---|
| 61 | std::string id; |
---|
| 62 | if (!cstr2string(_id, _id_len, id)) return; |
---|
| 63 | |
---|
| 64 | std::vector<boost::shared_ptr<xmlioserver::tree::CContext> > def_vector = |
---|
| 65 | xmlioserver::tree::CContext::GetContextGroup()->getChildList(); |
---|
| 66 | |
---|
| 67 | for (std::size_t i = 0; i < def_vector.size(); i++) |
---|
| 68 | { |
---|
| 69 | if (def_vector[i]->getId().compare(id) == 0) |
---|
| 70 | *_ret = def_vector[i].get(); |
---|
| 71 | return; |
---|
| 72 | } |
---|
| 73 | // Lever une execption ici |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | // ------------------------ Changements de contextes ------------------------ |
---|
| 77 | |
---|
[286] | 78 | void cxios_context_set_current(XContextPtr context, bool withswap) |
---|
[274] | 79 | { |
---|
| 80 | CTreeManager::SetCurrentContextId(context->getId()); |
---|
| 81 | } |
---|
| 82 | |
---|
[312] | 83 | |
---|
[280] | 84 | // -------------------- Vérification des identifiants ----------------------- |
---|
| 85 | |
---|
[286] | 86 | void cxios_context_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
[280] | 87 | { |
---|
| 88 | std::string id; |
---|
| 89 | if (!cstr2string(_id, _id_len, id)) return; |
---|
| 90 | |
---|
| 91 | std::vector<boost::shared_ptr<xmlioserver::tree::CContext> > def_vector = |
---|
| 92 | xmlioserver::tree::CContext::GetContextGroup()->getChildList(); |
---|
| 93 | |
---|
| 94 | for (std::size_t i = 0; i < def_vector.size(); i++) |
---|
| 95 | { |
---|
| 96 | if (def_vector[i]->getId().compare(id) == 0) |
---|
| 97 | *_ret = true; |
---|
| 98 | } |
---|
| 99 | *_ret = false; |
---|
| 100 | } |
---|
[274] | 101 | } // extern "C" |
---|