Skip to content

Commit 9e3d38d

Browse files
refactor: add NonAssignableClass to define classes without assign operator
Related-To: NEO-9038 Signed-off-by: Mateusz Jablonski <[email protected]> Source: 382fc95
1 parent ac71eb7 commit 9e3d38d

File tree

8 files changed

+24
-11
lines changed

8 files changed

+24
-11
lines changed

level_zero/core/source/driver/host_pointer_manager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#pragma once
99
#include "shared/source/helpers/device_bitfield.h"
10+
#include "shared/source/helpers/non_copyable_or_moveable.h"
1011
#include "shared/source/memory_manager/multi_graphics_allocation.h"
1112
#include "shared/source/utilities/spinlock.h"
1213

@@ -25,7 +26,7 @@ class MemoryManager;
2526
namespace L0 {
2627
struct Device;
2728

28-
struct HostPointerData {
29+
struct HostPointerData : NEO::NonAssignableClass {
2930
HostPointerData(uint32_t maxRootDeviceIndex)
3031
: hostPtrAllocations(maxRootDeviceIndex),
3132
maxRootDeviceIndex(maxRootDeviceIndex) {

level_zero/sysman/source/linux/sysman_fs_access.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#pragma once
99

10+
#include "shared/source/helpers/non_copyable_or_moveable.h"
1011
#include "shared/source/os_interface/linux/sys_calls.h"
1112

1213
#include "level_zero/ze_api.h"
@@ -43,7 +44,7 @@ class FdCache {
4344
void eraseLeastUsedEntryFromCache();
4445
};
4546

46-
class FsAccess {
47+
class FsAccess : NEO::NonAssignableClass {
4748
public:
4849
static FsAccess *create();
4950
FsAccess(const FsAccess &fsAccess);

level_zero/tools/source/sysman/linux/fs_access.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#pragma once
99

10+
#include "shared/source/helpers/non_copyable_or_moveable.h"
1011
#include "shared/source/os_interface/linux/sys_calls.h"
1112

1213
#include "level_zero/ze_api.h"
@@ -43,7 +44,7 @@ class FdCache {
4344
void eraseLeastUsedEntryFromCache();
4445
};
4546

46-
class FsAccess {
47+
class FsAccess : NEO::NonAssignableClass {
4748
public:
4849
static FsAccess *create();
4950
FsAccess(const FsAccess &fsAccess);

shared/source/execution_environment/root_device_environment.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#pragma once
99
#include "shared/source/built_ins/sip_kernel_type.h"
1010
#include "shared/source/helpers/affinity_mask.h"
11+
#include "shared/source/helpers/non_copyable_or_moveable.h"
1112
#include "shared/source/helpers/options.h"
1213

1314
#include <functional>
@@ -43,13 +44,12 @@ class ReleaseHelper;
4344
struct AllocationProperties;
4445
struct HardwareInfo;
4546

46-
struct RootDeviceEnvironment {
47+
struct RootDeviceEnvironment : NonCopyableClass {
4748
protected:
4849
std::unique_ptr<HardwareInfo> hwInfo;
4950

5051
public:
5152
RootDeviceEnvironment(ExecutionEnvironment &executionEnvironment);
52-
RootDeviceEnvironment(RootDeviceEnvironment &) = delete;
5353
MOCKABLE_VIRTUAL ~RootDeviceEnvironment();
5454

5555
MOCKABLE_VIRTUAL const HardwareInfo *getHardwareInfo() const;

shared/source/helpers/non_copyable_or_moveable.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2023 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -26,4 +26,11 @@ class NonCopyableClass {
2626
NonCopyableClass(NonCopyableClass &&) = default;
2727
NonCopyableClass &operator=(NonCopyableClass &&) = default;
2828
};
29+
30+
class NonAssignableClass {
31+
public:
32+
NonAssignableClass() = default;
33+
NonAssignableClass &operator=(const NonAssignableClass &) = delete;
34+
NonAssignableClass &operator=(NonAssignableClass &&) = delete;
35+
};
2936
} // namespace NEO

shared/source/memory_manager/multi_graphics_allocation.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/*
2-
* Copyright (C) 2020-2022 Intel Corporation
2+
* Copyright (C) 2020-2023 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#pragma once
99

10+
#include "shared/source/helpers/non_copyable_or_moveable.h"
1011
#include "shared/source/memory_manager/allocation_type.h"
1112
#include "shared/source/utilities/stackvec.h"
1213

@@ -17,7 +18,7 @@ namespace NEO {
1718
class MigrationSyncData;
1819
class GraphicsAllocation;
1920

20-
class MultiGraphicsAllocation {
21+
class MultiGraphicsAllocation : NonAssignableClass {
2122
public:
2223
MultiGraphicsAllocation(uint32_t maxRootDeviceIndex);
2324
MultiGraphicsAllocation(const MultiGraphicsAllocation &multiGraphicsAllocation);

shared/source/utilities/buffer_pool_allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct SmallBuffersParams {
3232
};
3333

3434
template <typename PoolT, typename BufferType, typename BufferParentType = BufferType>
35-
struct AbstractBuffersPool : public SmallBuffersParams<PoolT>, public NonCopyableClass {
35+
struct AbstractBuffersPool : public SmallBuffersParams<PoolT>, public NonCopyableClass, NonAssignableClass {
3636
// The prototype of a function allocating the `mainStorage` is not specified.
3737
// That would be an unnecessary limitation here - it is completely up to derived class implementation.
3838
// Perhaps the allocating function needs to leverage `HeapAllocator::allocate()` and also

shared/source/utilities/range.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
/*
2-
* Copyright (C) 2018-2022 Intel Corporation
2+
* Copyright (C) 2018-2023 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#pragma once
99

10+
#include "shared/source/helpers/non_copyable_or_moveable.h"
11+
1012
#include <iterator>
1113

1214
namespace NEO {
1315

1416
template <typename DataType>
15-
struct Range {
17+
struct Range : NonAssignableClass {
1618
using iterator = DataType *;
1719
using const_iterator = const DataType *;
1820
using reverse_iterator = std::reverse_iterator<iterator>;

0 commit comments

Comments
 (0)