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


C++ CEvent::what方法代码示例

本文整理汇总了C++中CEvent::what方法的典型用法代码示例。如果您正苦于以下问题:C++ CEvent::what方法的具体用法?C++ CEvent::what怎么用?C++ CEvent::what使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CEvent的用法示例。


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

示例1: debugArg

void
CDaemonApp::handleIpcMessage(const CEvent& e, void*)
{
	CIpcMessage* m = static_cast<CIpcMessage*>(e.getDataObject());
	switch (m->type()) {
		case kIpcCommand: {
			CIpcCommandMessage* cm = static_cast<CIpcCommandMessage*>(m);
			CString command = cm->command();
			LOG((CLOG_DEBUG "new command, elevate=%d command=%s", cm->elevate(), command.c_str()));

			CString debugArg("--debug");
			UInt32 debugArgPos = static_cast<UInt32>(command.find(debugArg));
			if (debugArgPos != CString::npos) {
				UInt32 from = debugArgPos + static_cast<UInt32>(debugArg.size()) + 1;
				UInt32 nextSpace = static_cast<UInt32>(command.find(" ", from));
				CString logLevel(command.substr(from, nextSpace - from));
				
				try {
					// change log level based on that in the command string
					// and change to that log level now.
					ARCH->setting("LogLevel", logLevel);
					CLOG->setFilter(logLevel.c_str());
				}
				catch (XArch& e) {
					LOG((CLOG_ERR "failed to save LogLevel setting, %s", e.what().c_str()));
				}
			}

			try {
				// store command in system settings. this is used when the daemon
				// next starts.
				ARCH->setting("Command", command);

				// TODO: it would be nice to store bools/ints...
				ARCH->setting("Elevate", CString(cm->elevate() ? "1" : "0"));
			}
			catch (XArch& e) {
				LOG((CLOG_ERR "failed to save settings, %s", e.what().c_str()));
			}

#if SYSAPI_WIN32
			// tell the relauncher about the new command. this causes the
			// relauncher to stop the existing command and start the new
			// command.
			m_relauncher->command(command, cm->elevate());
#endif
			break;
		}

		case kIpcHello:
			m_ipcLogOutputter->notifyBuffer();
			break;
	}
}
开发者ID:di9it,项目名称:synergy-through-usb,代码行数:54,代码来源:CDaemonApp.cpp

示例2: argParser

void
CDaemonApp::handleIpcMessage(const CEvent& e, void*)
{
	CIpcMessage* m = static_cast<CIpcMessage*>(e.getDataObject());
	switch (m->type()) {
		case kIpcCommand: {
			CIpcCommandMessage* cm = static_cast<CIpcCommandMessage*>(m);
			CString command = cm->command();

			// if empty quotes, clear.
			if (command == "\"\"") {
				command.clear();
			}

			if (!command.empty()) {
				LOG((CLOG_DEBUG "new command, elevate=%d command=%s", cm->elevate(), command.c_str()));

				std::vector<CString> argsArray;
				CArgParser::splitCommandString(command, argsArray);
				CArgParser argParser(NULL);
				const char** argv = argParser.getArgv(argsArray);
				CServerArgs serverArgs;
				CClientArgs clientArgs;
				int argc = static_cast<int>(argsArray.size());
				bool server = argsArray[0].find("synergys") != CString::npos ? true : false;
				CArgsBase* argBase = NULL;

				if (server) {
					argParser.parseServerArgs(serverArgs, argc, argv);
					argBase = &serverArgs;
				}
				else {
					argParser.parseClientArgs(clientArgs, argc, argv);
					argBase = &clientArgs;
				}

				delete[] argv;
				
				CString logLevel(argBase->m_logFilter);
				if (!logLevel.empty()) {
					try {
						// change log level based on that in the command string
						// and change to that log level now.
						ARCH->setting("LogLevel", logLevel);
						CLOG->setFilter(logLevel.c_str());
					}
					catch (XArch& e) {
						LOG((CLOG_ERR "failed to save LogLevel setting, %s", e.what()));
					}
				}

#if SYSAPI_WIN32
				CString logFilename;
				if (argBase->m_logFile != NULL) {
					logFilename = CString(argBase->m_logFile);
					ARCH->setting("LogFilename", logFilename);
					m_watchdog->setFileLogOutputter(m_fileLogOutputter);
					command = CArgParser::assembleCommand(argsArray, "--log", 1);
					LOG((CLOG_DEBUG "removed log file argument and filename %s from command ", logFilename.c_str()));
					LOG((CLOG_DEBUG "new command, elevate=%d command=%s", cm->elevate(), command.c_str()));
				}
				else {
					m_watchdog->setFileLogOutputter(NULL);
				}

				m_fileLogOutputter->setLogFilename(logFilename.c_str());
#endif
			}
			else {
				LOG((CLOG_DEBUG "empty command, elevate=%d", cm->elevate()));
			}

			try {
				// store command in system settings. this is used when the daemon
				// next starts.
				ARCH->setting("Command", command);

				// TODO: it would be nice to store bools/ints...
				ARCH->setting("Elevate", CString(cm->elevate() ? "1" : "0"));
			}
			catch (XArch& e) {
				LOG((CLOG_ERR "failed to save settings, %s", e.what()));
			}

#if SYSAPI_WIN32
			// tell the relauncher about the new command. this causes the
			// relauncher to stop the existing command and start the new
			// command.
			m_watchdog->setCommand(command, cm->elevate());
#endif
			break;
		}

		case kIpcHello:
			CIpcHelloMessage* hm = static_cast<CIpcHelloMessage*>(m);
			CString type;
			switch (hm->clientType()) {
				case kIpcClientGui: type = "gui"; break;
				case kIpcClientNode: type = "node"; break;
				default: type = "unknown"; break;
//.........这里部分代码省略.........
开发者ID:BorisChiou,项目名称:synergy,代码行数:101,代码来源:DaemonApp.cpp

示例3: debugArg

void
CDaemonApp::handleIpcMessage(const CEvent& e, void*)
{
	CIpcMessage* m = static_cast<CIpcMessage*>(e.getDataObject());
	switch (m->type()) {
		case kIpcCommand: {
			CIpcCommandMessage* cm = static_cast<CIpcCommandMessage*>(m);
			CString command = cm->command();

			// if empty quotes, clear.
			if (command == "\"\"") {
				command.clear();
			}

			if (!command.empty()) {
				LOG((CLOG_DEBUG "new command, elevate=%d command=%s", cm->elevate(), command.c_str()));

				CString debugArg("--debug");
				UInt32 debugArgPos = static_cast<UInt32>(command.find(debugArg));
				if (debugArgPos != CString::npos) {
					UInt32 from = debugArgPos + static_cast<UInt32>(debugArg.size()) + 1;
					UInt32 nextSpace = static_cast<UInt32>(command.find(" ", from));
					CString logLevel(command.substr(from, nextSpace - from));
				
					try {
						// change log level based on that in the command string
						// and change to that log level now.
						ARCH->setting("LogLevel", logLevel);
						CLOG->setFilter(logLevel.c_str());
					}
					catch (XArch& e) {
						LOG((CLOG_ERR "failed to save LogLevel setting, %s", e.what().c_str()));
					}
				}
			}
			else {
				LOG((CLOG_DEBUG "empty command, elevate=%d", cm->elevate()));
			}

			try {
				// store command in system settings. this is used when the daemon
				// next starts.
				ARCH->setting("Command", command);

				// TODO: it would be nice to store bools/ints...
				ARCH->setting("Elevate", CString(cm->elevate() ? "1" : "0"));
			}
			catch (XArch& e) {
				LOG((CLOG_ERR "failed to save settings, %s", e.what().c_str()));
			}

#if SYSAPI_WIN32
			// tell the relauncher about the new command. this causes the
			// relauncher to stop the existing command and start the new
			// command.
			m_watchdog->setCommand(command, cm->elevate());
#endif
			break;
		}

		case kIpcHello:
			CIpcHelloMessage* hm = static_cast<CIpcHelloMessage*>(m);
			CString type;
			switch (hm->clientType()) {
				case kIpcClientGui: type = "gui"; break;
				case kIpcClientNode: type = "node"; break;
				default: type = "unknown"; break;
			}

			LOG((CLOG_DEBUG "ipc hello, type=%s", type.c_str()));

#if SYSAPI_WIN32
			CString watchdogStatus = m_watchdog->isProcessActive() ? "ok" : "error";
			LOG((CLOG_INFO "watchdog status: %s", watchdogStatus.c_str()));
#endif

			m_ipcLogOutputter->notifyBuffer();
			break;
	}
}
开发者ID:findepi,项目名称:synergy,代码行数:80,代码来源:CDaemonApp.cpp


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