michael@0: /*
michael@0: *******************************************************************************
michael@0: * Copyright (C) 2007-2008, International Business Machines Corporation and *
michael@0: * others. All Rights Reserved. *
michael@0: *******************************************************************************
michael@0: */
michael@0: #ifndef TZTRANS_H
michael@0: #define TZTRANS_H
michael@0:
michael@0: /**
michael@0: * \file
michael@0: * \brief C++ API: Time zone transition
michael@0: */
michael@0:
michael@0: #include "unicode/utypes.h"
michael@0:
michael@0: #if !UCONFIG_NO_FORMATTING
michael@0:
michael@0: #include "unicode/uobject.h"
michael@0:
michael@0: U_NAMESPACE_BEGIN
michael@0:
michael@0: // Forward declaration
michael@0: class TimeZoneRule;
michael@0:
michael@0: /**
michael@0: * TimeZoneTransition
is a class representing a time zone transition.
michael@0: * An instance has a time of transition and rules for both before and after the transition.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: class U_I18N_API TimeZoneTransition : public UObject {
michael@0: public:
michael@0: /**
michael@0: * Constructs a TimeZoneTransition
with the time and the rules before/after
michael@0: * the transition.
michael@0: *
michael@0: * @param time The time of transition in milliseconds since the base time.
michael@0: * @param from The time zone rule used before the transition.
michael@0: * @param to The time zone rule used after the transition.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: TimeZoneTransition(UDate time, const TimeZoneRule& from, const TimeZoneRule& to);
michael@0:
michael@0: /**
michael@0: * Constructs an empty TimeZoneTransition
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: TimeZoneTransition();
michael@0:
michael@0: /**
michael@0: * Copy constructor.
michael@0: * @param source The TimeZoneTransition object to be copied.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: TimeZoneTransition(const TimeZoneTransition& source);
michael@0:
michael@0: /**
michael@0: * Destructor.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: ~TimeZoneTransition();
michael@0:
michael@0: /**
michael@0: * Clone this TimeZoneTransition object polymorphically. The caller owns the result and
michael@0: * should delete it when done.
michael@0: * @return A copy of the object.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: TimeZoneTransition* clone(void) const;
michael@0:
michael@0: /**
michael@0: * Assignment operator.
michael@0: * @param right The object to be copied.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: TimeZoneTransition& operator=(const TimeZoneTransition& right);
michael@0:
michael@0: /**
michael@0: * Return true if the given TimeZoneTransition objects are semantically equal. Objects
michael@0: * of different subclasses are considered unequal.
michael@0: * @param that The object to be compared with.
michael@0: * @return true if the given TimeZoneTransition objects are semantically equal.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: UBool operator==(const TimeZoneTransition& that) const;
michael@0:
michael@0: /**
michael@0: * Return true if the given TimeZoneTransition objects are semantically unequal. Objects
michael@0: * of different subclasses are considered unequal.
michael@0: * @param that The object to be compared with.
michael@0: * @return true if the given TimeZoneTransition objects are semantically unequal.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: UBool operator!=(const TimeZoneTransition& that) const;
michael@0:
michael@0: /**
michael@0: * Returns the time of transition in milliseconds.
michael@0: * @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: UDate getTime(void) const;
michael@0:
michael@0: /**
michael@0: * Sets the time of transition in milliseconds.
michael@0: * @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: void setTime(UDate time);
michael@0:
michael@0: /**
michael@0: * Returns the rule used before the transition.
michael@0: * @return The time zone rule used after the transition.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: const TimeZoneRule* getFrom(void) const;
michael@0:
michael@0: /**
michael@0: * Sets the rule used before the transition. The caller remains
michael@0: * responsible for deleting the TimeZoneRule
object.
michael@0: * @param from The time zone rule used before the transition.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: void setFrom(const TimeZoneRule& from);
michael@0:
michael@0: /**
michael@0: * Adopts the rule used before the transition. The caller must
michael@0: * not delete the TimeZoneRule
object passed in.
michael@0: * @param from The time zone rule used before the transition.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: void adoptFrom(TimeZoneRule* from);
michael@0:
michael@0: /**
michael@0: * Sets the rule used after the transition. The caller remains
michael@0: * responsible for deleting the TimeZoneRule
object.
michael@0: * @param to The time zone rule used after the transition.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: void setTo(const TimeZoneRule& to);
michael@0:
michael@0: /**
michael@0: * Adopts the rule used after the transition. The caller must
michael@0: * not delete the TimeZoneRule
object passed in.
michael@0: * @param to The time zone rule used after the transition.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: void adoptTo(TimeZoneRule* to);
michael@0:
michael@0: /**
michael@0: * Returns the rule used after the transition.
michael@0: * @return The time zone rule used after the transition.
michael@0: * @stable ICU 3.8
michael@0: */
michael@0: const TimeZoneRule* getTo(void) const;
michael@0:
michael@0: private:
michael@0: UDate fTime;
michael@0: TimeZoneRule* fFrom;
michael@0: TimeZoneRule* fTo;
michael@0:
michael@0: public:
michael@0: /**
michael@0: * Return the class ID for this class. This is useful only for comparing to
michael@0: * a return value from getDynamicClassID(). For example:
michael@0: *
michael@0: * . Base* polymorphic_pointer = createPolymorphicObject(); michael@0: * . if (polymorphic_pointer->getDynamicClassID() == michael@0: * . erived::getStaticClassID()) ... michael@0: *michael@0: * @return The class ID for all objects of this class. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: static UClassID U_EXPORT2 getStaticClassID(void); michael@0: michael@0: /** michael@0: * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This michael@0: * method is to implement a simple version of RTTI, since not all C++ michael@0: * compilers support genuine RTTI. Polymorphic operator==() and clone() michael@0: * methods call this method. michael@0: * michael@0: * @return The class ID for this object. All objects of a michael@0: * given class have the same class ID. Objects of michael@0: * other classes have different class IDs. michael@0: * @stable ICU 3.8 michael@0: */ michael@0: virtual UClassID getDynamicClassID(void) const; michael@0: }; michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_FORMATTING */ michael@0: michael@0: #endif // TZTRANS_H michael@0: michael@0: //eof