1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 **********************************************************************
5 *   Copyright (c) 2002-2005, International Business Machines Corporation
6 *   and others.  All Rights Reserved.
7 **********************************************************************
8 *   Date        Name        Description
9 *   01/14/2002  aliu        Creation.
10 **********************************************************************
11 */
12 #ifndef UNIFUNCT_H
13 #define UNIFUNCT_H
14 
15 #include "unicode/utypes.h"
16 #include "unicode/uobject.h"
17 
18 /**
19  * \file
20  * \brief C++ API: Unicode Functor
21  */
22 
23 U_NAMESPACE_BEGIN
24 
25 class UnicodeMatcher;
26 class UnicodeReplacer;
27 class TransliterationRuleData;
28 
29 /**
30  * <code>UnicodeFunctor</code> is an abstract base class for objects
31  * that perform match and/or replace operations on Unicode strings.
32  * @author Alan Liu
33  * @stable ICU 2.4
34  */
35 class U_COMMON_API UnicodeFunctor : public UObject {
36 
37 public:
38 
39     /**
40      * Destructor
41      * @stable ICU 2.4
42      */
43     virtual ~UnicodeFunctor();
44 
45     /**
46      * Return a copy of this object.  All UnicodeFunctor objects
47      * have to support cloning in order to allow classes using
48      * UnicodeFunctor to implement cloning.
49      * @stable ICU 2.4
50      */
51     virtual UnicodeFunctor* clone() const = 0;
52 
53     /**
54      * Cast 'this' to a UnicodeMatcher* pointer and return the
55      * pointer, or null if this is not a UnicodeMatcher*.  Subclasses
56      * that mix in UnicodeMatcher as a base class must override this.
57      * This protocol is required because a pointer to a UnicodeFunctor
58      * cannot be cast to a pointer to a UnicodeMatcher, since
59      * UnicodeMatcher is a mixin that does not derive from
60      * UnicodeFunctor.
61      * @stable ICU 2.4
62      */
63     virtual UnicodeMatcher* toMatcher() const;
64 
65     /**
66      * Cast 'this' to a UnicodeReplacer* pointer and return the
67      * pointer, or null if this is not a UnicodeReplacer*.  Subclasses
68      * that mix in UnicodeReplacer as a base class must override this.
69      * This protocol is required because a pointer to a UnicodeFunctor
70      * cannot be cast to a pointer to a UnicodeReplacer, since
71      * UnicodeReplacer is a mixin that does not derive from
72      * UnicodeFunctor.
73      * @stable ICU 2.4
74      */
75     virtual UnicodeReplacer* toReplacer() const;
76 
77     /**
78      * Return the class ID for this class.  This is useful only for
79      * comparing to a return value from getDynamicClassID().
80      * @return          The class ID for all objects of this class.
81      * @stable ICU 2.0
82      */
83     static UClassID U_EXPORT2 getStaticClassID(void);
84 
85     /**
86      * Returns a unique class ID <b>polymorphically</b>.  This method
87      * is to implement a simple version of RTTI, since not all C++
88      * compilers support genuine RTTI.  Polymorphic operator==() and
89      * clone() methods call this method.
90      *
91      * <p>Concrete subclasses of UnicodeFunctor should use the macro
92      *    UOBJECT_DEFINE_RTTI_IMPLEMENTATION from uobject.h to
93      *    provide definitios getStaticClassID and getDynamicClassID.
94      *
95      * @return The class ID for this object. All objects of a given
96      * class have the same class ID.  Objects of other classes have
97      * different class IDs.
98      * @stable ICU 2.4
99      */
100     virtual UClassID getDynamicClassID(void) const = 0;
101 
102     /**
103      * Set the data object associated with this functor.  The data
104      * object provides context for functor-to-standin mapping.  This
105      * method is required when assigning a functor to a different data
106      * object.  This function MAY GO AWAY later if the architecture is
107      * changed to pass data object pointers through the API.
108      * @internal ICU 2.1
109      */
110     virtual void setData(const TransliterationRuleData*) = 0;
111 
112 protected:
113 
114     /**
115      * Since this class has pure virtual functions,
116      * a constructor can't be used.
117      * @stable ICU 2.0
118      */
119     /*UnicodeFunctor();*/
120 
121 };
122 
123 /*inline UnicodeFunctor::UnicodeFunctor() {}*/
124 
125 U_NAMESPACE_END
126 
127 #endif
128