GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / o3tl / qa / cow_wrapper_clients.hxx
blobe2dad61d23bd76353c070770c9ea4895cc67ec2a
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 #ifndef INCLUDED_COW_WRAPPER_CLIENTS_HXX
21 #define INCLUDED_COW_WRAPPER_CLIENTS_HXX
23 #include "o3tl/cow_wrapper.hxx"
25 /* Definition of Cow_Wrapper_Clients classes */
27 namespace o3tltests {
29 /** This is a header and a separate compilation unit on purpose -
30 cow_wrapper needs destructor, copy constructor and assignment
31 operator to be outline, when pimpl idiom is used
34 /// test non-opaque impl type
35 class cow_wrapper_client1
37 public:
38 cow_wrapper_client1() : maImpl() {}
39 explicit cow_wrapper_client1( int nVal ) : maImpl(nVal) {}
41 void modify( int nVal ) { *maImpl = nVal; }
42 int queryUnmodified() const { return *maImpl; }
44 void makeUnique() { maImpl.make_unique(); }
45 bool is_unique() const { return maImpl.is_unique(); }
46 oslInterlockedCount use_count() const { return maImpl.use_count(); }
47 void swap( cow_wrapper_client1& r ) { o3tl::swap(maImpl, r.maImpl); }
49 bool operator==( const cow_wrapper_client1& rRHS ) const { return maImpl == rRHS.maImpl; }
50 bool operator!=( const cow_wrapper_client1& rRHS ) const { return maImpl != rRHS.maImpl; }
51 bool operator<( const cow_wrapper_client1& rRHS ) const { return maImpl < rRHS.maImpl; }
53 private:
54 o3tl::cow_wrapper< int > maImpl;
58 class cow_wrapper_client2_impl;
60 /** test opaque impl type - need to explicitly declare lifetime
61 methods
63 class cow_wrapper_client2
65 public:
66 cow_wrapper_client2();
67 explicit cow_wrapper_client2( int nVal );
68 ~cow_wrapper_client2();
70 cow_wrapper_client2( const cow_wrapper_client2& );
71 cow_wrapper_client2& operator=( const cow_wrapper_client2& );
73 void modify( int nVal );
74 int queryUnmodified() const;
76 void makeUnique();
77 bool is_unique() const;
78 oslInterlockedCount use_count() const;
79 void swap( cow_wrapper_client2& r );
81 bool operator==( const cow_wrapper_client2& rRHS ) const;
82 bool operator!=( const cow_wrapper_client2& rRHS ) const;
83 bool operator<( const cow_wrapper_client2& rRHS ) const;
85 private:
86 o3tl::cow_wrapper< cow_wrapper_client2_impl > maImpl;
89 /** test MT-safe cow_wrapper - basically the same as
90 cow_wrapper_client2, only with different refcounting policy
92 class cow_wrapper_client3
94 public:
95 cow_wrapper_client3();
96 explicit cow_wrapper_client3( int nVal );
97 ~cow_wrapper_client3();
99 cow_wrapper_client3( const cow_wrapper_client3& );
100 cow_wrapper_client3& operator=( const cow_wrapper_client3& );
102 void modify( int nVal );
103 int queryUnmodified() const;
105 void makeUnique();
106 bool is_unique() const;
107 oslInterlockedCount use_count() const;
108 void swap( cow_wrapper_client3& r );
110 bool operator==( const cow_wrapper_client3& rRHS ) const;
111 bool operator!=( const cow_wrapper_client3& rRHS ) const;
112 bool operator<( const cow_wrapper_client3& rRHS ) const;
114 private:
115 o3tl::cow_wrapper< cow_wrapper_client2_impl, o3tl::ThreadSafeRefCountingPolicy > maImpl;
118 /** test default-object comparison - have default-ctored-client4 share
119 the same static impl instance, check if isDefault does the right
120 thing
122 class cow_wrapper_client4
124 public:
125 cow_wrapper_client4();
126 explicit cow_wrapper_client4(int);
127 ~cow_wrapper_client4();
129 cow_wrapper_client4( const cow_wrapper_client4& );
130 cow_wrapper_client4& operator=( const cow_wrapper_client4& );
132 bool is_default() const;
134 bool operator==( const cow_wrapper_client4& rRHS ) const;
135 bool operator!=( const cow_wrapper_client4& rRHS ) const;
136 bool operator<( const cow_wrapper_client4& rRHS ) const;
138 private:
139 o3tl::cow_wrapper< int > maImpl;
142 } // namespace o3tltests
144 #endif /* INCLUDED_COW_WRAPPER_CLIENTS_HXX */
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */