示例#1
0
	bool UnitTests::TileRoad_Test1()
	{
		//Serialise method & Load constructor
		bool _result = true;
		TA::SaveGameManager *sgm = TA::SaveGameManager::GetInstance();
		TA::Game *game = TA::Game::getInstance();

		// Create character object and set object id for it
		std::shared_ptr<TileRoad> _object(new TileRoad());
		_object->setX(666);

		// Save the character object by using its serialise method
		std::ofstream ofs("unittest_savegame.dat", std::ios::binary);
		_object->serialise(ofs);
		ofs.close();

		//Reset _character1 to be sure we are not using old data...
		_object.reset();

		// Create new character object by using load constructor
		std::ifstream ifs("unittest_savegame.dat", std::ios::binary);
		std::shared_ptr<TileRoad> _object2(new TileRoad(ifs));

		ifs.close();

		_result = (_object2->getX() == 666);
		
		return _result;
	}
示例#2
0
	bool UnitTests::Character_Test3()
	{
		//Serialise method & Load constructor
		bool _result = true;
		TA::SaveGameManager *sgm = TA::SaveGameManager::GetInstance();
		TA::Game *game = TA::Game::getInstance();

		// Create character object and set object id for it
		std::shared_ptr<CharacterSimple> _object(new CharacterSimple());
		_object->SetObjectId(666);

		// Save the character object by using its serialise method
		std::ofstream ofs("unittest_savegame.dat", std::ios::binary);
		_object->serialise(ofs);
		ofs.close();
		
		// Create new character object by using load constructor
		std::ifstream ifs("unittest_savegame.dat", std::ios::binary);
		std::shared_ptr<CharacterSimple> _object2(new CharacterSimple(ifs));
		ifs.close();
		
		_result = (_object2->GetObjectId() == 666);
		
		return _result;
	}
示例#3
0
bool AccessControl::onObject(User *u, Scheme *s, Action a, data::Value &obj, data::Value &patch, apr::array<InputFile> &files) const {
	if (useAdminPrivileges(u)) {
		return true;
	}
	auto objIt = _objects.find(s);
	if (objIt != _objects.end() && objIt->second) {
		return objIt->second(u, s, a, obj, patch, files);
	} else if (_object) {
		return _object(u, s, a, obj, patch, files);
	}
	return true;
}
/**
 * Return the contact through which the request was made.
 *
 * \return A pointer to the Contact object.
 */
ContactPtr PendingContactInfo::contact() const
{
    return ContactPtr(qobject_cast<Contact*>((Contact*) _object().data()));
}
示例#5
0
	Object_p Interface::holder() 
	{ 
		return Object_p( _object() ); 
	}
示例#6
0
	Interface_p	Interface::ptr()
	{
		return Interface_p(_object(),this);
	}