Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions | Friends

bdlt::Timetable_Day Class Reference

#include <bdlt_timetable.h>

List of all members.

Public Types

enum  { k_UNSET_TRANSITION_CODE }

Public Member Functions

 Timetable_Day (bslma::Allocator *basicAllocator=0)
 Timetable_Day (const Timetable_Day &original, bslma::Allocator *basicAllocator=0)
 ~Timetable_Day ()
Timetable_Dayoperator= (const Timetable_Day &rhs)
bool addTransition (const Time &time, int code)
bool removeAllTransitions ()
bool removeTransition (const Time &time)
bool setInitialTransitionCode (int code)
int finalTransitionCode () const
int initialTransitionCode () const
bsl::size_t size () const
int transitionCodeInEffect (const Time &time) const

Friends

class Timetable_ConstIterator
bool operator== (const Timetable_Day &, const Timetable_Day &)
bool operator!= (const Timetable_Day &, const Timetable_Day &)
bool operator< (const Timetable_Day &, const Timetable_Day &)
template<class HASHALG >
void hashAppend (HASHALG &, const Timetable_Day &)

Detailed Description

This class implements a value-semantic repository of time-indexed state transitions over one date (this class implements one day of a timetable). A Timetable_Day can be "populated" with state transitions via the addTransition method, and queried for the transition code in effect at a specified time via the transitionCodeInEffect method. Note that, as an optimization for the transitionCodeInEffect method, the transition code in effect before the first possible transition is stored in d_initialTransitionCode.

See Component bdlt_timetable


Member Enumeration Documentation

anonymous enum
Enumerator:
k_UNSET_TRANSITION_CODE 

Constructor & Destructor Documentation

bdlt::Timetable_Day::Timetable_Day ( bslma::Allocator basicAllocator = 0  )  [explicit]

Create an empty Timetable_Day (i.e., a daily timetable having no transitions) whose initial transition code is k_UNSET_TRANSITION_CODE. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

bdlt::Timetable_Day::Timetable_Day ( const Timetable_Day original,
bslma::Allocator basicAllocator = 0 
)

Create a Timetable_Day having the same value as the specified original object. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

bdlt::Timetable_Day::~Timetable_Day (  ) 

Destroy this object.


Member Function Documentation

Timetable_Day& bdlt::Timetable_Day::operator= ( const Timetable_Day rhs  ) 

Assign to this object the value of the specified rhs daily timetable, and return a reference providing modifiable access to this object.

bool bdlt::Timetable_Day::addTransition ( const Time time,
int  code 
)

Add a transition to this daily timetable at the specified time having the specified code. If time is already a transition point, replace the existing code with code. Return true if the value returned by finalTransitionCode() prior to this operation is not equal to the value returned by finalTransitionCode() after this operation, and false otherwise. The behavior is undefined unless 24 > time.hour() and 0 <= code || k_UNSET_TRANSITION_CODE == code.

bool bdlt::Timetable_Day::removeAllTransitions (  ) 

Remove all transitions from this daily timetable. Return true if the value returned by finalTransitionCode() prior to this operation is not equal to the value returned by finalTransitionCode() after this operation, and false otherwise.

bool bdlt::Timetable_Day::removeTransition ( const Time time  ) 

If a transition occurs at the specified time, remove the transition from this daily timetable. Otherwise, return without modifying this daily timetable. Return true if the value returned by finalTransitionCode() prior to this operation is not equal to the value returned by finalTransitionCode() after this operation, and false otherwise. The behavior is undefined unless 24 > time.hour().

bool bdlt::Timetable_Day::setInitialTransitionCode ( int  code  ) 

Set the transition code in effect prior to the start of this daily timetable to the specified code. Return true if the value returned by finalTransitionCode() prior to this operation is not equal to the value returned by finalTransitionCode() after this operation, and false otherwise. The behavior is undefined unless 0 <= code || k_UNSET_TRANSITION_CODE == code.

int bdlt::Timetable_Day::finalTransitionCode (  )  const

Return the transition code that is in effect at the end of this daily timetable. Note that if this daily timetable has no transitions, initialTransitionCode() is returned.

int bdlt::Timetable_Day::initialTransitionCode (  )  const

Return the transition code in effect prior to the start of this daily timetable.

bsl::size_t bdlt::Timetable_Day::size (  )  const

Return the number of transitions in this daily timetable.

int bdlt::Timetable_Day::transitionCodeInEffect ( const Time time  )  const

Return the transition code associated with the latest transition that occurs on or before the specified time in this daily timetable. If this daily timetable has no such transition, return initialTransitionCode(). The behavior is undefined unless 24 > time.hour().


Friends And Related Function Documentation

friend class Timetable_ConstIterator [friend]
bool operator== ( const Timetable_Day ,
const Timetable_Day  
) [friend]

Return true if the specified lhs and rhs daily timetables have the same value, and false otherwise. Two daily timetables have the same value if they have the same initial transition code, the same number of transitions, and each corresponding pair of transitions has the same value.

bool operator!= ( const Timetable_Day ,
const Timetable_Day  
) [friend]

Return true if the specified lhs and rhs daily timetables do not have the same value, and false otherwise. Two daily timetables do not have the same value if they do not have the same initial transition code, they do not have the same number of transitions, or there is a corresponding pair of transitions that do not have the same value.

bool operator< ( const Timetable_Day ,
const Timetable_Day  
) [friend]

Return true if the specified lhs daily timetable is less than the specified rhs daily timetable, and false otherwise. The lhs daily timetable is less than the rhs daily timetable if lhs.initialTransitionCode() < rhs.initialTransitionCode(), or lhs.initialTransitionCode() == rhs.initialTransitionCode() and lhs.d_transitions < rhs.d_transitions.

template<class HASHALG >
void hashAppend ( HASHALG &  ,
const Timetable_Day  
) [friend]

Pass the specified object to the specified hashAlg. This function integrates with the bslh modular hashing system and effectively provides a bsl::hash specialization for Timetable_Day.


The documentation for this class was generated from the following file: