source: XIOS/dev/dev_olga/src/interface/c/iccalendar.cpp @ 1612

Last change on this file since 1612 was 1612, checked in by oabramkina, 21 months ago

Dev: adding exception handling.

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

File size: 2.2 KB
Line 
1#include "xios.hpp"
2
3#include "icdate.hpp"
4#include "exception.hpp"
5#include "timer.hpp"
6#include "context.hpp"
7#include "context_client.hpp"
8
9extern "C"
10{
11  void cxios_update_calendar(int step)
12  TRY
13  {
14    CTimer::get("XIOS").resume();
15    xios::CContext* context = CContext::getCurrent();
16    if (!context->hasServer && !context->client->isAttachedModeEnabled())
17      context->checkBuffersAndListen();
18    context->updateCalendar(step);
19    context->sendUpdateCalendar(step);
20    CTimer::get("XIOS").suspend();
21  }
22  CATCH_DUMP_STACK
23
24  void cxios_get_current_date(cxios_date* current_date_c)
25  TRY
26  {
27    CTimer::get("XIOS").resume();
28    const xios::CContext* context = CContext::getCurrent();
29    const std::shared_ptr<xios::CCalendar> cal = context->getCalendar();
30    if (!cal)
31      ERROR("void cxios_get_current_date(cxios_date* current_date_c)",
32            << "Impossible to get the current date: no calendar was defined.");
33    const CDate& currentDate = cal->getCurrentDate();
34    current_date_c->year = currentDate.getYear();
35    current_date_c->month = currentDate.getMonth();
36    current_date_c->day = currentDate.getDay();
37    current_date_c->hour = currentDate.getHour();
38    current_date_c->minute = currentDate.getMinute();
39    current_date_c->second = currentDate.getSecond();
40    CTimer::get("XIOS").suspend();
41  }
42  CATCH_DUMP_STACK
43
44  int cxios_get_year_length_in_seconds(int year)
45  TRY
46  {
47    CTimer::get("XIOS").resume();
48    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
49    if (!cal)
50      ERROR("int cxios_get_year_length_in_seconds(int year)",
51            << "Impossible to get the year length: no calendar was defined.");
52    int length = cal->getYearTotalLength(CDate(*cal, year, 01, 01));
53    CTimer::get("XIOS").suspend();
54
55    return length;
56  }
57  CATCH_DUMP_STACK
58
59  int cxios_get_day_length_in_seconds()
60  TRY
61  {
62    CTimer::get("XIOS").resume();
63    const std::shared_ptr<xios::CCalendar> cal = CContext::getCurrent()->getCalendar();
64    if (!cal)
65      ERROR("int cxios_get_day_length_in_seconds()",
66            << "Impossible to get the day length: no calendar was defined.");
67    int length = cal->getDayLengthInSeconds();
68    CTimer::get("XIOS").suspend();
69
70    return length;
71  }
72  CATCH_DUMP_STACK
73}
Note: See TracBrowser for help on using the repository browser.