|
Hymn to Beauty
C++ 3D Engine
|
#include <LockBox.hpp>
Classes | |
| class | Key |
Public Member Functions | |
| LockBox ()=default | |
| Constructor that defaults to referencing no data. More... | |
| LockBox (std::shared_ptr< Key > key, T *data) | |
| Constructor. More... | |
| LockBox (const LockBox< T > &other) | |
| Make a new reference to an existing lockbox. More... | |
| LockBox (LockBox< T > &&other) | |
| LockBox< T > & | operator= (LockBox< T > rhs) |
| Replace the currently held reference with a new one. More... | |
| ~LockBox () | |
| bool | Open (std::shared_ptr< Key > key, const std::function< void(T &)> &forValidKey) |
| Open a box to access underlying contents. More... | |
| uint32_t | RefCount () const |
| Number of lockboxes with the same reference. More... | |
Friends | |
| void | swap (LockBox< T > &first, LockBox< T > &second) |
| Swap two lockboxes with each other. More... | |
Restricts access to data by protecting it with a key. Only those with the correct key may access the data, allowing the user to define the set of owners according to how the key is distributed. Others may keep a reference to the data by holding a lockbox, but without the key they have no way to be granted access to the inner contents, and must turn to an owner to work with it instead.
|
default |
Constructor that defaults to referencing no data.
| Utility::LockBox< T >::LockBox | ( | std::shared_ptr< Key > | key, |
| T * | data | ||
| ) |
| Utility::LockBox< T >::LockBox | ( | const LockBox< T > & | other | ) |
Make a new reference to an existing lockbox.
| other | Existing LockBox whose data is referenced. |
| Utility::LockBox< T >::LockBox | ( | LockBox< T > && | other | ) |
| Utility::LockBox< T >::~LockBox |
Destroys a LockBox, increasing the reference count. Note that the wrapped object is not deleted since the box is only a thin wrapper.
| bool Utility::LockBox< T >::Open | ( | std::shared_ptr< Key > | key, |
| const std::function< void(T &)> & | forValidKey | ||
| ) |
Open a box to access underlying contents.
| key | A key that must match the box. |
| forValidKey | If |key| is valid, this function is called, passing a reference to the box contents. |
| LockBox< T > & Utility::LockBox< T >::operator= | ( | LockBox< T > | rhs | ) |
| uint32_t Utility::LockBox< T >::RefCount |
Number of lockboxes with the same reference.
Swap two lockboxes with each other.
| first | First lockbox to swap. |
| second | Second lockbox to swap. |