diff options
| author | Amlal <amlal.elmahrouss@icloud.com> | 2025-02-17 08:11:16 +0100 |
|---|---|---|
| committer | Amlal <amlal.elmahrouss@icloud.com> | 2025-02-17 08:11:16 +0100 |
| commit | 2a2c3d58388579d19a7310684521dc57299969d2 (patch) | |
| tree | a638ed7922ef33f53ad55810c22ad6dc0f47dbfd /dev/Usr | |
| parent | a89eca1c9755eb781ab49572612afa90dfa6ea31 (diff) | |
ADD: Atom.h in LibCF, Atom.h in NewKit and LibCF stores the value as a bit.
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/Usr')
| -rw-r--r-- | dev/Usr/LibCF/Atom.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/dev/Usr/LibCF/Atom.h b/dev/Usr/LibCF/Atom.h new file mode 100644 index 00000000..9dde247e --- /dev/null +++ b/dev/Usr/LibCF/Atom.h @@ -0,0 +1,47 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. + +------------------------------------------- */ +#pragma once + +#include <LibCF/Core.h> + +namespace LibCF +{ + template <typename T> + class CFAtom final + { + public: + explicit CFAtom() = default; + ~CFAtom() = default; + + public: + CFAtom& operator=(const CFAtom&) = delete; + CFAtom(const CFAtom&) = delete; + + public: + T operator[](SizeT bit) + { + return (fArrayOfAtoms & (1 << bit)); + } + + void operator|(SizeT bit) + { + fArrayOfAtoms |= (1 << bit); + } + + friend Boolean operator==(CFAtom<T>& atomic, const T& idx) + { + return atomic[idx] == idx; + } + + friend Boolean operator!=(CFAtom<T>& atomic, const T& idx) + { + return atomic[idx] == idx; + } + + private: + T fArrayOfAtoms; + }; +} // namespace LibCF |
