37 ERROR(
"CCalendarWrapper::getCalendar(bool checkValid = true)", <<
"The calendar was accessed before being created!");
87 ERROR(
"CCalendarWrapper::createCalendar(void)",
88 <<
"Error: the calendar can only be defined once!");
90 else if (!
type.isEmpty())
92 #define DECLARE_CALENDAR(MType, eType) \
93 if (type.getValue() == type_attr::eType) \
94 calendar = std::shared_ptr<CCalendar>(new C##MType##Calendar());
96 #undef DECLARE_CALENDAR
98 if (
type.getValue() == type_attr::user_defined)
100 if (day_length.isEmpty())
101 ERROR(
"CCalendarWrapper::createCalendar(void)",
102 <<
"The day length must be configured when using an user defined calendar.");
103 if (month_lengths.isEmpty() == year_length.isEmpty())
104 ERROR(
"CCalendarWrapper::createCalendar(void)",
105 <<
"Either the month lengths or the year length must be configured when using an user defined calendar.");
106 if (leap_year_drift.isEmpty() != leap_year_month.isEmpty())
107 ERROR(
"CCalendarWrapper::createCalendar(void)",
108 <<
"Both leap_year_drift and leap_year_month attributes must be set if you wish to configure leap years.");
109 if (leap_year_drift.isEmpty() && !leap_year_drift_offset.isEmpty())
110 ERROR(
"CCalendarWrapper::createCalendar(void)",
111 <<
"Both leap_year_drift and leap_year_month attributes are mandatory if you wish to use leap_year_drift_offset attribute.");
113 std::shared_ptr<CUserDefinedCalendar> userDefinedCalendar;
114 if (year_length.isEmpty())
115 userDefinedCalendar.reset(
new CUserDefinedCalendar(day_length.getValue(), month_lengths.getValue()));
117 userDefinedCalendar.reset(
new CUserDefinedCalendar(day_length.getValue(), year_length.getValue()));
119 if (!leap_year_month.isEmpty())
120 userDefinedCalendar->configureLeapYear(leap_year_month.getValue(),
121 leap_year_drift.getValue(),
122 leap_year_drift_offset.isEmpty() ? 0.0 : leap_year_drift_offset.getValue());
128 #define CHECK_EMPTY(attr) \
129 if (!attr.isEmpty()) \
130 ERROR("CCalendarWrapper::createCalendar(void)", \
131 << "The attribute \"" #attr "\" can only be used with user defined calendar.");
142 ERROR(
"CCalendarWrapper::createCalendar(void)",
143 <<
"[ type = " <<
type.getStringValue() <<
" ] "
144 <<
"The calendar is not properly handled!");
147 if (!timestep.isEmpty())
148 calendar->setTimeStep(timestep.getValue());
151 if (!start_date.isEmpty())
155 if (!time_origin.isEmpty())
161 ERROR(
"CCalendarWrapper::createCalendar(void)", <<
"Impossible to set the calendar: no current context available.");
164 else if (!start_date.isEmpty() || !time_origin.isEmpty())
166 ERROR(
"CCalendarWrapper::createCalendar(void)",
167 <<
"The calendar type must be set before defining the start date or the time origin!");
176 if (timestep.isEmpty())
178 ERROR(
"CCalendarWrapper::updateTimestep(void)",
179 <<
"Error: the timestep needs to be defined!");
182 calendar->setTimeStep(timestep.getValue());
////////////////////// Déclarations ////////////////////// ///
std::shared_ptr< CCalendar > getCalendar(bool checkValid=false) const
Accesseurs ///.
const CDate & getTimeOrigin() const
static CDate FromString(const StdString &str, const CCalendar &calendar)
static StdString GetDefName(void)
void setCalendar(std::shared_ptr< CCalendar > newCalendar)
Mutateurs ///.
CATCH CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar *scalarDestination, CScalar *scalarSource, CReduceScalarToScalar *algo ERROR)("CScalarAlgorithmReduceScalar::CScalarAlgorithmReduceScalar(CScalar* scalarDestination, CScalar* scalarSource, CReduceScalarToScalar* algo)",<< "Operation must be defined."<< "Scalar source "<< scalarSource->getId()<< std::endl<< "Scalar destination "<< scalarDestination->getId())
////////////////////// Déclarations ////////////////////// ///
static StdString GetName(void)
Accesseurs statiques ///.
std::shared_ptr< CCalendar > calendar
void createCalendar(void)
Try to create the calendar from the parsed attributes.
virtual void parse(xml::CXMLNode &node)
virtual void parse(xml::CXMLNode &node)
Parse the calendar node.
CCalendarWrapper(void)
Constructeurs ///.
void setTimeOrigin(const CDate &timeOrigin)
void setInitDate(const CDate &initDate)
Mutateurs ///.
enum xios::_node_type ENodeType
////////////////////// Définitions ////////////////////// ///
void updateTimestep(void)
Try to update the timestep of the calendar with the corresponding attribute.
CATCH CAxisAlgorithmReduceAxis::CAxisAlgorithmReduceAxis(CAxis *axisDestination, CAxis *axisSource, CReduceAxisToAxis *algo) alg checkValid)(axisDestination, axisSource)
StdString toString(void) const
Autres ///.
virtual ~CCalendarWrapper(void)
Destructeur ///.
const CDate & getInitDate() const
static CContext * getCurrent(void)
Get current context.
static ENodeType GetType(void)
#define CHECK_EMPTY(attr)