2017-07-12 14:02:10 +00:00
|
|
|
#include "MiscFlagsHandler.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nx::MiscFlagsHandler::MiscFlagsHandler() :
|
|
|
|
mIsSet(false)
|
|
|
|
{}
|
|
|
|
|
2017-07-15 08:28:01 +00:00
|
|
|
bool nx::MiscFlagsHandler::operator==(const MiscFlagsHandler & other) const
|
|
|
|
{
|
|
|
|
return isEqual(other);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nx::MiscFlagsHandler::operator!=(const MiscFlagsHandler & other) const
|
|
|
|
{
|
|
|
|
return !isEqual(other);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nx::MiscFlagsHandler::operator=(const MiscFlagsHandler & other)
|
|
|
|
{
|
|
|
|
copyFrom(other);
|
|
|
|
}
|
|
|
|
|
2017-07-12 14:02:10 +00:00
|
|
|
void nx::MiscFlagsHandler::importKernelCapabilityList(const fnd::List<KernelCapability>& caps)
|
|
|
|
{
|
|
|
|
if (caps.getSize() > kMaxKernelCapNum)
|
|
|
|
{
|
|
|
|
throw fnd::Exception(kModuleName, "Too many kernel capabilities");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (caps.getSize() == 0)
|
|
|
|
return;
|
|
|
|
|
2017-07-15 08:28:01 +00:00
|
|
|
MiscFlagsEntry entry;
|
|
|
|
entry.setKernelCapability(caps[0]);
|
2017-07-12 14:02:10 +00:00
|
|
|
|
2017-07-15 08:28:01 +00:00
|
|
|
clear();
|
|
|
|
for (u32 i = 0; i < FLAG_NUM; i++)
|
|
|
|
{
|
|
|
|
if ((entry.getFlags() & BIT(i)) == BIT(i))
|
|
|
|
{
|
|
|
|
mFlags.addElement((Flags)i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-12 14:02:10 +00:00
|
|
|
mIsSet = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nx::MiscFlagsHandler::exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const
|
|
|
|
{
|
|
|
|
if (isSet() == false)
|
|
|
|
return;
|
|
|
|
|
2017-07-15 08:28:01 +00:00
|
|
|
// convert list to word flags
|
|
|
|
u32 flag;
|
|
|
|
for (size_t i = 0; i < mFlags.getSize(); i++)
|
|
|
|
{
|
|
|
|
flag |= BIT(mFlags[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// create MiscFlag entry
|
|
|
|
MiscFlagsEntry entry;
|
|
|
|
entry.setFlags(flag);
|
|
|
|
|
|
|
|
// add to list
|
|
|
|
caps.addElement(entry.getKernelCapability());
|
2017-07-12 14:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void nx::MiscFlagsHandler::clear()
|
|
|
|
{
|
|
|
|
mIsSet = false;
|
2017-07-15 08:28:01 +00:00
|
|
|
mFlags.clear();
|
2017-07-12 14:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool nx::MiscFlagsHandler::isSet() const
|
|
|
|
{
|
|
|
|
return mIsSet;
|
|
|
|
}
|
|
|
|
|
2017-07-15 08:28:01 +00:00
|
|
|
const fnd::List<nx::MiscFlagsHandler::Flags>& nx::MiscFlagsHandler::getFlagList() const
|
2017-07-12 14:02:10 +00:00
|
|
|
{
|
2017-07-15 08:28:01 +00:00
|
|
|
return mFlags;
|
2017-07-12 14:02:10 +00:00
|
|
|
}
|
|
|
|
|
2017-07-15 08:28:01 +00:00
|
|
|
void nx::MiscFlagsHandler::setFlagList(fnd::List<Flags> flags)
|
2017-07-12 14:02:10 +00:00
|
|
|
{
|
2017-07-15 08:28:01 +00:00
|
|
|
mFlags = flags;
|
2017-07-12 14:02:10 +00:00
|
|
|
mIsSet = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nx::MiscFlagsHandler::copyFrom(const MiscFlagsHandler & other)
|
|
|
|
{
|
|
|
|
mIsSet = other.mIsSet;
|
2017-07-15 08:28:01 +00:00
|
|
|
mFlags = other.mFlags;
|
2017-07-12 14:02:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool nx::MiscFlagsHandler::isEqual(const MiscFlagsHandler & other) const
|
|
|
|
{
|
|
|
|
return (mIsSet == other.mIsSet) \
|
2017-07-15 08:28:01 +00:00
|
|
|
&& (mFlags == other.mFlags);
|
2017-07-12 14:02:10 +00:00
|
|
|
}
|