1 /*
2  *******************************************************************************
3  * Copyright (C) 2009-2014, Google, International Business Machines Corporation and *
4  * others. All Rights Reserved.                                                *
5  *******************************************************************************
6  */
7 
8 #ifndef __TMUNIT_H__
9 #define __TMUNIT_H__
10 
11 
12 /**
13  * \file
14  * \brief C++ API: time unit object
15  */
16 
17 
18 #include "unicode/measunit.h"
19 
20 #if !UCONFIG_NO_FORMATTING
21 
22 U_NAMESPACE_BEGIN
23 
24 /**
25  * Measurement unit for time units.
26  * @see TimeUnitAmount
27  * @see TimeUnit
28  * @stable ICU 4.2
29  */
30 class U_I18N_API TimeUnit: public MeasureUnit {
31 public:
32     /**
33      * Constants for all the time units we supported.
34      * @stable ICU 4.2
35      */
36     enum UTimeUnitFields {
37         UTIMEUNIT_YEAR,
38         UTIMEUNIT_MONTH,
39         UTIMEUNIT_DAY,
40         UTIMEUNIT_WEEK,
41         UTIMEUNIT_HOUR,
42         UTIMEUNIT_MINUTE,
43         UTIMEUNIT_SECOND,
44         UTIMEUNIT_FIELD_COUNT
45     };
46 
47     /**
48      * Create Instance.
49      * @param timeUnitField  time unit field based on which the instance
50      *                       is created.
51      * @param status         input-output error code.
52      *                       If the timeUnitField is invalid,
53      *                       then this will be set to U_ILLEGAL_ARGUMENT_ERROR.
54      * @return               a TimeUnit instance
55      * @stable ICU 4.2
56      */
57     static TimeUnit* U_EXPORT2 createInstance(UTimeUnitFields timeUnitField,
58                                               UErrorCode& status);
59 
60 
61     /**
62      * Override clone.
63      * @stable ICU 4.2
64      */
65     virtual UObject* clone() const;
66 
67     /**
68      * Copy operator.
69      * @stable ICU 4.2
70      */
71     TimeUnit(const TimeUnit& other);
72 
73     /**
74      * Assignment operator.
75      * @stable ICU 4.2
76      */
77     TimeUnit& operator=(const TimeUnit& other);
78 
79     /**
80      * Returns a unique class ID for this object POLYMORPHICALLY.
81      * This method implements a simple form of RTTI used by ICU.
82      * @return The class ID for this object. All objects of a given
83      * class have the same class ID.  Objects of other classes have
84      * different class IDs.
85      * @stable ICU 4.2
86      */
87     virtual UClassID getDynamicClassID() const;
88 
89     /**
90      * Returns the class ID for this class. This is used to compare to
91      * the return value of getDynamicClassID().
92      * @return The class ID for all objects of this class.
93      * @stable ICU 4.2
94      */
95     static UClassID U_EXPORT2 getStaticClassID();
96 
97 
98     /**
99      * Get time unit field.
100      * @return time unit field.
101      * @stable ICU 4.2
102      */
103     UTimeUnitFields getTimeUnitField() const;
104 
105     /**
106      * Destructor.
107      * @stable ICU 4.2
108      */
109     virtual ~TimeUnit();
110 
111 private:
112     UTimeUnitFields fTimeUnitField;
113 
114     /**
115      * Constructor
116      * @internal ICU 4.2
117      */
118     TimeUnit(UTimeUnitFields timeUnitField);
119 
120 };
121 
122 
123 U_NAMESPACE_END
124 
125 #endif /* #if !UCONFIG_NO_FORMATTING */
126 
127 #endif // __TMUNIT_H__
128 //eof
129 //
130