libluna: Document Attributes.h and Badge.h
This commit is contained in:
parent
b8e70996c3
commit
24f9dd22ec
@ -1,3 +1,12 @@
|
||||
/**
|
||||
* @file Attributes.h
|
||||
* @author apio (cloudapio.eu)
|
||||
* @brief Macro wrappers around GCC attributes.
|
||||
*
|
||||
* @copyright Copyright (c) 2022-2023, the Luna authors.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define _weak __attribute__((weak))
|
||||
|
@ -1,8 +1,33 @@
|
||||
/**
|
||||
* @file Badge.h
|
||||
* @author apio (cloudapio.eu)
|
||||
* @brief A simple way to control who can call functions.
|
||||
*
|
||||
* @copyright Copyright (c) 2022-2023, the Luna authors.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief A struct that can only be constructed by one type, used to control access to functions/methods.
|
||||
*
|
||||
* Example: There is a private method FooClass::foo() that you want to be callable by BarClass without making it a
|
||||
* friend.
|
||||
*
|
||||
* So, make FooClass::foo() public and make it take a Badge<BarClass> which will only be constructible by BarClass, thus
|
||||
* limiting the method even though it is public.
|
||||
*
|
||||
* @tparam T The type that can construct this badge.
|
||||
*/
|
||||
template <class T> struct Badge
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* @brief Construct a new Badge.
|
||||
*
|
||||
* This can only be done by the type T.
|
||||
*/
|
||||
constexpr Badge() = default;
|
||||
|
||||
Badge(const Badge<T>&) = delete;
|
||||
|
Loading…
Reference in New Issue
Block a user