merge the formfield patch from ooo-build
[ooovba.git] / o3tl / qa / cow_wrapper_clients.hxx
blob6661730b3bbe17e581a3a786840d975e7eee3510
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cow_wrapper_clients.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_COW_WRAPPER_CLIENTS_HXX
32 #define INCLUDED_COW_WRAPPER_CLIENTS_HXX
34 #include "o3tl/cow_wrapper.hxx"
36 /* Definition of Cow_Wrapper_Clients classes */
38 namespace o3tltests {
40 /** This is a header and a separate compilation unit on purpose -
41 cow_wrapper needs destructor, copy constructor and assignment
42 operator to be outline, when pimpl idiom is used
45 /// test non-opaque impl type
46 class cow_wrapper_client1
48 public:
49 cow_wrapper_client1() : maImpl() {}
50 explicit cow_wrapper_client1( int nVal ) : maImpl(nVal) {}
52 void modify( int nVal ) { *maImpl = nVal; }
53 int queryUnmodified() const { return *maImpl; }
55 void makeUnique() { maImpl.make_unique(); }
56 bool is_unique() const { return maImpl.is_unique(); }
57 oslInterlockedCount use_count() const { return maImpl.use_count(); }
58 void swap( cow_wrapper_client1& r ) { o3tl::swap(maImpl, r.maImpl); }
60 bool operator==( const cow_wrapper_client1& rRHS ) const { return maImpl == rRHS.maImpl; }
61 bool operator!=( const cow_wrapper_client1& rRHS ) const { return maImpl != rRHS.maImpl; }
62 bool operator<( const cow_wrapper_client1& rRHS ) const { return maImpl < rRHS.maImpl; }
64 private:
65 o3tl::cow_wrapper< int > maImpl;
69 class cow_wrapper_client2_impl;
71 /** test opaque impl type - need to explicitely declare lifetime
72 methods
74 class cow_wrapper_client2
76 public:
77 cow_wrapper_client2();
78 explicit cow_wrapper_client2( int nVal );
79 ~cow_wrapper_client2();
81 cow_wrapper_client2( const cow_wrapper_client2& );
82 cow_wrapper_client2& operator=( const cow_wrapper_client2& );
84 void modify( int nVal );
85 int queryUnmodified() const;
87 void makeUnique();
88 bool is_unique() const;
89 oslInterlockedCount use_count() const;
90 void swap( cow_wrapper_client2& r );
92 bool operator==( const cow_wrapper_client2& rRHS ) const;
93 bool operator!=( const cow_wrapper_client2& rRHS ) const;
94 bool operator<( const cow_wrapper_client2& rRHS ) const;
96 private:
97 o3tl::cow_wrapper< cow_wrapper_client2_impl > maImpl;
100 /** test MT-safe cow_wrapper - basically the same as
101 cow_wrapper_client2, only with different refcounting policy
103 class cow_wrapper_client3
105 public:
106 cow_wrapper_client3();
107 explicit cow_wrapper_client3( int nVal );
108 ~cow_wrapper_client3();
110 cow_wrapper_client3( const cow_wrapper_client3& );
111 cow_wrapper_client3& operator=( const cow_wrapper_client3& );
113 void modify( int nVal );
114 int queryUnmodified() const;
116 void makeUnique();
117 bool is_unique() const;
118 oslInterlockedCount use_count() const;
119 void swap( cow_wrapper_client3& r );
121 bool operator==( const cow_wrapper_client3& rRHS ) const;
122 bool operator!=( const cow_wrapper_client3& rRHS ) const;
123 bool operator<( const cow_wrapper_client3& rRHS ) const;
125 private:
126 o3tl::cow_wrapper< cow_wrapper_client2_impl, o3tl::ThreadSafeRefCountingPolicy > maImpl;
129 } // namespace o3tltests
131 #endif /* INCLUDED_COW_WRAPPER_CLIENTS_HXX */