QcComponent Class
template <typename T> class QcComponentOptional state T of one kind of creature, kept on the heap (decision E-423): only the creatures of that kind carry it (a villager its QcVillager), the others pay one pointer. More...
| Header: | #include <server/entities/QcComponent.h> |
Public Functions
| QcComponent() | |
| QcComponent(QcComponent<T> &&) | |
| ~QcComponent() | |
| T & | emplace(Args &&... args) |
| T * | get() |
| const T * | get() const |
| bool | has() const |
| void | reset() |
| operator bool() const | |
| T & | operator*() |
| const T & | operator*() const |
| T * | operator->() |
| const T * | operator->() const |
| QcComponent<T> & | operator=(QcComponent<T> &&) |
| QcComponent<T> & | operator=(const QcComponent<T> &other) |
Detailed Description
Copies are deep, so a creature with components copies like a value (QList<QcCreature>). The saved form of a component is its frame in the creature's entry (QcComponentFrames, decision E-420).
Member Function Documentation
[default] QcComponent::QcComponent()
Default-constructs an instance of QcComponent.
[noexcept default] QcComponent::QcComponent(QcComponent<T> &&)
Move-constructs an instance of QcComponent.
[default] QcComponent::~QcComponent()
Destroys the instance of QcComponent.
template <typename... Args> T &QcComponent::emplace(Args &&... args)
Gives the creature the component made from args (replacing one it had). Returns it.
T *QcComponent::get()
Returns the state; nullptr when the creature has none.
const T *QcComponent::get() const
Returns the state, read-only; nullptr when the creature has none.
bool QcComponent::has() const
Returns whether the creature has the component.
void QcComponent::reset()
Takes the component away.
[explicit] QcComponent::operator bool() const
Returns whether the creature has the component.
T &QcComponent::operator*()
Returns the state; only while the creature has it.
const T &QcComponent::operator*() const
Returns the state, read-only; only while the creature has it.
T *QcComponent::operator->()
Returns a pointer to the state; only while the creature has it.
const T *QcComponent::operator->() const
Returns a pointer to the state, read-only; only while the creature has it.
[noexcept default] QcComponent<T> &QcComponent::operator=(QcComponent<T> &&)
Move-assigns other to this QcComponent instance.
QcComponent<T> &QcComponent::operator=(const QcComponent<T> &other)
Copies the state of other deeply (or none). Returns this component.