XIOS  1.0
Xml I/O Server
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Définitions de type Énumérations Valeurs énumérées Amis Macros
iccalendar.cpp
Aller à la documentation de ce fichier.
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 
9 extern "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  }
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  }
43 
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  }
58 
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  }
73 }
void cxios_update_calendar(int step) TRY
Definition: iccalendar.cpp:11
void updateCalendar(int step)
Update calendar in each time step.
Definition: context.cpp:1958
int getSecond(void) const
Get the calendar associated to the date.
Definition: date.cpp:141
CATCH_DUMP_STACK int cxios_get_day_length_in_seconds() TRY
Definition: iccalendar.cpp:59
int year
Definition: date.hpp:97
int getMonth(void) const
Definition: date.cpp:137
#define TRY
Definition: exception.hpp:154
#define CATCH_DUMP_STACK
Definition: exception.hpp:157
std::shared_ptr< CCalendar > getCalendar(void) const
Accesseurs ///.
Definition: context.cpp:81
bool isAttachedModeEnabled() const
Check if the attached mode is used.
CATCH_DUMP_STACK void cxios_get_current_date(cxios_date *current_date_c) TRY
Definition: iccalendar.cpp:24
int getDay(void) const
Definition: date.cpp:138
int getMinute(void) const
Definition: date.cpp:140
int getHour(void) const
Definition: date.cpp:139
int getYear(void) const
Divers accesseurs ///.
Definition: date.cpp:136
#define ERROR(id, x)
Definition: exception.hpp:73
void sendUpdateCalendar(int step)
Client side: Send a message to update calendar in each time step.
Definition: context.cpp:1330
bool checkBuffersAndListen(bool enableEventsProcessing=true)
Try to send the buffers and receive possible answers.
Definition: context.cpp:422
CContextClient * client
Concrete contex client.
Definition: context.hpp:251
CATCH_DUMP_STACK int cxios_get_year_length_in_seconds(int year) TRY
Definition: iccalendar.cpp:44