1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/test/mock/mock_BonusBearer.cpp
John Bolton 6d8f1e4530 Fixed incorrect usage of const std::shared_ptr. Resolves 0003142.
Replaced const TBonusListPtr with TConstBonusListPtr where necessary
Replaced const std::shared_ptr<T> with std::shared_ptr<const T> where necessary.
Removed superfluous use of const.
Replaced const std::shared_ptr<T> with const std::shared_ptr<T> & in function parameters and ranged for-loops.
2020-09-30 22:56:28 -07:00

48 lines
990 B
C++

/*
* mock_BonusBearer.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "mock_BonusBearer.h"
BonusBearerMock::BonusBearerMock()
: treeVersion(1),
cachedLast(0)
{
}
BonusBearerMock::~BonusBearerMock() = default;
void BonusBearerMock::addNewBonus(const std::shared_ptr<Bonus> & b)
{
bonuses.push_back(b);
treeVersion++;
}
TConstBonusListPtr BonusBearerMock::getAllBonuses(const CSelector & selector, const CSelector & limit, const CBonusSystemNode * root, const std::string & cachingStr) const
{
if(cachedLast != treeVersion)
{
bonuses.stackBonuses();
cachedLast = treeVersion;
}
auto ret = std::make_shared<BonusList>();
bonuses.getBonuses(*ret, selector, limit);
return ret;
}
int64_t BonusBearerMock::getTreeVersion() const
{
int64_t ret = treeVersion;
return ret << 32;
}