Fix typo
[LibreOffice.git] / o3tl / qa / cow_wrapper_clients.cxx
blob913165c83c562ad87e4666697a96e54cd324b134
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "cow_wrapper_clients.hxx"
21 #include <rtl/instance.hxx>
23 namespace o3tltests {
25 class cow_wrapper_client2_impl
27 public:
28 cow_wrapper_client2_impl() : mnValue(0) {}
29 explicit cow_wrapper_client2_impl( int nVal ) : mnValue(nVal) {}
30 void setValue( int nVal ) { mnValue = nVal; }
31 int getValue() const { return mnValue; }
33 bool operator==( const cow_wrapper_client2_impl& rRHS ) const { return mnValue == rRHS.mnValue; }
34 bool operator!=( const cow_wrapper_client2_impl& rRHS ) const { return mnValue != rRHS.mnValue; }
35 bool operator<( const cow_wrapper_client2_impl& rRHS ) const { return mnValue < rRHS.mnValue; }
37 private:
38 int mnValue;
41 cow_wrapper_client2::cow_wrapper_client2() : maImpl()
45 cow_wrapper_client2::cow_wrapper_client2( int nVal ) :
46 maImpl( cow_wrapper_client2_impl(nVal) )
50 cow_wrapper_client2::~cow_wrapper_client2()
54 cow_wrapper_client2::cow_wrapper_client2( const cow_wrapper_client2& rSrc ) :
55 maImpl(rSrc.maImpl)
59 cow_wrapper_client2::cow_wrapper_client2( cow_wrapper_client2&& rSrc ) noexcept :
60 maImpl( std::move( rSrc.maImpl ) )
64 cow_wrapper_client2& cow_wrapper_client2::operator=( const cow_wrapper_client2& rSrc )
66 maImpl = rSrc.maImpl;
68 return *this;
71 cow_wrapper_client2& cow_wrapper_client2::operator=(cow_wrapper_client2&& rSrc) noexcept
73 maImpl = std::move(rSrc.maImpl);
75 return *this;
78 void cow_wrapper_client2::modify( int nVal )
80 maImpl->setValue( nVal );
83 int cow_wrapper_client2::queryUnmodified() const
85 return maImpl->getValue();
88 void cow_wrapper_client2::makeUnique()
90 maImpl.make_unique();
92 bool cow_wrapper_client2::is_unique() const
94 return maImpl.is_unique();
96 oslInterlockedCount cow_wrapper_client2::use_count() const
98 return maImpl.use_count();
100 void cow_wrapper_client2::swap( cow_wrapper_client2& r )
102 o3tl::swap(maImpl, r.maImpl);
105 bool cow_wrapper_client2::operator==( const cow_wrapper_client2& rRHS ) const
107 return maImpl == rRHS.maImpl;
109 bool cow_wrapper_client2::operator!=( const cow_wrapper_client2& rRHS ) const
111 return maImpl != rRHS.maImpl;
113 bool cow_wrapper_client2::operator<( const cow_wrapper_client2& rRHS ) const
115 return maImpl < rRHS.maImpl;
119 cow_wrapper_client3::cow_wrapper_client3() : maImpl()
123 cow_wrapper_client3::cow_wrapper_client3( int nVal ) :
124 maImpl( cow_wrapper_client2_impl(nVal) )
128 cow_wrapper_client3::~cow_wrapper_client3()
132 cow_wrapper_client3::cow_wrapper_client3( const cow_wrapper_client3& rSrc ) :
133 maImpl(rSrc.maImpl)
137 cow_wrapper_client3::cow_wrapper_client3( cow_wrapper_client3&& rSrc ) noexcept :
138 maImpl( std::move( rSrc.maImpl ) )
142 cow_wrapper_client3& cow_wrapper_client3::operator=( const cow_wrapper_client3& rSrc )
144 maImpl = rSrc.maImpl;
146 return *this;
149 cow_wrapper_client3& cow_wrapper_client3::operator=(cow_wrapper_client3&& rSrc) noexcept
151 maImpl = std::move(rSrc.maImpl);
153 return *this;
156 void cow_wrapper_client3::modify( int nVal )
158 maImpl->setValue( nVal );
161 int cow_wrapper_client3::queryUnmodified() const
163 return maImpl->getValue();
166 void cow_wrapper_client3::makeUnique()
168 maImpl.make_unique();
170 bool cow_wrapper_client3::is_unique() const
172 return maImpl.is_unique();
174 oslInterlockedCount cow_wrapper_client3::use_count() const
176 return maImpl.use_count();
178 void cow_wrapper_client3::swap( cow_wrapper_client3& r )
180 o3tl::swap(maImpl, r.maImpl);
183 bool cow_wrapper_client3::operator==( const cow_wrapper_client3& rRHS ) const
185 return maImpl == rRHS.maImpl;
187 bool cow_wrapper_client3::operator!=( const cow_wrapper_client3& rRHS ) const
189 return maImpl != rRHS.maImpl;
191 bool cow_wrapper_client3::operator<( const cow_wrapper_client3& rRHS ) const
193 return maImpl < rRHS.maImpl;
197 namespace { struct theDefaultClient4 : public rtl::Static< o3tl::cow_wrapper< int >,
198 theDefaultClient4 > {}; }
200 cow_wrapper_client4::cow_wrapper_client4() :
201 maImpl(theDefaultClient4::get())
205 cow_wrapper_client4::cow_wrapper_client4( int nVal ) :
206 maImpl( nVal )
210 cow_wrapper_client4::~cow_wrapper_client4()
214 cow_wrapper_client4::cow_wrapper_client4( const cow_wrapper_client4& rSrc ) :
215 maImpl(rSrc.maImpl)
219 cow_wrapper_client4& cow_wrapper_client4::operator=( const cow_wrapper_client4& rSrc )
221 maImpl = rSrc.maImpl;
223 return *this;
226 bool cow_wrapper_client4::is_default() const
228 return maImpl.same_object(theDefaultClient4::get());
231 bool cow_wrapper_client4::operator==( const cow_wrapper_client4& rRHS ) const
233 return maImpl == rRHS.maImpl;
235 bool cow_wrapper_client4::operator!=( const cow_wrapper_client4& rRHS ) const
237 return maImpl != rRHS.maImpl;
239 bool cow_wrapper_client4::operator<( const cow_wrapper_client4& rRHS ) const
241 return maImpl < rRHS.maImpl;
244 bool BogusRefCountPolicy::s_bShouldIncrement = false;
245 bool BogusRefCountPolicy::s_bShouldDecrement = false;
246 sal_uInt32 BogusRefCountPolicy::s_nEndOfScope = 0;
248 cow_wrapper_client5::cow_wrapper_client5() :
249 maImpl()
253 cow_wrapper_client5::cow_wrapper_client5(int nX) :
254 maImpl(nX)
258 cow_wrapper_client5::cow_wrapper_client5( const cow_wrapper_client5& rSrc ) :
259 maImpl( rSrc.maImpl )
263 cow_wrapper_client5::cow_wrapper_client5( cow_wrapper_client5&& rSrc ) noexcept :
264 maImpl( std::move( rSrc.maImpl ) )
268 cow_wrapper_client5::~cow_wrapper_client5()
272 cow_wrapper_client5& cow_wrapper_client5::operator=( const cow_wrapper_client5& rSrc )
274 maImpl = rSrc.maImpl;
276 return *this;
279 cow_wrapper_client5& cow_wrapper_client5::operator=(cow_wrapper_client5&& rSrc) noexcept
281 maImpl = std::move( rSrc.maImpl );
283 return *this;
286 bool cow_wrapper_client5::operator==( const cow_wrapper_client5& rSrc ) const {
287 return maImpl == rSrc.maImpl;
290 bool cow_wrapper_client5::operator!=( const cow_wrapper_client5& rSrc ) const {
291 return maImpl != rSrc.maImpl;
294 } // namespace o3tltests
296 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */