blob: 30f8ededc1f12ddad395dfde19aa0002122eb89e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/nekernel-org/nekernel
#ifndef NEKIT_ATOM_H
#define NEKIT_ATOM_H
#include <NeKit/Config.h>
namespace Kernel {
template <class TypeAtomic>
class Atom final {
public:
explicit Atom() = default;
~Atom() = default;
public:
Atom& operator=(const Atom&) = delete;
Atom(const Atom&) = delete;
public:
using Type = TypeAtomic;
using Ref = TypeAtomic&;
using ConstRef = const TypeAtomic&;
const TypeAtomic& operator[](const SizeT& bit) { return (fArrayOfAtoms & (1 << bit)); }
void operator|(const SizeT& bit) { fArrayOfAtoms |= (1 << bit); }
Atom& operator|=(const SizeT& bit) {
this->operator|(bit);
return *this;
}
friend bool operator==(Atom<TypeAtomic>& atomic, const TypeAtomic& idx) {
return atomic[idx] == idx;
}
friend bool operator!=(Atom<TypeAtomic>& atomic, const TypeAtomic& idx) {
return atomic[idx] != idx;
}
private:
TypeAtomic fArrayOfAtoms;
};
} // namespace Kernel
#endif
|