/src/mozilla-central/intl/icu/source/i18n/sharedbreakiterator.h
Line | Count | Source (jump to first uncovered line) |
1 | | // © 2016 and later: Unicode, Inc. and others. |
2 | | // License & terms of use: http://www.unicode.org/copyright.html |
3 | | /* |
4 | | ****************************************************************************** |
5 | | * Copyright (C) 2014, International Business Machines |
6 | | * Corporation and others. All Rights Reserved. |
7 | | ****************************************************************************** |
8 | | * sharedbreakiterator.h |
9 | | */ |
10 | | |
11 | | #ifndef __SHARED_BREAKITERATOR_H__ |
12 | | #define __SHARED_BREAKITERATOR_H__ |
13 | | |
14 | | #include "unicode/utypes.h" |
15 | | #include "sharedobject.h" |
16 | | |
17 | | #if !UCONFIG_NO_BREAK_ITERATION |
18 | | |
19 | | U_NAMESPACE_BEGIN |
20 | | |
21 | | class BreakIterator; |
22 | | |
23 | | // SharedBreakIterator encapsulates a shared BreakIterator. Because |
24 | | // BreakIterator has mutable semantics, clients must ensure that all uses |
25 | | // of a particular shared BreakIterator is protected by the same mutex |
26 | | // ensuring that only one thread at a time gets access to that shared |
27 | | // BreakIterator. Clients can accomplish this by creating a mutex for all |
28 | | // uses of break iterator within a particular class. Then objects of that |
29 | | // class may then freely share break iterators among themselves. However, |
30 | | // these shared break iterators must never be exposed outside of that class. |
31 | | class U_I18N_API SharedBreakIterator : public SharedObject { |
32 | | public: |
33 | | SharedBreakIterator(BreakIterator *biToAdopt); |
34 | | virtual ~SharedBreakIterator(); |
35 | | |
36 | 0 | BreakIterator *get() const { return ptr; } |
37 | 0 | BreakIterator *operator->() const { return ptr; } |
38 | 0 | BreakIterator &operator*() const { return *ptr; } |
39 | | private: |
40 | | BreakIterator *ptr; |
41 | | SharedBreakIterator(const SharedBreakIterator &); |
42 | | SharedBreakIterator &operator=(const SharedBreakIterator &); |
43 | | }; |
44 | | |
45 | | U_NAMESPACE_END |
46 | | |
47 | | #endif |
48 | | |
49 | | #endif |