Optimized Button class. Added IsPressed and GetPressed methods.

This commit is contained in:
2024-08-04 00:47:38 -07:00
parent 3970b8d402
commit 8d4420528a
14 changed files with 240 additions and 52 deletions

View File

@@ -7,44 +7,68 @@ namespace ehs
{
}
Button::Button(const Str_8& name)
: name(name), hash(name.Hash_32())
Button::Button(Str_8 name)
: hash(name.Hash_32()), name((Str_8 &&)name)
{
}
Button::Button(const Button& key)
: name(key.name), hash(key.hash)
Button::Button(Button &&key) noexcept
: hash(key.hash), name((Str_8 &&)key.name)
{
key.hash = 0;
}
Button::Button(const Button &key)
: hash(key.hash), name(key.name)
{
}
Button& Button::operator=(const Button& key)
Button & Button::operator=(Button &&key) noexcept
{
if (this == &key)
return *this;
name = key.name;
hash = key.hash;
name = (Str_8 &&)key.name;
key.hash = 0;
return *this;
}
bool Button::operator==(const Button& key) const
Button &Button::operator=(const Button &key)
{
if (this == &key)
return *this;
hash = key.hash;
name = key.name;
return *this;
}
bool Button::operator==(const Button &key) const
{
return key.hash == hash;
}
bool Button::operator!=(const Button& key) const
bool Button::operator!=(const Button &key) const
{
return key.hash != hash;
}
UInt_32 Button::GetHash() const
{
return hash;
}
Str_8 Button::GetName() const
{
return name;
}
UInt_32 Button::GetHash() const
bool Button::IsValid() const
{
return hash;
}
}
}