Пример #1
0
/**
 Processes a file, if it contains valuable commands. The file is loaded into a buffer
 a is passed to <it>ParseBuffer</it>, where all commands will be extracted.
 */
void CStyleFile::ProcessFile()
{
	CFile f;

	try
	{
		f.Open(m_Filename, CFile::modeRead);
		ULONGLONG l = f.GetLength();

		CString text;
		f.Read(text.GetBuffer(l), l * sizeof(TCHAR));
		text.ReleaseBuffer();

		if (HasCommands(text))
		{
			ParseBuffer(text);
		}
	}
	catch (CFileException& ex)
	{
		TRACE(_T("Error opening style file: %s\n"), ex);
		UNUSED_ALWAYS(ex);

		f.Close();
	}

	f.Close();
}
Пример #2
0
    void Controller::HandleCommand() {
        if (!HasCommands())
            return;

        while (HasCommands()) {
            Command cmd = PopCommand();

            switch (cmd.what) {
                case Cmd::kResume:
                    mTimer->Resume();
                    mStatus = State::kRunning;
                    break;
                case Cmd::kPause:
                    if (mStatus == State::kRunning) {
                        mTimer->Pause();
                        std::unique_lock<std::mutex> locker(mConditionMutex);
                        mStatus = State::kPaused;
                        while (mStatus == State::kPaused) {
                            mCondition.wait(locker);
                        }
                    }
                    break;
                case Cmd::kSeek:
                    if (mStatus == State::kRunning) {
                        time_t timepoint = 0;
                        *reinterpret_cast<int*>(&timepoint) = cmd.arg1;
                        *(reinterpret_cast<int*>(&timepoint) + 1) = cmd.arg2;
                        mManager->SeekTo(timepoint);
                    }
                    break;
                case Cmd::kResize:
                    mDisplayer->Resize(cmd.arg1, cmd.arg2);
                    mManager->GetConfig()->MeasureFlag++;
                    break;
                case Cmd::kReLayout:
                    mManager->ReLayout();
                    break;
                case Cmd::kStop:
                    mStatus = State::kStopped;
                    break;
            }
        }
    }