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 | |
---|
31 | void cxios_set_context_calendar_type(XContextPtr context_hdl, const char * calendar_type, int calendar_type_size) |
---|
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); |
---|
36 | context_hdl->sendAttributToServer(context_hdl->calendar_type) ; |
---|
37 | } |
---|
38 | |
---|
39 | void cxios_set_context_start_date(XContextPtr context_hdl, const char * start_date, int start_date_size) |
---|
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); |
---|
45 | context_hdl->sendAttributToServer(context_hdl->start_date) ; |
---|
46 | } |
---|
47 | |
---|
48 | void cxios_set_context_output_dir(XContextPtr context_hdl, const char * output_dir, int output_dir_size) |
---|
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); |
---|
54 | context_hdl->sendAttributToServer(context_hdl->output_dir) ; |
---|
55 | } |
---|
56 | |
---|
57 | // ------------------------ Création des handle ----------------------------- |
---|
58 | |
---|
59 | void cxios_context_handle_create (XContextPtr * _ret, const char * _id, int _id_len) |
---|
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 | |
---|
78 | void cxios_context_set_current(XContextPtr context, bool withswap) |
---|
79 | { |
---|
80 | CTreeManager::SetCurrentContextId(context->getId()); |
---|
81 | } |
---|
82 | |
---|
83 | |
---|
84 | // -------------------- Vérification des identifiants ----------------------- |
---|
85 | |
---|
86 | void cxios_context_valid_id (bool * _ret, const char * _id, int _id_len) |
---|
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 | } |
---|
101 | } // extern "C" |
---|