diff options
Diffstat (limited to 'src/kernel/NeKit/Atom.h')
| -rw-r--r-- | src/kernel/NeKit/Atom.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/kernel/NeKit/Atom.h b/src/kernel/NeKit/Atom.h new file mode 100644 index 00000000..0f8eefbc --- /dev/null +++ b/src/kernel/NeKit/Atom.h @@ -0,0 +1,33 @@ +/* ======================================== + + Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +======================================== */ +#pragma once + +#include <NeKit/Defines.h> + +namespace Kernel { +template <typename T> +class Atom final { + public: + explicit Atom() = default; + ~Atom() = default; + + public: + Atom& operator=(const Atom&) = delete; + Atom(const Atom&) = delete; + + public: + T operator[](Size bit) { return (fArrayOfAtoms & (1 << bit)); } + + void operator|(Size bit) { fArrayOfAtoms |= (1 << bit); } + + friend Boolean operator==(Atom<T>& atomic, const T& idx) { return atomic[idx] == idx; } + + friend Boolean operator!=(Atom<T>& atomic, const T& idx) { return atomic[idx] == idx; } + + private: + T fArrayOfAtoms; +}; +} // namespace Kernel |
