BWAPI
|
#include <UnitFilter.h>
Classes | |
struct | UnitFilterTypeDef |
Public Member Functions | |
UnitFilter () | |
UnitFilter (BWAPI::UnitType type) | |
UnitFilter (UnitFilterFlags::type flags) | |
UnitFilter (const UnitFilter &other) | |
UnitFilter & | operator= (const UnitFilter &other) |
UnitFilter | operator|| (const UnitFilter &other) const |
UnitFilter | operator&& (const UnitFilter &other) const |
bool | passesFilter (const Unit &unit) const |
UnitFilter & | operator! () |
bool | operator!= (const UnitFilter &other) const |
bool | operator== (const UnitFilter &other) const |
bool | operator< (const UnitFilter &other) const |
Private Types | |
typedef SafeEnum < UnitFilterTypeDef > | UnitFilterType |
Private Member Functions | |
bool | filter (const Unit &unit) const |
UnitFilter (const UnitFilter &left, OperatorType::type opType, const UnitFilter &right) | |
Private Attributes | |
UnitFilterType | mType |
OperatorType | mOperatorType |
boost::scoped_ptr< UnitFilter > | mLFilter |
boost::scoped_ptr< UnitFilter > | mRFilter |
bool | mExpectedValue |
BWAPI::UnitType | mUnitType |
UnitFilterFlags::type | mUnitFlags |
Definition at line 28 of file UnitFilter.h.
typedef SafeEnum<UnitFilterTypeDef> UnitFilter::UnitFilterType [private] |
Definition at line 97 of file UnitFilter.h.
Definition at line 5 of file UnitFilter.cpp.
: mType(UnitFilterType::None) , mOperatorType(OperatorType::None) , mLFilter() , mRFilter() , mExpectedValue(true) , mUnitType(BWAPI::UnitTypes::None) , mUnitFlags(UnitFilterFlags::None) { }
Definition at line 16 of file UnitFilter.cpp.
: mType(UnitFilterType::UnitOfType) , mOperatorType(OperatorType::None) , mLFilter() , mRFilter() , mExpectedValue(true) , mUnitType(type) , mUnitFlags(UnitFilterFlags::None) { }
Definition at line 27 of file UnitFilter.cpp.
: mType(UnitFilterType::PassesFlags) , mOperatorType(OperatorType::None) , mLFilter() , mRFilter() , mExpectedValue(true) , mUnitType(BWAPI::UnitTypes::None) , mUnitFlags(flags) { }
UnitFilter::UnitFilter | ( | const UnitFilter & | other | ) | [inline] |
Definition at line 35 of file UnitFilter.h.
: mType(other.mType) , mOperatorType(other.mOperatorType) , mLFilter(other.mLFilter ? new UnitFilter(*other.mLFilter) : NULL) , mRFilter(other.mRFilter ? new UnitFilter(*other.mRFilter) : NULL) , mExpectedValue(other.mExpectedValue) , mUnitType(other.mUnitType) , mUnitFlags(other.mUnitFlags) {}
UnitFilter::UnitFilter | ( | const UnitFilter & | left, |
OperatorType::type | opType, | ||
const UnitFilter & | right | ||
) | [inline, private] |
Definition at line 112 of file UnitFilter.h.
: mType(UnitFilterType::None) , mOperatorType(opType) , mLFilter(new UnitFilter(left)) , mRFilter(new UnitFilter(right)) , mExpectedValue(true) , mUnitType(BWAPI::UnitTypes::None) , mUnitFlags(UnitFilterFlags::None) {}
bool UnitFilter::filter | ( | const Unit & | unit | ) | const [private] |
Definition at line 109 of file UnitFilter.cpp.
References UnitFilterFlags::CanAttackAir, UnitFilterFlags::CanAttackGround, UnitFilterFlags::HasAddon, UnitHelper::isArmyUnit(), UnitFilterFlags::IsArmyUnit, UnitFilterFlags::IsComplete, UnitFilterFlags::IsLifted, UnitFilterFlags::IsSpellCaster, UnitFilterFlags::IsWorker, mExpectedValue, mType, mUnitFlags, mUnitType, BWAPI::BulletTypes::None, and SafeEnum< def, inner >::underlying().
{ switch(mType.underlying()) { case UnitFilterType::None: return mExpectedValue; case UnitFilterType::UnitOfType: return (unit->getType() == mUnitType) == mExpectedValue; case UnitFilterType::PassesFlags: { if((mUnitFlags & UnitFilterFlags::IsComplete) != 0 && unit->isCompleted() != mExpectedValue) return false; if((mUnitFlags & UnitFilterFlags::HasAddon) != 0 && unit->hasAddon() != mExpectedValue) return false; if((mUnitFlags & UnitFilterFlags::IsLifted) != 0 && unit->isLifted() != mExpectedValue) return false; if((mUnitFlags & UnitFilterFlags::IsWorker) != 0 && unit->getType().isWorker() != mExpectedValue) return false; if((mUnitFlags & UnitFilterFlags::IsArmyUnit) != 0 && UnitHelper::isArmyUnit(unit->getType()) != mExpectedValue) return false; if((mUnitFlags & UnitFilterFlags::CanAttackGround) != 0 && unit->canAttackGround() != mExpectedValue) return false; if((mUnitFlags & UnitFilterFlags::CanAttackAir) != 0 && unit->canAttackAir() != mExpectedValue) return false; if((mUnitFlags & UnitFilterFlags::IsSpellCaster) != 0 && unit->getType().isSpellcaster() != mExpectedValue) return false; return true; } } return false; }
Definition at line 38 of file UnitFilter.cpp.
References mExpectedValue.
{ mExpectedValue = !mExpectedValue; return *this; }
bool UnitFilter::operator!= | ( | const UnitFilter & | other | ) | const |
Definition at line 44 of file UnitFilter.cpp.
References operator==().
{ return !operator==(other); }
UnitFilter UnitFilter::operator&& | ( | const UnitFilter & | other | ) | const [inline] |
Definition at line 65 of file UnitFilter.h.
References OperatorTypeDef::And.
{ return UnitFilter(*this, OperatorType::And, other); }
bool UnitFilter::operator< | ( | const UnitFilter & | other | ) | const |
Definition at line 69 of file UnitFilter.cpp.
References mExpectedValue, mLFilter, mOperatorType, mRFilter, mType, mUnitFlags, and mUnitType.
{ if(mType < other.mType) return true; else if(mType != other.mType) return false; if(mOperatorType < other.mOperatorType) return true; else if(mOperatorType != other.mOperatorType) return false; if(*mLFilter < *other.mLFilter) return true; else if(*mLFilter != *other.mLFilter) return false; if(*mRFilter < *other.mRFilter) return true; else if(*mRFilter != *other.mRFilter) return false; if(mExpectedValue < other.mExpectedValue) return true; else if(mExpectedValue != other.mExpectedValue) return false; if(mUnitType < other.mUnitType) return true; else if(mUnitType != other.mUnitType) return false; if(mUnitFlags < other.mUnitFlags) return true; else if(mUnitFlags != other.mUnitFlags) return false; return false; }
UnitFilter& UnitFilter::operator= | ( | const UnitFilter & | other | ) | [inline] |
Definition at line 45 of file UnitFilter.h.
References mExpectedValue, mLFilter, mOperatorType, mRFilter, mType, mUnitFlags, and mUnitType.
{ mType = other.mType; mOperatorType = other.mOperatorType; mExpectedValue = other.mExpectedValue; mUnitType = other.mUnitType; mUnitFlags = other.mUnitFlags; mLFilter.reset(other.mLFilter ? new UnitFilter(*other.mLFilter) : NULL); mRFilter.reset(other.mRFilter ? new UnitFilter(*other.mRFilter) : NULL); return *this; }
bool UnitFilter::operator== | ( | const UnitFilter & | other | ) | const |
Definition at line 49 of file UnitFilter.cpp.
References mExpectedValue, mLFilter, mOperatorType, mRFilter, mType, mUnitFlags, and mUnitType.
Referenced by operator!=().
{ if(mType != other.mType) return false; else if(mOperatorType != other.mOperatorType) return false; else if(*mLFilter != *other.mLFilter) return false; else if(*mRFilter != *other.mRFilter) return false; else if(mExpectedValue != other.mExpectedValue) return false; else if(mUnitType != other.mUnitType) return false; else if(mUnitFlags != other.mUnitFlags) return false; else return true; }
UnitFilter UnitFilter::operator|| | ( | const UnitFilter & | other | ) | const [inline] |
Definition at line 61 of file UnitFilter.h.
References OperatorTypeDef::Or.
{ return UnitFilter(*this, OperatorType::Or, other); }
bool UnitFilter::passesFilter | ( | const Unit & | unit | ) | const [inline] |
Definition at line 70 of file UnitFilter.h.
References OperatorTypeDef::And, OperatorTypeDef::None, and OperatorTypeDef::Or.
Referenced by Requirement::earliestUnitTime().
{ if(mOperatorType == OperatorType::None) return filter(unit); else if(mOperatorType == OperatorType::And) return mLFilter->passesFilter(unit) == mExpectedValue && mRFilter->passesFilter(unit) == mExpectedValue; else if(mOperatorType == OperatorType::Or) return mLFilter->passesFilter(unit) == mExpectedValue || mRFilter->passesFilter(unit) == mExpectedValue; return false; }
bool UnitFilter::mExpectedValue [private] |
Definition at line 105 of file UnitFilter.h.
Referenced by filter(), operator!(), operator<(), operator=(), and operator==().
boost::scoped_ptr<UnitFilter> UnitFilter::mLFilter [private] |
Definition at line 102 of file UnitFilter.h.
Referenced by operator<(), operator=(), and operator==().
OperatorType UnitFilter::mOperatorType [private] |
Definition at line 101 of file UnitFilter.h.
Referenced by operator<(), operator=(), and operator==().
boost::scoped_ptr<UnitFilter> UnitFilter::mRFilter [private] |
Definition at line 103 of file UnitFilter.h.
Referenced by operator<(), operator=(), and operator==().
UnitFilterType UnitFilter::mType [private] |
Definition at line 99 of file UnitFilter.h.
Referenced by filter(), operator<(), operator=(), and operator==().
UnitFilterFlags::type UnitFilter::mUnitFlags [private] |
Definition at line 108 of file UnitFilter.h.
Referenced by filter(), operator<(), operator=(), and operator==().
BWAPI::UnitType UnitFilter::mUnitType [private] |
Definition at line 107 of file UnitFilter.h.
Referenced by filter(), operator<(), operator=(), and operator==().