void HlView::Update() { if( BtStrCompare( m_lastArchiveName, m_archiveName ) == BtFalse ) { if( m_pLast ) { m_pLast->OnExit(); } Unload(); Load(); OnEntry(); } // Update the menu UpdateMenu(); m_pLast = this; }
/*********************************************************************** * Method: RobotController::Transition * Params: RobotState::State newState * Returns: void * Effects: Transition strarts the transition from one state to another ***********************************************************************/ void RobotController::Transition(RobotState::State newState, void* args) { //TODO: make sure the state we are entering is valid based on the current state of the robot if (m_status.GetState() != newState) { m_timeEnteringState = ros::Time::now(); } switch(m_status.GetState()) { case RobotState::WAITING: case RobotState::WAITING_TAG_FINISHED: case RobotState::NAVIGATING: case RobotState::NAVIGATING_TAG_FINISHED: // m_tagProcessor->SetShouldPause(false); break; } m_status.SetState(newState); OnEntry(args); ROS_INFO_STREAM("Transitioned to " << RobotState::ToString(newState)); }
bool IniReader::Parse() { FILE* f = OpenGameFile(m_filename, "r"); if(f == NULL) return false; bool res = true; enum ParseState { S_DEFAULT, S_IGNORERESTLINE, S_PROPNAME, S_PROPVALUE, S_SECTION }; ParseState state = S_DEFAULT; std::string propname; std::string section; std::string value; while(!feof(f) && !ferror(f)) { unsigned char c = 0; if(fread(&c, 1, 1, f) == 0) break; if(c == '\r') continue; // ignore this switch(state) { case S_DEFAULT: if(c >= 128) break; // just ignore unicode-stuff when we are in this state (UTF8 bytes at beginning are also handled by this) else if(isspace(c)) break; // ignore spaces and newlines else if(c == '#') { state = S_IGNORERESTLINE; /* this is a comment */ break; } else if(c == '[') { state = S_SECTION; section = ""; break; } else if(c == '=') { warnings << "WARNING: \"=\" is not allowed as the first character in a line of " << m_filename << endl; break; /* ignore */ } else { state = S_PROPNAME; propname = c; break; } case S_SECTION: if(c == ']') { if( ! OnNewSection(section) ) { res = false; goto parseCleanup; } state = S_DEFAULT; NewSection(section); break; } else if(c == '\n') { warnings << "WARNING: section-name \"" << section << "\" of " << m_filename << " is not closed correctly" << endl; state = S_DEFAULT; break; } else if(isspace(c)) { warnings << "WARNING: section-name \"" << section << "\" of " << m_filename << " contains a space" << endl; break; /* ignore */ } else { section += c; break; } case S_PROPNAME: if(c == '\n') { warnings << "WARNING: property \"" << propname << "\" of " << m_filename << " incomplete" << endl; state = S_DEFAULT; break; } else if(isspace(c)) break; // just ignore spaces else if(c == '=') { state = S_PROPVALUE; value = ""; break; } else { propname += c; break; } case S_PROPVALUE: if(c == '\n' || c == '#') { if( ! OnEntry(section, propname, value) ) { res = false; goto parseCleanup; } NewEntryInSection(propname, value); if(c == '#') state = S_IGNORERESTLINE; else state = S_DEFAULT; break; } else if(isspace(c) && value == "") break; // ignore heading spaces else { value += c; break; } case S_IGNORERESTLINE: if(c == '\n') state = S_DEFAULT; break; // ignore everything } } // In case the endline is missing at the end of file, finish the parsing of the last line if (state == S_PROPVALUE) { if( ! OnEntry(section, propname, value) ) { res = false; goto parseCleanup; } NewEntryInSection(propname, value); } // DEBUG: dump the file /*notes << "Dump of " << m_filename << endl; for (SectionMap::iterator it = m_sections.begin(); it != m_sections.end(); ++it) { notes << "[" << it->first << "]" << endl; for (Section::iterator k = it->second.begin(); k != it->second.end(); ++k) notes << k->first << "=" << k->second << endl; notes << endl; } notes << endl;*/ parseCleanup: fclose(f); return res; }