8#ifndef INCLUDED_BDLT_TIMETABLE
9#define INCLUDED_BDLT_TIMETABLE
175#include <bdlscm_version.h>
194#include <bsl_algorithm.h>
195#include <bsl_cstddef.h>
196#include <bsl_iosfwd.h>
197#include <bsl_vector.h>
205class Timetable_ConstIterator;
279 bsl::ostream&
print(bsl::ostream& stream,
281 int spacesPerLevel = 4)
const;
324template <
class HASHALG>
446 bsl::ostream&
print(bsl::ostream& stream,
448 int spacesPerLevel = 4)
const;
493template <
class HASHALG>
514 int d_initialTransitionCode;
529 template <
class HASHALG>
611 bsl::size_t
size()
const;
650template <
class HASHALG>
674 int d_initialTransitionCode;
687 template <
class HASHALG>
909 bsl::ostream&
print(bsl::ostream& stream,
911 int spacesPerLevel = 4)
const;
947template <
class HASHALG>
966 bsl::size_t d_dayIndex;
970 bsl::size_t d_transitionIndex;
996 bsl::size_t dayIndex,
997 bsl::size_t transitionIndex);
1092TimetableTransition::TimetableTransition()
1094, d_code(k_UNSET_TRANSITION_CODE)
1099TimetableTransition::TimetableTransition(
const Datetime& datetime,
int code)
1100: d_datetime(datetime)
1105 BSLS_ASSERT(0 <= code || k_UNSET_TRANSITION_CODE == code);
1111: d_datetime(original.d_datetime)
1112, d_code(original.d_code)
1121 d_datetime = rhs.d_datetime;
1122 d_code = rhs.d_code;
1145 const TimetableTransition& rhs)
1147 return lhs.datetime() == rhs.datetime() && lhs.code() == rhs.code();
1152 const TimetableTransition& rhs)
1154 return lhs.datetime() != rhs.datetime() || lhs.code() != rhs.code();
1159 const TimetableTransition& rhs)
1161 return lhs.datetime() < rhs.datetime()
1162 || (lhs.datetime() == rhs.datetime() && lhs.code() < rhs.code());
1166bool bdlt::operator<(
const TimetableTransition& lhs,
const Datetime& rhs)
1170 return lhs.datetime() < rhs;
1174bool bdlt::operator<(
const Datetime& lhs,
const TimetableTransition& rhs)
1178 return lhs < rhs.datetime();
1182template <
class HASHALG>
1186 using ::BloombergLP::bslh::hashAppend;
1200TimetableTransition_Ref::TimetableTransition_Ref()
1201: TimetableTransition()
1207TimetableTransition_Ref::TimetableTransition_Ref(
1214TimetableTransition_Ref::TimetableTransition_Ref(
1225 d_datetime = rhs.d_datetime;
1226 d_code = rhs.d_code;
1239, d_code(k_UNSET_TRANSITION_CODE)
1258: d_time(original.d_time)
1259, d_code(original.d_code)
1268 d_time = rhs.d_time;
1269 d_code = rhs.d_code;
1292 const Timetable_CompactableTransition& rhs)
1294 return lhs.time() == rhs.time() && lhs.code() == rhs.code();
1299 const Timetable_CompactableTransition& rhs)
1301 return lhs.time() != rhs.time() || lhs.code() != rhs.code();
1306 const Timetable_CompactableTransition& rhs)
1308 return lhs.time() < rhs.time()
1309 || (lhs.time() == rhs.time() && lhs.code() < rhs.code());
1318 return lhs.time() < rhs;
1323 const Timetable_CompactableTransition& rhs)
1327 return lhs < rhs.time();
1331template <
class HASHALG>
1334 const Timetable_CompactableTransition&
object)
1336 using ::BloombergLP::bslh::hashAppend;
1351: d_initialTransitionCode(k_UNSET_TRANSITION_CODE)
1352, d_transitions(basicAllocator)
1359: d_initialTransitionCode(original.d_initialTransitionCode)
1360, d_transitions(original.d_transitions, basicAllocator)
1368 d_initialTransitionCode = rhs.d_initialTransitionCode;
1369 d_transitions = rhs.d_transitions;
1379 d_transitions.clear();
1381 return code != d_initialTransitionCode;
1389 bool rv = d_initialTransitionCode != code && d_transitions.empty();
1391 d_initialTransitionCode = code;
1401 d_transitions.rbegin();
1403 return iter != d_transitions.rend()
1405 : d_initialTransitionCode;
1411 return d_initialTransitionCode;
1417 return d_transitions.size();
1426 return lhs.d_initialTransitionCode == rhs.d_initialTransitionCode
1427 && lhs.d_transitions == rhs.d_transitions;
1433 return lhs.d_initialTransitionCode != rhs.d_initialTransitionCode
1434 || lhs.d_transitions != rhs.d_transitions;
1438bool bdlt::operator<(
const Timetable_Day& lhs,
const Timetable_Day& rhs)
1440 return lhs.d_initialTransitionCode < rhs.d_initialTransitionCode
1441 || ( lhs.d_initialTransitionCode == rhs.d_initialTransitionCode
1442 && lhs.d_transitions < rhs.d_transitions);
1446template <
class HASHALG>
1450 using ::BloombergLP::bslh::hashAppend;
1452 hashAppend(hashAlg,
object.d_initialTransitionCode);
1483 d_firstDate =
Date(9999, 12, 31);
1484 d_lastDate =
Date( 1, 1, 1);
1486 d_timetable.removeAll();
1502 d_firstDate =
Date(9999, 12, 31);
1503 d_lastDate =
Date( 1, 1, 1);
1505 d_timetable.removeAll();
1518 &other.d_initialTransitionCode);
1543 return d_initialTransitionCode;
1549 return date >= d_firstDate && date <= d_lastDate;
1563 return d_firstDate <= d_lastDate ? d_lastDate - d_firstDate + 1 : 0;
1572 bsl::size_t index = date - d_firstDate;
1589 return d_timetable.allocator();
1598 return lhs.d_initialTransitionCode == rhs.d_initialTransitionCode
1599 && lhs.d_firstDate == rhs.d_firstDate
1600 && lhs.d_lastDate == rhs.d_lastDate
1601 && lhs.d_timetable == rhs.d_timetable;
1607 return lhs.d_initialTransitionCode != rhs.d_initialTransitionCode
1608 || lhs.d_firstDate != rhs.d_firstDate
1609 || lhs.d_lastDate != rhs.d_lastDate
1610 || lhs.d_timetable != rhs.d_timetable;
1615 const Timetable& timetable)
1617 return timetable.print(stream, 0, -1);
1624 if (a.allocator() == b.allocator()) {
1630 Timetable futureA(b, a.allocator());
1631 Timetable futureB(a, b.allocator());
1638template <
class HASHALG>
1642 using ::BloombergLP::bslh::hashAppend;
1646 hashAppend(hashAlg,
object.d_initialTransitionCode);
1659 const Timetable& timetable,
1660 bsl::size_t dayIndex,
1661 bsl::size_t transitionIndex)
1662: d_timetable_p(&timetable)
1663, d_dayIndex(dayIndex)
1664, d_transitionIndex(transitionIndex)
1673, d_transitionIndex(0)
1680: d_timetable_p(original.d_timetable_p)
1681, d_dayIndex(original.d_dayIndex)
1682, d_transitionIndex(original.d_transitionIndex)
1691 d_timetable_p = rhs.d_timetable_p;
1692 d_dayIndex = rhs.d_dayIndex;
1693 d_transitionIndex = rhs.d_transitionIndex;
1704 <
static_cast<bsl::size_t
>(d_timetable_p->
length()));
1706 < d_timetable_p->d_timetable[d_dayIndex].size());
1709 d_timetable_p->d_timetable[d_dayIndex].d_transitions[
1722 <
static_cast<bsl::size_t
>(d_timetable_p->
length()));
1733 Timetable_ConstIterator& iterator,
1736 const Timetable_ConstIterator curr = iterator;
1743 Timetable_ConstIterator& iterator,
1746 const Timetable_ConstIterator curr = iterator;
1753 const Timetable_ConstIterator& rhs)
1755 return lhs.d_timetable_p == rhs.d_timetable_p
1756 && lhs.d_dayIndex == rhs.d_dayIndex
1757 && lhs.d_transitionIndex == rhs.d_transitionIndex;
1762 const Timetable_ConstIterator& rhs)
1764 return lhs.d_timetable_p != rhs.d_timetable_p
1765 || lhs.d_dayIndex != rhs.d_dayIndex
1766 || lhs.d_transitionIndex != rhs.d_transitionIndex;
Definition bdlc_compactedarray.h:670
Definition bdlt_date.h:294
Definition bdlt_datetime.h:331
Date date() const
Return the value of the "date" part of this object.
Definition bdlt_datetime.h:2164
Time time() const
Return the value of the "time" part of this object.
Definition bdlt_datetime.h:2275
Definition bdlt_time.h:196
int hour() const
Return the value of the hour attribute of this time object.
Definition bdlt_time.h:898
Definition bslstl_vector.h:1025
bsl::reverse_iterator< const_iterator > const_reverse_iterator
Definition bslstl_vector.h:1060
static void swap(T *a, T *b)
Definition bslalg_swaputil.h:194
Definition bslma_allocator.h:457
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
void hashAppend(HASH_ALGORITHM &hashAlg, const baljsn::EncoderTestAddress &object)
Definition baljsn_encoder_testtypes.h:9236
Definition bbldc_basicisma30360.h:112
bool operator<(const Date &lhs, const Date &rhs)
Calendar_BusinessDayConstIter operator++(Calendar_BusinessDayConstIter &iterator, int)
Definition bdlt_calendar.h:2156
bool operator==(const Calendar &lhs, const Calendar &rhs)
bsl::ostream & operator<<(bsl::ostream &stream, const Calendar &calendar)
void swap(Calendar &a, Calendar &b)
void hashAppend(HASHALG &hashAlg, const Calendar &object)
bool operator!=(const Calendar &lhs, const Calendar &rhs)
Calendar_BusinessDayConstIter operator--(Calendar_BusinessDayConstIter &iterator, int)
Definition bdlt_calendar.h:2165
Definition balxml_encoderoptions.h:68
Enum
Enumerated day-of-week values.
Definition bdlt_dayofweek.h:123
Definition bslma_usesbslmaallocator.h:343