int main() { auto rs = Robots::ROBOT_SERVER::GetInstance(); //rs->CreateRobot<ROBOT_TYPE_I>(); #ifdef PLATFORM_IS_LINUX rs->LoadXml("/usr/Robots/resource/HexapodIII/HexapodIII.xml"); rs->AddGait("wk", walk, parse); rs->Start(); #endif #ifdef PLATFORM_IS_WINDOWS rs->LoadXml("C:\\Robots\\resource\\HexapodIII\\HexapodIII.xml"); rs->AddGait("wk", Robots::walk, Robots::parseWalk); #endif // /**/ std::cout<<"finished"<<std::endl; Aris::Core::RunMsgLoop(); return 0; }
/* vector <Notif>* NotifyXml::GetUnReadNotif() { return &VUnReadNotif; } */ int NotifyXml::AddItem ( const Notif ¬if ) { if( pRootElement == NULL/* && pLastBookElem == NULL*/) { LoadXml(m_XmlFilePath); } if( pRootElement != NULL /*&& pLastBookElem != NULL*/) { TiXmlElement *pNewElemNotif = new TiXmlElement("Notice"); TiXmlElement *pNewElemNotifID = new TiXmlElement("ID"); TiXmlText *pNewTextNotifID = new TiXmlText(notif.Notif_ID.c_str()); pNewElemNotifID->LinkEndChild(pNewTextNotifID); pNewElemNotif->LinkEndChild(pNewElemNotifID); TiXmlElement *pNewElemNotifTitle = new TiXmlElement("Title"); TiXmlText *pNewTextNotifTitle = new TiXmlText(notif.Title.c_str()); pNewElemNotifTitle->LinkEndChild(pNewTextNotifTitle); pNewElemNotif->LinkEndChild(pNewElemNotifTitle); TiXmlElement *pNewElemNotifContent = new TiXmlElement("Content"); TiXmlText *pNewTextNotifContent = new TiXmlText(notif.Content.c_str()); pNewElemNotifContent->LinkEndChild(pNewTextNotifContent); pNewElemNotif->LinkEndChild(pNewElemNotifContent); TiXmlElement *pNewElemNotifStartTime = new TiXmlElement("PubTime"); TiXmlText *pNewTextNotifStartTime = new TiXmlText(notif.StartTime.c_str()); pNewElemNotifStartTime->LinkEndChild(pNewTextNotifStartTime); pNewElemNotif->LinkEndChild(pNewElemNotifStartTime); TiXmlElement *pNewElemNotifEndTime = new TiXmlElement("EndTime"); TiXmlText *pNewTextNotifEndTime = new TiXmlText(notif.EndTime.c_str()); pNewElemNotifEndTime->LinkEndChild(pNewTextNotifEndTime); pNewElemNotif->LinkEndChild(pNewElemNotifEndTime); /* TiXmlElement *pNewElemNotifGrade = new TiXmlElement("Readed"); char cReaded[2] ; sprintf(cReaded, "%d" , notif.Readed); TiXmlText *pNewTextNotifGrade = new TiXmlText(cReaded); pNewElemNotifGrade->LinkEndChild(pNewTextNotifGrade); pNewElemNotif->LinkEndChild(pNewElemNotifGrade); */ //pLastBookElem->LinkEndChild(pNewElemNotif);//adding it to the LastBookElem pRootElement->LinkEndChild(pNewElemNotif);//adding it to the LastBookElem pLastBookElem = pNewElemNotif; printf("[%s:%d]:%s()- #### - !!\n",__FILE__,__LINE__,__func__); if(myDocument == NULL) { perror("myDocument == NULL"); return -1; } myDocument->SaveFile(); return 0; } else return -1; }
int NotifyXml::RemoveItem ( string notif_ID ) { if( pRootElement == NULL && pLastBookElem == NULL) { LoadXml(m_XmlFilePath); } if( pFirstBookElem != NULL && pRootElement != NULL) { TiXmlElement *FirstCourseItem = pFirstBookElem; while ( FirstCourseItem != NULL ) { TiXmlElement *IDElem = FirstCourseItem->FirstChildElement(); string strID = IDElem->FirstChild()->Value(); if( strID == notif_ID) { pRootElement->RemoveChild(FirstCourseItem); myDocument->SaveFile(); return 0; } FirstCourseItem = FirstCourseItem->NextSiblingElement(); }//not found return -1; } else { return -1; } }
BOOL CPanelBase::LoadXmlData( LPCSTR lpszXml ) { TiXmlDocument xmlDoc; { xmlDoc.Parse(lpszXml, NULL, TIXML_ENCODING_UTF8); } if (xmlDoc.Error()) return FALSE; TiXmlElement *pXmlRootElem = xmlDoc.RootElement(); return LoadXml(pXmlRootElem); }
bool GameMode::Load(void) { Config * config = Config::GetInstance(); m_current = config->GetGameMode(); LoadDefaultValues(); // Game mode objects configuration file if (!doc_objects->Load(GetObjectsFilename())) return false; if (!doc.Load(GetFilename())) return false; if (!LoadXml()) return false; return true; }
// Load the game mode from strings (probably from network) bool GameMode::LoadFromString(const std::string& game_mode_name, const std::string& game_mode_contents, const std::string& game_mode_objects_contents) { m_current = game_mode_name; MSG_DEBUG("game_mode", "Loading %s from network: ", m_current.c_str()); if (!doc_objects->LoadFromString(game_mode_objects_contents)) return false; if (!doc.LoadFromString(game_mode_contents)) return false; if (!LoadXml(doc.GetRoot())) return false; MSG_DEBUG("game_mode", "OK\n"); return true; }
void CFilterDlg::OnLoad(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wndCtl*/) { CFileDialog dlg(true, L".xml", m_name.c_str(), OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, L"XML Files (*.xml)\0*.xml\0" L"JSON Files (*.json)\0*.json\0" L"All Files\0*.*\0" L"\0", 0); dlg.m_ofn.nFilterIndex = 0; dlg.m_ofn.lpstrTitle = L"Load DebugView Filter"; // notice subtle behaviour, see http://msdn.microsoft.com/en-us/library/ms646839 at lpstrInitialDir std::wstring path; wchar_t szPath[MAX_PATH]; if (SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_PERSONAL, nullptr, 0, szPath))) { path = szPath; path += L"\\DebugView++ Filters"; dlg.m_ofn.lpstrInitialDir = path.c_str(); } if (dlg.DoModal() != IDOK) return; auto ext = GetFileNameExt(dlg.m_szFileName); auto fileName = Str(dlg.m_szFileName).str(); FilterData data; if (boost::iequals(ext, L"json")) data = LoadJson(fileName); else /* if (boost::iequals(ext, L"xml")) */ data = LoadXml(fileName); SetDlgItemTextA(*this, IDC_NAME, data.name.c_str()); auto msgFilters = m_messagePage.GetFilters(); msgFilters.insert(msgFilters.end(), data.filter.messageFilters.begin(), data.filter.messageFilters.end()); m_messagePage.SetFilters(msgFilters); auto procFilters = m_processPage.GetFilters(); procFilters.insert(procFilters.end(), data.filter.processFilters.begin(), data.filter.processFilters.end()); m_processPage.SetFilters(procFilters); }
bool BulletPhysics::Initialize() { LoadXml(); // this object controls bullet SDK's internal memory management during collision pass m_CollisionConfiguration.reset(CB_NEW btDefaultCollisionConfiguration); // this manages how bullet detects precise collisions between pairs of objects m_Dispatcher.reset(CB_NEW btCollisionDispatcher(m_CollisionConfiguration.get())); // used to quickly detect collisions between object, imprecisely. // if a collision passes this phase it will be passed to the dispatcher m_Broadphase.reset(CB_NEW btDbvtBroadphase); m_Solver.reset(CB_NEW btSequentialImpulseConstraintSolver); // this is the main interface point for the physics world m_DynamicsWorld.reset(CB_NEW btDiscreteDynamicsWorld(m_Dispatcher.get(), m_Broadphase.get(), m_Solver.get(), m_CollisionConfiguration.get())); m_DebugDrawer.reset(CB_NEW BulletDebugDrawer); m_DebugDrawer->ReadOptions(); if (!m_CollisionConfiguration || !m_Dispatcher || !m_Broadphase || !m_Solver || !m_DynamicsWorld /*|| !m_DebugDrawer*/) { CB_ERROR("BulletPhysics::Initialize failed"); return false; } m_DynamicsWorld->setDebugDrawer(m_DebugDrawer.get()); // set internal tick callback to our own method m_DynamicsWorld->setInternalTickCallback(BulletPhysics::BulletInternalTickCallback); m_DynamicsWorld->setWorldUserInfo(this); return true; }
MainWindow::MainWindow(const std::string &simulationName) { this->m_dw = NULL; this->m_gen = new Generator(simulationName); // // Menu // QMenu *menuFichier = menuBar()->addMenu("&File"); /* QAction *menuOpen = menuFichier->addAction("Open"); menuOpen->setDisabled(true); QAction *menuNew = menuFichier->addAction("New"); menuNew->setDisabled(true); QAction *menuSave = menuFichier->addAction("Save"); menuSave->setDisabled(true); QAction *menuSaveAs = menuFichier->addAction("Save as"); menuSaveAs->setDisabled(true); */ QAction *menuSavePix = menuFichier->addAction("Save as picture"); connect(menuSavePix, SIGNAL(triggered()), this, SLOT(SavePicture())); QAction *menuXml = menuFichier->addAction("Save as XML"); connect(menuXml, SIGNAL(triggered()), this, SLOT(SaveXml())); QAction *menuXmlLoad = menuFichier->addAction("Load XML file"); connect(menuXmlLoad, SIGNAL(triggered()), this, SLOT(LoadXml())); QAction *actionQuit = menuFichier->addAction("Quit"); connect(actionQuit, SIGNAL(triggered()), qApp, SLOT(quit())); QMenu *menuEdit = menuBar()->addMenu("&Edit"); QAction *actionConfig = menuEdit->addAction("Configuration"); actionConfig->setDisabled(true); //connect(actionConfig, SIGNAL(triggered()), this, SLOT(ConfigurationMenu())); QMenu *menuView = menuBar()->addMenu("&Generate"); QAction *actionCpp = menuView->addAction("&C++"); connect(actionCpp, SIGNAL(triggered()), this, SLOT(GenerateCpp())); QAction *actionPython = menuView->addAction("&Python"); connect(actionPython, SIGNAL(triggered()), this, SLOT(GeneratePython())); QMenu *menuHelp = menuBar()->addMenu("&Help"); QAction *menuOnlineHelp = menuHelp->addAction("Online Help"); menuOnlineHelp->setDisabled(true); //connect(menuOnlineHelp, SIGNAL(triggered()), this, SLOT(Help())); QAction *menuAbout = menuHelp->addAction("About"); connect(menuAbout, SIGNAL(triggered()), this, SLOT(About())); menuAbout = menuAbout; menuHelp = menuHelp; // // toolbar for add equipements. // QToolBar *toolBarFichier = addToolBar(""); //PC QIcon pcIcon(":/Ico/Pc.png"); QString pcString("Terminal"); QAction *pcAction = toolBarFichier->addAction(pcIcon, pcString); connect(pcAction, SIGNAL(triggered()), this, SLOT(CreatePc())); //Pc-group QIcon pcgIcon(":/Ico/Pc-group.png"); QString pcgString("Terminal Group"); QAction *pcgAction = toolBarFichier->addAction(pcgIcon, pcgString); connect(pcgAction, SIGNAL(triggered()), this, SLOT(CreatePcGroup())); //PC-Emu QIcon emuIcon(":/Ico/Emu.png"); QString emuString("PC with emu"); QAction *emuAction = toolBarFichier->addAction(emuIcon, emuString); connect(emuAction, SIGNAL(triggered()), this, SLOT(CreateEmu())); //PC-Tap QIcon tapIcon(":/Ico/Tap.png"); QString tapString("PC with tap"); QAction *tapAction = toolBarFichier->addAction(tapIcon, tapString); connect(tapAction, SIGNAL(triggered()), this, SLOT(CreateTap())); //AP-Wifi QIcon apIcon(":/Ico/Ap-Wifi.png"); QString apString("AP Wifi"); QAction *apAction = toolBarFichier->addAction(apIcon, apString); connect(apAction, SIGNAL(triggered()), this, SLOT(CreateAp())); //StationWifi QIcon stasIcon(":/Ico/StationWifi.png"); QString stasString("Station Wifi"); QAction *stasAction = toolBarFichier->addAction(stasIcon, stasString); connect(stasAction, SIGNAL(triggered()), this, SLOT(CreateStation())); //Hub QIcon hubIcon(":/Ico/Hub.png"); QString hubString("Hub"); QAction *hubAction = toolBarFichier->addAction(hubIcon, hubString); connect(hubAction, SIGNAL(triggered()), this, SLOT(CreateHub())); //Switch QIcon switchIcon(":/Ico/Switch.png"); QString switchString("Switch"); QAction *switchAction = toolBarFichier->addAction(switchIcon, switchString); connect(switchAction, SIGNAL(triggered()), this, SLOT(CreateSwitch())); //Router QIcon routerIcon(":/Ico/Router.png"); QString routerString("Router"); QAction *routerAction = toolBarFichier->addAction(routerIcon, routerString); connect(routerAction, SIGNAL(triggered()), this, SLOT(CreateRouter())); //separator toolBarFichier->addSeparator(); // Wired Link QIcon linkIcon(":/Ico/WiredLink.png"); QString linkString("Wired Link"); QAction *linkAction = toolBarFichier->addAction(linkIcon, linkString); connect(linkAction, SIGNAL(triggered()), this, SLOT(CreateWiredLink())); // Station link QIcon stasLinkIcon(":/Ico/Link.png"); QString stasLinkString("Station Link"); QAction *stasLinkAction = toolBarFichier->addAction(stasLinkIcon, stasLinkString); connect(stasLinkAction, SIGNAL(triggered()), this, SLOT(CreateWifiLink())); //P2P link QIcon p2pLinkIcon(":/Ico/P2pLink.png"); QString p2pLinkString("P2P Link"); QAction *p2pLinkAction = toolBarFichier->addAction(p2pLinkIcon, p2pLinkString); connect(p2pLinkAction, SIGNAL(triggered()), this, SLOT(CreateP2pLink())); //separator toolBarFichier->addSeparator(); QIcon appsLinkIcon(""); QString appsLinkString("Application"); QAction *appsLinkAction = toolBarFichier->addAction(appsLinkIcon, appsLinkString); connect(appsLinkAction, SIGNAL(triggered()), this, SLOT(CreateApplication())); //separator toolBarFichier->addSeparator(); //Delete button QIcon delIcon(":/Ico/Del.png"); QString delString("Delete"); this->m_delAction = toolBarFichier->addAction(delIcon, delString); this->m_delAction->setDisabled (true); connect(this->m_delAction, SIGNAL(triggered()), this, SLOT(DeleteObject())); // // Creation of Drag N Drop Area. // QHBoxLayout *dragLayout = new QHBoxLayout; this->m_dw = new DragWidget(); dragLayout->addWidget(this->m_dw); QWidget *zoneCentral = new QWidget; zoneCentral->setLayout(dragLayout); this->setCentralWidget(zoneCentral); // // // this->m_dw->SetMainWindow(this); }
int LibraryDetectionManager::LoadXmlDoc( TiXmlDocument& Doc ) { int loaded = 0; for ( TiXmlElement* Elem = Doc.FirstChildElement("library"); Elem; Elem = Elem->NextSiblingElement("library") ) { // Load the version of this set int version = 0; if ( Elem->QueryIntAttribute( "version", &version ) != TIXML_SUCCESS ) version = 0; // Load shortcode wxString ShortCode = wxString(Elem->Attribute("short_code"),wxConvUTF8); if ( ShortCode.IsEmpty() ) continue; // Load name wxString Name = wxString( Elem->Attribute("name"), wxConvUTF8 ); if ( Name.IsEmpty() ) continue; // Check if we already have setting of this library // I'm to lazy to firbid const_cast here ;) LibraryDetectionConfigSet* OldSet = const_cast< LibraryDetectionConfigSet* > ( GetLibrary( ShortCode ) ); LibraryDetectionConfigSet* NewSet = 0; if ( OldSet ) { // There are detection settings yet, we override only when there's newer // or same version already if ( OldSet->Version > version ) continue; // We do not upgrade OldSet->Categories.Clear(); OldSet->Configurations.clear(); OldSet->LibraryName.Clear(); NewSet = OldSet; } else { NewSet = new LibraryDetectionConfigSet; Libraries.Add( NewSet ); } // Setup configuration set NewSet->ShortCode = ShortCode; NewSet->Version = version; NewSet->LibraryName = Name; // Read categories of library for ( TiXmlAttribute* attr = Elem->FirstAttribute(); attr; attr = attr->Next() ) { // if ( !strncasecmp(attr->Name(),"category",8) ) if ( !strncmp(attr->Name(),"category",8) ) NewSet->Categories.Add( wxString( attr->Value(),wxConvUTF8 ) ); } // Check if there's corresponding pkg-config entry if ( IsPkgConfigEntry(ShortCode) ) { LibraryDetectionConfig Config; Config.PkgConfigVar = ShortCode; Config.Description = NewSet->LibraryName + _T(" (pkg-config)"); LibraryDetectionFilter Filter; Filter.Type = LibraryDetectionFilter::PkgConfig; Filter.Value = ShortCode; Config.Filters.push_back(Filter); loaded += AddConfig(Config,NewSet) ? 1 : 0; } // Load libraries LibraryDetectionConfig Initial; loaded += LoadXml( Elem, Initial, NewSet ); } return loaded; }
int LibraryDetectionManager::LoadXml(TiXmlElement* Elem,LibraryDetectionConfig& Config,LibraryDetectionConfigSet* ConfigSet,bool Filters,bool Settings) { wxString Description = wxString(Elem->Attribute("description"),wxConvUTF8); if ( !Description.empty() ) Config.Description = Description; int loaded = 0; for ( TiXmlElement* Data = Elem->FirstChildElement(); Data; Data = Data->NextSiblingElement() ) { wxString Node = wxString(Data->Value(),wxConvUTF8).MakeLower(); if ( Filters && Settings ) { // Load subnodes if ( Node == _T("filters") ) { loaded += LoadXml(Data,Config,ConfigSet,true,false); continue; } if ( Node == _T("settings") ) { loaded += LoadXml(Data,Config,ConfigSet,false,true); continue; } // pkgconfig does define both filter and setting if ( Node == _T("pkgconfig") ) { Config.PkgConfigVar = wxString(Data->Attribute("name"),wxConvUTF8); LibraryDetectionFilter Filter; Filter.Type = LibraryDetectionFilter::PkgConfig; Filter.Value = Config.PkgConfigVar; Config.Filters.push_back(Filter); continue; } } if ( Filters ) { // Load filter LibraryDetectionFilter::FilterType Type = LibraryDetectionFilter::None; if ( Node == _T("platform") ) Type = LibraryDetectionFilter::Platform; else if ( Node == _T("file") ) Type = LibraryDetectionFilter::File; else if ( Node == _T("exec") ) Type = LibraryDetectionFilter::Exec; else if ( Node == _T("compiler") ) Type = LibraryDetectionFilter::Compiler; if ( Type != LibraryDetectionFilter::None ) { LibraryDetectionFilter Filter; Filter.Type = Type; Filter.Value = wxString(Data->Attribute("name"),wxConvUTF8); if ( !Filter.Value.IsEmpty() ) Config.Filters.push_back(Filter); continue; } } if ( Settings ) { // Load setting if ( Node==_T("path") ) { wxString Include = wxString(Data->Attribute("include"),wxConvUTF8); wxString Lib = wxString(Data->Attribute("lib"),wxConvUTF8); wxString Obj = wxString(Data->Attribute("obj"),wxConvUTF8); if ( !Include.empty() ) Config.IncludePaths.Add(Include); if ( !Lib.empty() ) Config.LibPaths.Add(Lib); if ( !Obj.empty() ) Config.ObjPaths.Add(Obj); continue; } if ( Node==_T("flags") ) { wxString cFlags = wxString(Data->Attribute("cflags"),wxConvUTF8); wxString lFlags = wxString(Data->Attribute("lflags"),wxConvUTF8); if ( !cFlags.empty() ) Config.CFlags.Add(cFlags); if ( !lFlags.empty() ) Config.LFlags.Add(lFlags); continue; } if ( Node==_T("add") ) { wxString cFlags = wxString(Data->Attribute("cflags"),wxConvUTF8); wxString lFlags = wxString(Data->Attribute("lflags"),wxConvUTF8); wxString Lib = wxString(Data->Attribute("lib") ,wxConvUTF8); wxString Define = wxString(Data->Attribute("define"),wxConvUTF8); if ( !cFlags.empty() ) Config.CFlags.Add(cFlags); if ( !lFlags.empty() ) Config.LFlags.Add(lFlags); if ( !Lib.empty() ) Config.Libs.Add(Lib); if ( !Define.empty() ) Config.Defines.Add(Define); } if ( Node==_T("header") ) { wxString file = wxString(Data->Attribute("file"),wxConvUTF8); if ( !file.empty() ) Config.Headers.Add(file); } if ( Node==_T("require") ) { wxString lib = wxString(Data->Attribute("library"),wxConvUTF8); if ( !lib.empty() ) Config.Require.Add(lib); } } } if ( Settings && Filters ) { TiXmlElement* Cfg = Elem->FirstChildElement("config"); if ( Cfg ) { // If there are any sub-configurations, let's // iterate through them and load config-specific settings for ( ;Cfg; Cfg = Cfg->NextSiblingElement("config") ) { // Append sub-configuration data LibraryDetectionConfig Copy(Config); loaded += LoadXml(Cfg,Copy,ConfigSet); } } else { // No sub-config entry, so let's add this one loaded += AddConfig(Config,ConfigSet) ? 1 : 0; } } return loaded; }