2017-08-05 13:09:50 +00:00
|
|
|
#include <nx/MiscFlagsHandler.h>
|
2017-07-12 14:02:10 +00:00
|
|
|
|
|
|
|
nx::MiscFlagsHandler::MiscFlagsHandler() :
|
|
|
|
mIsSet(false)
|
|
|
|
{}
|
|
|
|
|
2018-06-24 15:01:16 +00:00
|
|
|
void nx::MiscFlagsHandler::operator=(const MiscFlagsHandler & other)
|
2017-07-15 08:28:01 +00:00
|
|
|
{
|
2018-06-24 15:01:16 +00:00
|
|
|
mIsSet = other.mIsSet;
|
|
|
|
mFlags = other.mFlags;
|
2017-07-15 08:28:01 +00:00
|
|
|
}
|
|
|
|
|
2018-06-24 15:01:16 +00:00
|
|
|
bool nx::MiscFlagsHandler::operator==(const MiscFlagsHandler & other) const
|
2017-07-15 08:28:01 +00:00
|
|
|
{
|
2018-06-24 15:01:16 +00:00
|
|
|
return (mIsSet == other.mIsSet) \
|
|
|
|
&& (mFlags == other.mFlags);
|
2017-07-15 08:28:01 +00:00
|
|
|
}
|
|
|
|
|
2018-06-24 15:01:16 +00:00
|
|
|
bool nx::MiscFlagsHandler::operator!=(const MiscFlagsHandler & other) const
|
2017-07-15 08:28:01 +00:00
|
|
|
{
|
2018-06-24 15:01:16 +00:00
|
|
|
return !(*this == other);
|
2017-07-15 08:28:01 +00:00
|
|
|
}
|
|
|
|
|
2018-06-29 04:24:39 +00:00
|
|
|
void nx::MiscFlagsHandler::importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps)
|
2017-07-12 14:02:10 +00:00
|
|
|
{
|
2018-06-24 15:01:16 +00:00
|
|
|
if (caps.size() > kMaxKernelCapNum)
|
2017-07-12 14:02:10 +00:00
|
|
|
{
|
|
|
|
throw fnd::Exception(kModuleName, "Too many kernel capabilities");
|
|
|
|
}
|
|
|
|
|
2018-06-24 15:01:16 +00:00
|
|
|
if (caps.size() == 0)
|
2017-07-12 14:02:10 +00:00
|
|
|
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();
|
2018-03-22 05:26:22 +00:00
|
|
|
for (uint32_t i = 0; i < FLAG_NUM; i++)
|
2017-07-15 08:28:01 +00:00
|
|
|
{
|
|
|
|
if ((entry.getFlags() & BIT(i)) == BIT(i))
|
|
|
|
{
|
|
|
|
mFlags.addElement((Flags)i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-12 14:02:10 +00:00
|
|
|
mIsSet = true;
|
|
|
|
}
|
|
|
|
|
2018-06-29 04:24:39 +00:00
|
|
|
void nx::MiscFlagsHandler::exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const
|
2017-07-12 14:02:10 +00:00
|
|
|
{
|
|
|
|
if (isSet() == false)
|
|
|
|
return;
|
|
|
|
|
2017-07-15 08:28:01 +00:00
|
|
|
// convert list to word flags
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t flag = 0;
|
2018-06-24 15:01:16 +00:00
|
|
|
for (size_t i = 0; i < mFlags.size(); i++)
|
2017-07-15 08:28:01 +00:00
|
|
|
{
|
|
|
|
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;
|
2018-06-24 15:01:16 +00:00
|
|
|
}
|