当前位置: 首页>>代码示例>>C++>>正文


C++ Logger函数代码示例

本文整理汇总了C++中Logger函数的典型用法代码示例。如果您正苦于以下问题:C++ Logger函数的具体用法?C++ Logger怎么用?C++ Logger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Logger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Client

ResolvingCombat::~ResolvingCombat() {
    if (TRACE_EXECUTION) Logger().debugStream() << "(HumanClientFSM) ~ResolvingCombat";
    Client().m_ui->GetMapWnd()->Show();
    FreeCombatData(m_previous_combat_data.get());
    FreeCombatData(m_combat_data.get());
}
开发者ID:anarsky,项目名称:freeorion,代码行数:6,代码来源:HumanClientFSM.cpp

示例2: Logger

Clock::Clock() {
	// TODO Auto-generated constructor stub
	logger = Logger();
}
开发者ID:LCartwright,项目名称:gameboy,代码行数:4,代码来源:Clock.cpp

示例3: DataElement

bool File::ReadDataBlock(std::string block, DataBlock* datablock)
{
    blockSize = block.size();
    int currentPos = 0;
    bool optionalToken = 0;
    int elementIndex = 0;
    int propertyIndex = 0;
    for(int i = 0; i <= 4; i++)//Why this is in a for loop I will never know
    {
        if(i == 0)
        {
            datablock->elements.push_back(new DataElement());
            //element token
            int extractPos1 = block.find_first_of('{', currentPos)-currentPos;
            int extractPos2 = block.find_first_of('"', currentPos)-currentPos;
            checkExtractPos(&extractPos1);
            checkExtractPos(&extractPos2);
            if(extractPos1<extractPos2)
            {
                std::string elementToken = block.substr(currentPos, extractPos1);
                if(!checkToken(elementToken))
                {
                    Logger()<<"Element contains incorrect syntax: \n"<<elementToken<<"\n"<<std::endl; //syntax error
                    return false;
                }
                datablock->elements[elementIndex]->elementName = elementToken;
                currentPos += extractPos1+1;
                optionalToken = false;
            }
            else if(extractPos2<extractPos1)
            {
                std::string elementToken = block.substr(currentPos, extractPos2);
                if(!checkToken(elementToken))
                {
                    Logger()<<"Element contains incorrect syntax: \n"<<elementToken<<"\n"<<std::endl; //syntax error
                    return false;
                }
                datablock->elements[elementIndex]->elementName = elementToken;
                currentPos += extractPos2+1;
                optionalToken = true;
            }
            else
            {
                Logger()<<"Element doesn't contain properties OR no terminating comment: \n"
                        <<datablock->elements[elementIndex]->elementName<<" '"
                        <<datablock->elements[elementIndex]->elementIdentifier<<"'\n"<<std::endl; //error
                return false;
            }
        }
        if(i == 1)
        {
            //check for optional
            if(optionalToken)
            {
                int extractPos1 = block.find_first_of('"', currentPos)-currentPos;
                //int extractPos2 = block.find_first_of('{', currentPos)-currentPos;
                //first do the "
                std::string optionalTokenStr = block.substr(currentPos, extractPos1);
                if(!checkToken(optionalTokenStr))
                {
                    Logger()<<"Optional Identifier contains incorrect syntax: \n"
                            <<datablock->elements[elementIndex]->elementName<<" "<<optionalTokenStr<<"\n"<<std::endl; //syntax error
                    return false;
                }
                datablock->elements[elementIndex]->elementIdentifier = optionalTokenStr;
                currentPos += extractPos1+1;
                //then check if { is next, if not we have an issue
                if(block[currentPos] == '{')
                    currentPos++;
                else
                {
                    Logger()<<"Element doesn't contain properties (are you missing an '{' ?): \n"
                            <<datablock->elements[elementIndex]->elementName<<" '"
                            <<datablock->elements[elementIndex]->elementIdentifier<<"'\n"<<std::endl;
                    return false;
                }
            }
        }
        if(i == 2)
        {
            //break the properties section
            //int first = currentPos;
            int last = block.find_first_of('}', currentPos);
            while(currentPos < last)//loop through all the properties
            {
                //create a new property
                datablock->elements[elementIndex]->properties.push_back(new DataProperty());
                int extractPos1 = block.find_first_of(':', currentPos)-currentPos;
                //do the propertyToken:
                std::string propertyToken = block.substr(currentPos, extractPos1);
                if(!checkToken(propertyToken))
                {
                    Logger()<<"Property contains incorrect syntax: \n"
                            <<datablock->elements[elementIndex]->elementName<<" '"
                            <<datablock->elements[elementIndex]->elementIdentifier<<"': \n"<<propertyToken<<"\n"<<std::endl; //syntax error
                    return false;
                }
                datablock->elements[elementIndex]->properties[propertyIndex]->propertyName = propertyToken;
                currentPos += extractPos1+1;
                //do the valueToken
//.........这里部分代码省略.........
开发者ID:Cimera42,项目名称:2DGame,代码行数:101,代码来源:fileReader.cpp

示例4: main

int main(int argc, char* argv[]) {
    InitDirs(argv[0]);
    std::vector<std::string> args;
    for (int i = 0; i < argc; ++i)
        args.push_back(argv[i]);

#else
int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) {
    // copy UTF-16 command line arguments to UTF-8 vector
    std::vector<std::string> args;
    for (int i = 0; i < argc; ++i) {
        std::wstring argi16(argv[i]);
        std::string argi8;
        utf8::utf16to8(argi16.begin(), argi16.end(), std::back_inserter(argi8));
        args.push_back(argi8);
    }
    InitDirs((args.empty() ? "" : *args.begin()));
#endif

    try {
        GetOptionsDB().AddFlag('h', "help", "Print this help message.");

        // read config.xml and set options entries from it, if present
        XMLDoc doc;
        {
            boost::filesystem::ifstream ifs(GetConfigPath());
            if (ifs) {
                doc.ReadDoc(ifs);
                GetOptionsDB().SetFromXML(doc);
            }
        }

        GetOptionsDB().SetFromCommandLine(args);

        if (GetOptionsDB().Get<bool>("help")) {
            GetOptionsDB().GetUsage(std::cerr);
            return 0;
        }

        parse::init();

        ServerApp g_app;
        g_app(); // Calls ServerApp::Run() to run app (intialization and main process loop)

    } catch (const std::invalid_argument& e) {
        Logger().errorStream() << "main() caught exception(std::invalid_arg): " << e.what();
        std::cerr << "main() caught exception(std::invalid_arg): " << e.what() << std::endl;
        return 1;
    } catch (const std::runtime_error& e) {
        Logger().errorStream() << "main() caught exception(std::runtime_error): " << e.what();
        std::cerr << "main() caught exception(std::runtime_error): " << e.what() << std::endl;
        return 1;
    } catch (const std::exception& e) {
        Logger().errorStream() << "main() caught exception(std::exception): " << e.what();
        std::cerr << "main() caught exception(std::exception): " << e.what() << std::endl;
        return 1;
    } catch (...) {
        Logger().errorStream() << "main() caught unknown exception.";
        std::cerr << "main() caught unknown exception." << std::endl;
        return 1;
    }

    return 0;
}
开发者ID:Ablu,项目名称:freeorion,代码行数:64,代码来源:dmain.cpp

示例5: m_design_id

Ship::Ship(int empire_id, int design_id, const std::string& species_name,
           int produced_by_empire_id/* = ALL_EMPIRES*/) :
    m_design_id(design_id),
    m_fleet_id(INVALID_OBJECT_ID),
    m_ordered_scrapped(false),
    m_ordered_colonize_planet_id(INVALID_OBJECT_ID),
    m_ordered_invade_planet_id(INVALID_OBJECT_ID),
    m_ordered_bombard_planet_id(INVALID_OBJECT_ID),
    m_last_turn_active_in_combat(INVALID_GAME_TURN),
    m_species_name(species_name),
    m_produced_by_empire_id(produced_by_empire_id)
{
    if (!GetShipDesign(design_id))
        throw std::invalid_argument("Attempted to construct a Ship with an invalid design id");

    if (!m_species_name.empty() && !GetSpecies(m_species_name))
        Logger().debugStream() << "Ship created with invalid species name: " << m_species_name;

    SetOwner(empire_id);

    UniverseObject::Init();

    AddMeter(METER_FUEL);
    AddMeter(METER_MAX_FUEL);
    AddMeter(METER_SHIELD);
    AddMeter(METER_MAX_SHIELD);
    AddMeter(METER_DETECTION);
    AddMeter(METER_STRUCTURE);
    AddMeter(METER_MAX_STRUCTURE);
    AddMeter(METER_BATTLE_SPEED);
    AddMeter(METER_STARLANE_SPEED);

    const std::vector<std::string>& part_names = Design()->Parts();
    for (std::size_t i = 0; i < part_names.size(); ++i) {
        if (part_names[i] != "") {
            const PartType* part = GetPartType(part_names[i]);
            if (!part) {
                Logger().errorStream() << "Ship::Ship couldn't get part with name " << part_names[i];
                continue;
            }

            switch (part->Class()) {
            case PC_SHORT_RANGE:
            case PC_POINT_DEFENSE: {
                m_part_meters[std::make_pair(METER_DAMAGE,              part->Name())];
                m_part_meters[std::make_pair(METER_ROF,                 part->Name())];
                m_part_meters[std::make_pair(METER_RANGE,               part->Name())];
                break;
            }
            case PC_MISSILES: {
                std::pair<std::size_t, std::size_t>& part_missiles =
                    m_missiles[part_names[i]];
                ++part_missiles.first;
                part_missiles.second += boost::get<LRStats>(part->Stats()).m_capacity;
                m_part_meters[std::make_pair(METER_DAMAGE,              part->Name())];
                m_part_meters[std::make_pair(METER_ROF,                 part->Name())];
                m_part_meters[std::make_pair(METER_RANGE,               part->Name())];
                m_part_meters[std::make_pair(METER_SPEED,               part->Name())];
                m_part_meters[std::make_pair(METER_STEALTH,             part->Name())];
                m_part_meters[std::make_pair(METER_STRUCTURE,           part->Name())];
                m_part_meters[std::make_pair(METER_CAPACITY,            part->Name())];
                break;
            }
            case PC_FIGHTERS: {
                std::pair<std::size_t, std::size_t>& part_fighters =
                    m_fighters[part_names[i]];
                ++part_fighters.first;
                part_fighters.second += boost::get<FighterStats>(part->Stats()).m_capacity;
                m_part_meters[std::make_pair(METER_ANTI_SHIP_DAMAGE,    part->Name())];
                m_part_meters[std::make_pair(METER_ANTI_FIGHTER_DAMAGE, part->Name())];
                m_part_meters[std::make_pair(METER_LAUNCH_RATE,         part->Name())];
                m_part_meters[std::make_pair(METER_FIGHTER_WEAPON_RANGE,part->Name())];
                m_part_meters[std::make_pair(METER_SPEED,               part->Name())];
                m_part_meters[std::make_pair(METER_STEALTH,             part->Name())];
                m_part_meters[std::make_pair(METER_STRUCTURE,           part->Name())];
                m_part_meters[std::make_pair(METER_DETECTION,           part->Name())];
                m_part_meters[std::make_pair(METER_CAPACITY,            part->Name())];
                break;
            }
            default:
                break;
            }
        }
    }
}
开发者ID:fatman2021,项目名称:FreeOrion,代码行数:85,代码来源:Ship.cpp

示例6: ErrorOutput

 void ErrorOutput(const std::string& error_text) {
     Logger().errorStream() << error_text;
 }
开发者ID:Nagilum23,项目名称:freeorion-1,代码行数:3,代码来源:AIInterface.cpp

示例7: TestStepResult

TVerdict CEntryStatusStep::doTestStepL()
	{
	// don't continue if previous phases have aborted
	if (TestStepResult() != EPass)
		{
		return TestStepResult();
		}

	// Delay briefly to ensure that any update entry steps in concurrent tests can
	// check first (which sets the state to EAwaitingApproval.)
	User::After(KStateCheckDelay);

	_LIT(KCancelMessage, "Cancelling...");

	// Cancel if set to do so before checking state.
	if (iCancelPoint == EAfterOpen)
		{
		Logger().Write(KCancelMessage);
		Session().Cancel();
		}

	iState = Session().GetStateL();
	
	// log the action
	_LIT(KMessageFmt, "State of cache entry for certificate '%S' is %d.");
	Logger().WriteFormat(KMessageFmt, SubjectLC(), iState);
	CleanupStack::PopAndDestroy(1); // subject

	if (iCancelPoint == EAfterGetState)
		{
		Logger().Write(KCancelMessage);
		Session().Cancel();
		iState = Session().GetStateL();
		Logger().WriteFormat(KMessageFmt, SubjectLC(), iState);
		CleanupStack::PopAndDestroy(1); // subject
		}
	else if (iRequestChangeNotify)
		{
		if (iState == EEntryAwaitingApproval || !iRequirePendingApproval)
			{
			TRequestStatus status;
			Session().RequestNotify(status);
			if (iCancelPoint == EAfterChangeNotify)
				{
				Logger().Write(KCancelMessage);
				Session().Cancel();
				}

			User::WaitForRequest(status);

			User::LeaveIfError(status.Int());

			iState = Session().GetStateL();

			// log the action
			_LIT(KMessageFormat, "Got cache change notify for certificate '%S', state = %d.");
			Logger().WriteFormat(KMessageFormat, SubjectLC(), iState);
			CleanupStack::PopAndDestroy(1); // certificate status
			}
		else
			{
			// log the action
			_LIT(KMessageFormat, "Cannot wait for change notify, entry state is not %d (EEntryAwaitingApproval.)");
			Logger().WriteFormat(KMessageFormat, EEntryAwaitingApproval);
			SetTestStepResult(EFail)		;
			}
		}
	
	return TestStepResult();
	
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:71,代码来源:entrystatusstep.cpp

示例8: Add

void CoinChangeTest::Init(void)
{
	Add("1", [&](){
		vector<unsigned int> denoms { 1, 3, 4};
		map<unsigned int, unsigned int> changes;
		unsigned int amount = 6;
		Test::CoinChange::ComputeSolution(amount, denoms, changes);
		map<unsigned int, unsigned int>::iterator it;
		Logger().WriteInformation("For amount %d, changes are :\n", amount);
		for (it = changes.begin(); it != changes.end(); it++) {
			Logger().WriteInformation("\tcoint %d, count %d\n", it->first, it->second);
		}

		ASSERT1(changes.size() == 1);
		ASSERT1(changes[3] == 2);
	});

	Add("2", [&](){
		vector<unsigned int> denoms { 1, 5, 10, 25};
		for (int i = 0; i < 100; i ++) {
			unsigned int amount = Test::Random::Next(1, 1000);
			map<unsigned int, unsigned int> changes1;
			map<unsigned int, unsigned int> changes2;
			Test::CoinChange::ComputeSolution(amount, denoms, changes1);
			Test::CoinChange::GreedySolution(amount, denoms, changes2);

			ASSERT1(changes1.size() == changes2.size());

			map<unsigned int, unsigned int>::iterator it;
			Logger().WriteInformation("Run %d, amount %d, changes are :\n", i, amount);
			for (it = changes1.begin(); it != changes1.end(); it++) {
				Logger().WriteInformation("\tcoint %d, count %d\n", it->first, it->second);
				ASSERT1(it->second == changes2[it->first]);
			}
		}
	});

	Add("AllSolutions", [&](){
		auto check = [&](unsigned int sum, vector<unsigned int> & denoms, unsigned int count) {
			vector<map<unsigned int, unsigned int>> solutions;
			Test::CoinChange::ComputeAllSolutions(sum, denoms, solutions);
			Logger().WriteInformation("Sum %d numbers:", sum);
			for_each (denoms.begin(), denoms.end(), [&](unsigned int d){
				Logger().WriteInformation("  %d", d);
			});
			Logger().WriteInformation("\n");
			for_each (solutions.begin(), solutions.end(), [&](map<unsigned int, unsigned int> & m){
				Logger().WriteInformation("  %d = ", sum);
				int i = 0;
				for_each (m.begin(), m.end(), [&](pair<unsigned int, unsigned int> p) {
					if (i != 0) {
						Logger().WriteInformation(" + ");
					}
					Logger().WriteInformation("%d x %d", p.second, p.first);
					i++;
				});
				Logger().WriteInformation("\n");
			});
			ASSERT1(solutions.size() == count);
		};

		vector<unsigned int> denoms { 2, 3, 6, 7 };
		check(7, denoms, 2);
	});

	Add("SubSetSolutions", [&](){
		auto check = [&](unsigned int sum, vector<unsigned int> & denoms, unsigned int count) {
			vector<map<unsigned int, unsigned int>> solutions;
			Test::CoinChange::ComputeSubSetSolutions(sum, denoms, solutions);
			Logger().WriteInformation("Sum %d numbers:", sum);
			for_each (denoms.begin(), denoms.end(), [&](unsigned int d){
				Logger().WriteInformation("  %d", d);
			});
			Logger().WriteInformation("\n");
			for_each (solutions.begin(), solutions.end(), [&](map<unsigned int, unsigned int> & m){
				Logger().WriteInformation("  %d = ", sum);
				int i = 0;
				for_each (m.begin(), m.end(), [&](pair<unsigned int, unsigned int> p) {
					if (i != 0) {
						Logger().WriteInformation(" + ");
					}
					Logger().WriteInformation("%d x %d", p.second, p.first);
					i++;
				});
				Logger().WriteInformation("\n");
			});
			ASSERT1(solutions.size() == count);
		};

		vector<unsigned int> denoms { 2, 3, 6, 7 };
		check(7, denoms, 1);
	});
}
开发者ID:PeterGH,项目名称:Test,代码行数:93,代码来源:CoinChangeTest.cpp

示例9: LoadLibrary

bool DeviceDirect3D::create()
{
	HMODULE libD3D11 = LoadLibrary("d3d11.dll");
	if(!libD3D11)
	{
		Logger() << "Could not load d3d11.dll, you probably do not have DirectX 11 installed.";
		return false;
	}

	HMODULE libCompiler43 = LoadLibrary("d3dcompiler_43.dll");
	if(!libCompiler43)
	{
		Logger() << "Could not load d3dcompiler_43.dll, try updating your DirectX";
		return false;
	}

	//Release handles
	FreeLibrary(libD3D11);
	FreeLibrary(libCompiler43);

	std::vector<IDXGIAdapter1*> adapters;
	if(!getAdapterHandle(&adapters))
	{
		return false;
	}

	UINT createDeviceFlags = 0;
#if defined(_DEBUG)
    createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

	const D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_0 /*, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0*/ };
	DXGI_SWAP_CHAIN_DESC sd;
	
	ZeroMemory(&sd,sizeof(sd));
	
	const WindowSettings& ws = getWindow()->getWindowSettings();

	sd.BufferCount = 1;	
	sd.BufferDesc.Width = (UINT)ws.width;
	sd.BufferDesc.Height = (UINT)ws.height;
	sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; //_SRGB;
	sd.BufferDesc.RefreshRate.Numerator = 60;	
	sd.BufferDesc.RefreshRate.Denominator = 1;	
	sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS;
	sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
	sd.OutputWindow = static_cast<WindowWinAPI*>(getWindow())->getHandle();
	sd.SampleDesc.Count = 1;
	sd.SampleDesc.Quality = 0;
	sd.Windowed = ws.fullscreen ? FALSE : TRUE;
	
	int selectedAdapterId = ws.gpu;
	IDXGIAdapter* selectedAdapter = nullptr;
	if(selectedAdapterId >= 0) 
	{
		if(selectedAdapterId < (int)adapters.size())
		{
			selectedAdapter = adapters[selectedAdapterId];
		} else {
			LOGFUNCERROR("Selected graphics card " << selectedAdapterId << " does not exist");
		}
	}

	HRESULT result = D3D11CreateDeviceAndSwapChain(selectedAdapter, selectedAdapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE, 0, createDeviceFlags, featureLevels,
                        _countof(featureLevels), D3D11_SDK_VERSION, &sd, &swapChain, &device, &featureLevel, &context);

	if(result != S_OK)
	{
		if(result == DXGI_ERROR_UNSUPPORTED)
		{
			LOGFUNCERROR("Your videocard does not appear to support DirectX 11");
		} else {
			LOGERROR(result, "D3D11CreateDeviceAndSwapChain");
		}
		return false;
	}

	//D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;	
	/*result = device->CreateShaderResourceView(swapBackBuffer, 0, &swapBackBufferSRV);

	if(result != S_OK){
		LOGERROR(result, "ID3D11Device::CreateShaderResourceView");
		return false;
	}*/

	D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS dxHwOpt;
	result = device->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, &dxHwOpt, sizeof(dxHwOpt));
	if(FAILED(result))
	{
		LOGERROR(result, "CheckFeatureSupport");
		return false;
	}
	if(!dxHwOpt.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x)
	{
		Logger() << "ComputeShaders are not supported on this device";
		return false;
	}
	
	//Get the buffer from the swapchain
	result = swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&swapBackBuffer);
//.........这里部分代码省略.........
开发者ID:MadrMan,项目名称:gpgpuraytrace,代码行数:101,代码来源:DeviceDirect3D.cpp

示例10: TESTL

enum TVerdict CEsockTest11_3::easyTestStepL()
	{
	TInetAddr addrLocal, addrRemote;
	TRequestStatus wstat, wstat2, wstat3, rstat;
	TInt sockIndex1, sockIndex2, sockIndex3;
	
	const TInt KBufSize = 4024;
	// Constructs an empty 8 bit modifiable buffer descriptor. It contains no data.
	typedef TBuf8<KBufSize> TBuffer;
	
	// get local ip address
	TESTL(GetIpAddressFromConfig(_L("Test_11.3"), _L("ipAddressLocal"), addrLocal));
	
	// get ip address to connect to (usually loopback)
	TESTL(GetIpAddressFromConfig(_L("Test_11.3"), _L("ipAddressRemote"), addrRemote));
	
	// open socket and listen for connect requests
	TESTL(KErrNone == OpenListeningSocketL(addrLocal, sockIndex1));
	
	// open active socket and make connect request
	TESTL(KErrNone == OpenActiveSocketL(addrRemote, sockIndex2));
	
	// accept connect request
	TESTL(KErrNone == AcceptConnectionL(sockIndex3, sockIndex1));
	
	TBuffer* wtemp=new (ELeave) TBuffer;
	CleanupStack::PushL(wtemp);
	TBuffer& wbuf=*wtemp;
	
	TBuffer* rtemp=new (ELeave) TBuffer;
	CleanupStack::PushL(rtemp);
	TBuffer& rbuf=*rtemp;
	
	wbuf.SetMax();
	StripeDes(wbuf, 0, wbuf.Length(), '@', 'Z');
	
	iEsockSuite->GetSocketHandle(sockIndex2).Send(wbuf, 0, wstat);
	iEsockSuite->GetSocketHandle(sockIndex2).Send(wbuf, 0, wstat2);
	iEsockSuite->GetSocketHandle(sockIndex2).Send(wbuf, 0, wstat3);
	iEsockSuite->GetSocketHandle(sockIndex2).CancelAll();
	User::WaitForRequest(wstat);
	User::WaitForRequest(wstat2);
	User::WaitForRequest(wstat3);
	TESTEL(wstat==KErrNone || wstat==KErrCancel, wstat.Int());
	TESTEL(wstat2==KErrNone || wstat2==KErrCancel, wstat2.Int());
	TESTEL(wstat3==KErrNone || wstat3==KErrCancel, wstat3.Int());
	
	Logger().WriteFormat(_L("stat1 %d stat2 %d stat3 %d"),wstat.Int(), wstat2.Int(), wstat3.Int());
	
	iEsockSuite->GetSocketHandle(sockIndex3).Recv(rbuf, 0, rstat);
	iEsockSuite->GetSocketHandle(sockIndex3).CancelAll();
	User::WaitForRequest(rstat);
	TESTEL(rstat==KErrNone || rstat==KErrCancel, rstat.Int());
	
	iEsockSuite->GetSocketHandle(sockIndex2).Shutdown(RSocket::ENormal, wstat);
	iEsockSuite->GetSocketHandle(sockIndex3).Shutdown(RSocket::ENormal, rstat);
	iEsockSuite->GetSocketHandle(sockIndex2).CancelAll();
	iEsockSuite->GetSocketHandle(sockIndex3).CancelAll();
	User::WaitForRequest(wstat);
	User::WaitForRequest(rstat);
	TESTEL(wstat == KErrNone, wstat.Int());
	TESTEL(rstat == KErrNone, rstat.Int());

	CleanupStack::PopAndDestroy(2, wtemp);
	
	// shutdown the client socket - do not wait for completion
	CloseSockets(2);
	return EPass;
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:69,代码来源:EsockTestSection11.cpp

示例11: Logger

enum TVerdict CEsockTest11_4::easyTestStepL()
	{
	//
	// Out Of Memory Test on open() RSocket //
	//

	TVerdict verdict = EPass;
	
	Logger().WriteFormat(_L("TE_ESock: test 11.4"));
	Logger().WriteFormat(_L("RSocket Open"));

#if defined (_DEBUG_SOCKET_FUNCTIONS)

	RSocketServ socketHelper;
	CleanupClosePushL(socketHelper);
	TInt ret = socketHelper.Connect();
	TESTEL(KErrNone == ret, ret);

	// Create a socket on the helper to get the DND up & running
	RSocket sockHelper;
	CleanupClosePushL(sockHelper);
	ret = sockHelper.Open(socketHelper, KAfInet, KSockStream, KProtocolInetTcp);
	TESTEL(KErrNone == ret, ret);
	// Short wait for DND settle down
    User::After(5000000);
	socketHelper.__DbgMarkHeap();

	RSocketServ socketServer;
	CleanupClosePushL(socketServer);
	ret = socketServer.Connect();
	TESTEL(KErrNone == ret, ret);
	
	// See if we can crash the server:
	RSocket sock;
	CleanupClosePushL(sock);
	TInt failure = 0;

	verdict = EInconclusive;
	TInt prevResult = KErrNoMemory;
	TInt prevOccurs = 0;
	while (EInconclusive == verdict)
		{
		socketServer.__DbgFailNext(failure++);
		ret = sock.Open(socketServer, KAfInet, KSockStream, KProtocolInetTcp);
		
		if ((prevResult != ret) || (++prevOccurs >= 1000))
			{
			Logger().WriteFormat(_L("%d loop(s), open socket returned %d"), prevOccurs, prevResult);
			if (KErrNone == ret)
				{
				verdict = EPass;
				}
			else if (KErrServerTerminated == ret)
				{
				verdict = EFail;
				}
			else if (prevResult != ret)
				{
				prevResult = ret;
				prevOccurs = 1;
				}
			else
				{
				prevOccurs = 0;
				}
			}
		};
	
	socketServer.__DbgFailNext(-1);
	// wait for protocol families to unload - it's via an async callback and dependent upon the IP stack, which
	// may also be killing off DND. So a big delay is needed. If it proves unreliable in future then the really
	// strong approach would be shutting down ESOCK - it'll panic if it has allocations outstanding
    User::After(5000000);
	socketHelper.__DbgMarkEnd(0);
	CleanupStack::PopAndDestroy(4, &socketHelper);

#else
	Logger().WriteFormat(_L("Test disabled on release build."));
#endif
	
	return verdict;
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:82,代码来源:EsockTestSection11.cpp

示例12:

boost::statechart::result IntroMenu::react(const JoinMPGameRequested& a) {
    if (TRACE_EXECUTION) Logger().debugStream() << "(HumanClientFSM) IntroMenu.JoinMPGameRequested";
    return transit<WaitingForMPJoinAck>();
}
开发者ID:anarsky,项目名称:freeorion,代码行数:4,代码来源:HumanClientFSM.cpp

示例13: DoneCombatTurn

 void DoneCombatTurn() {
     Logger().debugStream() << "AIInterface::DoneCombatTurn()";
     AIClientApp::GetApp()->StartCombatTurn(); // encodes combat order sets and sends combat turn orders message.  "done" the combat turn for the client, but "starts" the combat turn for the server
 }
开发者ID:Nagilum23,项目名称:freeorion-1,代码行数:4,代码来源:AIInterface.cpp

示例14: turn

CombatInfo::CombatInfo(int system_id_, int turn_) :
    turn(turn_),
    system_id(system_id_)
{
    TemporaryPtr<System> system = ::GetSystem(system_id);
    if (!system) {
        Logger().errorStream() << "CombatInfo constructed with invalid system id: " << system_id;
        return;
    }

    // add system to full / complete objects in combat - NOTE: changed from copy of system
    objects.Insert(system);


    // find ships and their owners in system
    std::vector<TemporaryPtr<Ship> > ships =
        Objects().FindObjects<Ship>(system->ShipIDs());

    for (std::vector<TemporaryPtr<Ship> >::const_iterator ship_it = ships.begin();
         ship_it != ships.end(); ++ship_it)
    {
        TemporaryPtr<Ship> ship = *ship_it;
        // add owner to empires that have assets in this battle
        empire_ids.insert(ship->Owner());

        objects.Insert(ship);
    }

    // find planets and their owners in system
    std::vector<TemporaryPtr<Planet> > planets =
        Objects().FindObjects<Planet>(system->PlanetIDs());

    for (std::vector<TemporaryPtr<Planet> >::const_iterator planet_it = planets.begin();
         planet_it != planets.end(); ++planet_it)
    {
        TemporaryPtr<Planet> planet = *planet_it;
        // if planet is populated, add owner to empires that have assets in this battle
        if (planet->CurrentMeterValue(METER_POPULATION) > 0.0)
            empire_ids.insert(planet->Owner());

        objects.Insert(planet);
    }

    // TODO: should buildings be considered separately?

    // now that all participants in the battle have been found, loop through
    // objects again to assemble each participant empire's latest
    // known information about all objects in this battle

    // system
    for (std::set<int>::const_iterator empire_it = empire_ids.begin();
         empire_it != empire_ids.end(); ++empire_it)
    {
        int empire_id = *empire_it;
        if (empire_id == ALL_EMPIRES)
            continue;
        empire_known_objects[empire_id].Insert(GetEmpireKnownSystem(system->ID(), empire_id));
    }

    // ships
    for (std::vector<TemporaryPtr<Ship> >::const_iterator it = ships.begin();
         it != ships.end(); ++it)
    {
        TemporaryPtr<Ship> ship = *it;
        int ship_id = ship->ID();
        TemporaryPtr<const Fleet> fleet = GetFleet(ship->FleetID());
        if (!fleet) {
            Logger().errorStream() << "CombatInfo::CombatInfo couldn't get fleet with id "
                                   << ship->FleetID() << " in system " << system->Name() << " (" << system_id << ")";
            continue;
        }

        for (std::set<int>::const_iterator empire_it = empire_ids.begin();
             empire_it != empire_ids.end(); ++empire_it)
        {
            int empire_id = *empire_it;
            if (empire_id == ALL_EMPIRES)
                continue;
            if (GetUniverse().GetObjectVisibilityByEmpire(ship_id, empire_id) >= VIS_BASIC_VISIBILITY ||
                   (fleet->Aggressive() &&
                       (empire_id == ALL_EMPIRES ||
                        fleet->Unowned() ||
                        Empires().GetDiplomaticStatus(empire_id, fleet->Owner()) == DIPLO_WAR)))
            { empire_known_objects[empire_id].Insert(GetEmpireKnownShip(ship->ID(), empire_id));}
        }
    }

    // planets
    for (std::vector<TemporaryPtr<Planet> >::const_iterator it = planets.begin();
         it != planets.end(); ++it)
    {
        TemporaryPtr<Planet> planet = *it;
        int planet_id = planet->ID();

        for (std::set<int>::const_iterator empire_it = empire_ids.begin(); empire_it != empire_ids.end(); ++empire_it) {
            int empire_id = *empire_it;
            if (empire_id == ALL_EMPIRES)
                continue;
            if (GetUniverse().GetObjectVisibilityByEmpire(planet_id, empire_id) >= VIS_BASIC_VISIBILITY) {
                empire_known_objects[empire_id].Insert(GetEmpireKnownPlanet(planet->ID(), empire_id));
//.........这里部分代码省略.........
开发者ID:e-h-j,项目名称:freeorion,代码行数:101,代码来源:CombatSystem.cpp

示例15: LogOutput

 void LogOutput(const std::string& log_text) {
     Logger().debugStream() << log_text;
 }
开发者ID:Nagilum23,项目名称:freeorion-1,代码行数:3,代码来源:AIInterface.cpp


注:本文中的Logger函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。