v8::Handle<Value> App::New(const Arguments& args) { v8::HandleScope scope; App* obj = new App(); obj->Wrap(args.This()); return scope.Close(args.This()); }
int main() { App app; app.Run(); return 0; }
int main(int argc, char* argv[]) { App mainApp; return mainApp.onExecute(); }
void Planet::RenderObject(Date t, App& app) { /*if (simpleRender) { scale = 0.000002f; } else { scale = 0.00000004f; } glDisable(GL_LIGHT0); glDisable(GL_LIGHTING);*/ //if (marked){ // scale = 0.00005f; //}else{ // scale = 0.00004f; //} //#pragma region CHECK_IF_SUN // if (body.GetSpiceId() == SUN_SPICE_ID){ // scale = 0.0000004f; // } //#pragma endregion #pragma region Object_Positioning Vector3T <Length> pos = body.GetPosition(t, SpaceObject::SSB, app.GetReferenceFrame()); Vector3 position(pos.x.ValueIn(app.LengthUnit())* distanceScale, pos.y.ValueIn(app.LengthUnit()) * distanceScale, pos.z.ValueIn(app.LengthUnit()) * distanceScale); Frame bodyFrame = body.GetDefaultFrame(); const Matrix4x4& matrix = bodyFrame.GetTransformationMatrix(t, app.GetReferenceFrame()); matrix.GetColumnMajor(rotationMatrix); #pragma region DRAW_INFO_BILLBOARD if (clicked) { Length radius = body.GetRadius(); DrawBillboard(position, radius.ValueIn(app.LengthUnit()) * scale); } #pragma endregion glPushName(ID); glPushMatrix(); #pragma region Trajectory_Rendering glBindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); if (body.GetSpiceName() == "MOON"); RenderTrajectory(t); #pragma endregion glTranslatef(position.x, position.y, position.z); glMultMatrixf(rotationMatrix); #pragma endregion #pragma region Render_As_Glu_Sphere if (marked) { glDisable(GL_LIGHT0); glDisable(GL_LIGHTING); } glBindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); //render as a GLU sphere quadric object GLUquadricObj* quadric = gluNewQuadric(); gluQuadricTexture(quadric, true); gluQuadricNormals(quadric, GLU_SMOOTH); Length radius = body.GetRadius(); gluSphere(quadric, radius.ValueIn(app.LengthUnit()) * scale, 30, 30); gluDeleteQuadric(quadric); #pragma endregion #pragma region Planet_Info_Writing glDisable(GL_LIGHTING); glColor3f(255.0, 255.0, 255.0); std::string data; if (marked) { std::ostringstream strs; strs << "Position: (" << pos.x.ValueIn(app.LengthUnit()) << app.LengthUnit().str() << ", " << pos.y.ValueIn(app.LengthUnit()) << app.LengthUnit().str() << ", " << pos.z.ValueIn(app.LengthUnit()) << app.LengthUnit().str() << ") " << app.GetReferenceFrame().GetName() << std::endl; data = body.GetName() + " " + strs.str(); } else { data = body.GetName(); } glRasterPos3f(0, 0, radius.ValueIn(app.LengthUnit()) * 1.1 * scale); font.glPrint(data.c_str()); glEnable(GL_LIGHTING); #pragma endregion glPopMatrix(); glPopName(); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); }
// windows callback LRESULT App::WindowProc(UINT message, WPARAM wParam, LPARAM lParam, BOOL* pProcessed) { int wmId, wmEvent; App *host = App::sharedInstance(); HWND hwnd = host->getWindowHandle(); switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { case ID_FILE_RELAUNCH: host->onFileRelaunch(); break; case ID_FILE_EXIT: host->onFileExit(); break; case ID_VIEW_PORTRAIT: case ID_VIEW_LANDSCAPE: host->onViewChangeOrientation(wmId); break; case ID_VIEW_RESET_ZOOM: case ID_VIEW_ZOOM_OUT: host->onViewChangeZoom(wmId); break; default: if (wmId >= ID_VIEW_SIZE && wmId <= ID_VIEW_SIZE + SimulatorConfig::sharedDefaults()->getScreenSizeCount() - 1) { host->onViewChangeFrameSize(wmId); break; } return 0; } break; case WM_KEYDOWN: if (wParam == VK_F5) { host->onFileRelaunch(); } break; case WM_COPYDATA: { PCOPYDATASTRUCT pMyCDS = (PCOPYDATASTRUCT) lParam; if (pMyCDS->dwData == CCLOG_STRING) { const char *szBuf = (const char*)(pMyCDS->lpData); sharedInstance()->writeDebugLog(szBuf); break; } } default: return 0; } *pProcessed = TRUE; return 0; }
void onValueChanged(ui::Control*, bool value) { if (s_app.tritonLayer) s_app.removeTriton(); else s_app.addTriton(); }
void calibratedPressed(){ app->setRotationRef(); }
qreal VirtualConsole::pixelDensity() const { App *app = qobject_cast<App *>(m_view); return app->pixelDensity(); }
BOOL Initialize(GL_Window* window, Keys* keys) // Any OpenGL Initialization Goes Here { font = Font(window->hDC); standalonePointFont = Font(window->hDC); glShadeModel(GL_SMOOTH); glEnable(GL_TEXTURE_2D); app.SetLoggingFile("error.log"); app.SetReferenceFrame(Frame::ECLIPJ2000); app.SetDefaultUnits(App::UT_DEFAULT); app.LoadKernel("data/meta.tm"); //app.LoadChildren(SpaceObject("Solar system barycenter"), true, true); app.AddObject(SpaceBody("EARTH")); app.AddObject(SpaceBody("SUN")); app.AddObject(SpaceBody("MOON")); app.AddObject(SpaceObject("L2_OBJECT")); app.AddObject(SpaceObject("L2")); TGA* sunTexture = new TGA("Images\\SUN.tga"); skyTexture = new TGA("Images\\STARS.tga"); t = Date("Mar 29 2016 01:03:52.99996036291100000 (UTC+0)"); size_t count = app.GetObjectsLength(); for (int i = 0; i < count; i++) { const SpaceObject& obj = app.GetObjectByIndex(i); try { if (SpaceObject::IsPlanet(obj.GetSpiceId()) || obj.GetSpiceId() == SUN_SPICE_ID || obj.GetSpiceName() == "MOON") { std::string path = "Images\\" + obj.GetName() + ".tga"; if (TGA* Texture = new TGA(path.c_str())) { const SpaceBody& body = dynamic_cast<const SpaceBody&>(obj); SolarSystem.addPlanet(Planet(body, Texture, obj, app.GetReferenceFrame(), window->hDC)); } else { const SpaceBody& body = dynamic_cast<const SpaceBody&>(obj); SolarSystem.addPlanet(Planet(body, sunTexture, obj, app.GetReferenceFrame(), window->hDC)); } } else if (obj.GetSpiceName() == "L2_OBJECT") SolarSystem.AddTrajectoryAsSpaceObject(obj, app.GetReferenceFrame(), t, app.RetrieveObject("L2")); else if (obj.GetSpiceName() == "L2") SolarSystem.AddStandaloneSpacePoint(obj, standalonePointFont); } catch (const std::bad_cast&) { } } g_window = window; g_keys = keys; g_Camera.PositionCamera(Vector3(-5.5f, 28.44f, 0.2f), Vector3(-17.6f, 53.26f, -8.5f), Vector3(0, 0, 1)); //g_Camera.FocusOnPlanet(SolarSystem.FindObjectWithID(0), t, app); RECT rect; GetClientRect(g_window->hWnd, &rect); centerX = (rect.right - rect.left) >> 1; centerY = (rect.bottom - rect.top) >> 1; SetCursorPos(centerX, centerY); //t = Date("Aug 17 2000 15:51:01 UTC-5"); //Color setup glClearColor(0, 0, 0, 1); float g_LightPosition[4] = { 1, 1, 0, 1 }; float ambience[4] = { 0.0f, 0.0f, 0.0f }; float diffuse[4] = { 1.0f, 0.9f, 0.9f }; glLightfv(GL_LIGHT0, GL_AMBIENT, ambience); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_POSITION, g_LightPosition); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); return TRUE; // Return TRUE (Initialization Successful) }
void main() { App a; a.Go(); }
int main(int argc, char** argv) { App prog; return prog.onExecute(); }
FixtureRemap::FixtureRemap(Doc *doc, QWidget *parent) : QDialog(parent) , m_doc(doc) { Q_ASSERT(doc != NULL); setupUi(this); connect(m_addButton, SIGNAL(clicked()), this, SLOT(slotAddTargetFixture())); connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveTargetFixture())); connect(m_cloneButton, SIGNAL(clicked()), this, SLOT(slotCloneSourceFixture())); connect(m_remapButton, SIGNAL(clicked()), this, SLOT(slotAddRemap())); connect(m_unmapButton, SIGNAL(clicked()), this, SLOT(slotRemoveRemap())); m_cloneButton->setEnabled(false); remapWidget = new RemapWidget(m_sourceTree, m_targetTree, this); remapWidget->show(); m_remapLayout->addWidget(remapWidget); m_targetDoc = new Doc(this); /* Load user fixtures first so that they override system fixtures */ m_targetDoc->fixtureDefCache()->load(QLCFixtureDefCache::userDefinitionDirectory()); m_targetDoc->fixtureDefCache()->load(QLCFixtureDefCache::systemDefinitionDirectory()); m_sourceTree->setIconSize(QSize(24, 24)); m_sourceTree->setAllColumnsShowFocus(true); fillFixturesTree(m_doc, m_sourceTree); m_targetTree->setIconSize(QSize(24, 24)); m_targetTree->setAllColumnsShowFocus(true); connect(m_sourceTree->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(slotUpdateConnections())); connect(m_sourceTree, SIGNAL(clicked(QModelIndex)), this, SLOT(slotUpdateConnections())); connect(m_sourceTree, SIGNAL(expanded(QModelIndex)), this, SLOT(slotUpdateConnections())); connect(m_sourceTree, SIGNAL(collapsed(QModelIndex)), this, SLOT(slotUpdateConnections())); connect(m_sourceTree, SIGNAL(itemSelectionChanged()), this, SLOT(slotSourceSelectionChanged())); connect(m_targetTree->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(slotUpdateConnections())); connect(m_targetTree, SIGNAL(clicked(QModelIndex)), this, SLOT(slotUpdateConnections())); connect(m_targetTree, SIGNAL(expanded(QModelIndex)), this, SLOT(slotUpdateConnections())); connect(m_targetTree, SIGNAL(collapsed(QModelIndex)), this, SLOT(slotUpdateConnections())); // retrieve the original project name for QLC+ main class App *mainApp = (App *)m_doc->parent(); QString prjName = mainApp->fileName(); if (prjName.lastIndexOf(".") > 0) prjName.insert(prjName.lastIndexOf("."), tr(" (remapped)")); else prjName.append(tr(" (remapped)")); m_targetProjectLabel->setText(prjName); }
int main(int argc, char* argv[]) #endif { #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX //XInitThreads(); #endif setlocale(LC_NUMERIC, "C"); PATHMANAGER::Init(std::cout, std::cerr); std::streambuf* oldCout = std::cout.rdbuf(); std::streambuf* oldCerr = std::cerr.rdbuf(); #if 0 std::string po = PATHMANAGER::UserConfigDir() + "/ogre_ed.out"; std::ofstream out(po.c_str()); std::cout.rdbuf(out.rdbuf()); // redirect std::cout to out.txt #endif #if 1 std::string pa = PATHMANAGER::UserConfigDir() + "/ogre_ed.err"; std::ofstream oute(pa.c_str()); std::cerr.rdbuf(oute.rdbuf()); // redirect std::cerr to oute.txt #endif /// Load Settings //---------------------------------------------------------------- SETTINGS* settings = new SETTINGS(); std::string setFile = PATHMANAGER::EditorSetFile(); if (!PATHMANAGER::FileExists(setFile)) { std::cout << "Settings not found - loading defaults." << std::endl; LoadDefaultSet(settings,setFile); } settings->Load(setFile); // LOAD if (settings->version != SET_VER) // loaded older, use default { std::cout << "Settings found, but older version - loading defaults." << std::endl; boost::filesystem::rename(setFile, PATHMANAGER::UserConfigDir() + "/editor_old.cfg"); LoadDefaultSet(settings,setFile); settings->Load(setFile); // LOAD } // Start //---------------------------------------------------------------- App* pApp = new App(settings); try { #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 pApp->Run( settings->ogre_dialog || lpCmdLine[0]!=0 ); #else pApp->Run( settings->ogre_dialog ); #endif } catch (Ogre::Exception& e) { #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 MessageBoxA( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL); #else std::cerr << "An exception has occured: " << e.getFullDescription().c_str() << std::endl; #endif } pApp->SaveCam(); delete pApp; settings->Save(setFile); delete settings; std::cout.rdbuf(oldCout); std::cerr.rdbuf(oldCerr); return 0; }
int main() { return theApp.exec(); }
int main() { App app; return app.run(); }
int main(int argc, char *argv[]) { App *app = new App(); app->process(argc, argv); }
FhgfsOpsErr SetMetadataMirroringMsgEx::setDirMirroring(EntryInfo* entryInfo) { const char* logContext = "SetMetadataMirroringMsg (set dir mirror)"; App* app = Program::getApp(); MetaStore* metaStore = app->getMetaStore(); NodeCapacityPools* metaCapacityPools = app->getMetaCapacityPools(); // verify owner of root dir if( (entryInfo->getEntryID() == META_ROOTDIR_ID_STR) && (app->getLocalNodeNumID() != app->getRootDir()->getOwnerNodeID() ) ) { LogContext(logContext).log(Log_DEBUG, "This node does not own the root directory."); return FhgfsOpsErr_NOTOWNER; } DirInode* dir = metaStore->referenceDir(entryInfo->getEntryID(), true); if(unlikely(!dir) ) return FhgfsOpsErr_NOTADIR; // choose new dir mirror node /* (note: choosing 2 nodes here is a workaround to ensure that we have at least one node available that is not the current node.) */ UInt16Vector mirrorCandidates; unsigned numDesiredTargets = 2; unsigned minNumRequiredTargets = numDesiredTargets; metaCapacityPools->chooseStorageTargets( numDesiredTargets, minNumRequiredTargets, NULL, &mirrorCandidates); if(unlikely(mirrorCandidates.size() < minNumRequiredTargets) ) { // (might be caused by a bad list of preferred targets) /* note: if we only got one here, that would be ourselve, so we definitely need mirrorCandidates.size()==2 */ LogContext(logContext).logErr( "No metadata servers available to mirror directory. " "DirID: " + entryInfo->getEntryID() ); metaStore->releaseDir(entryInfo->getEntryID() ); return FhgfsOpsErr_UNKNOWNNODE; } // make sure we don't pick ourselve as mirror uint16_t mirrorNodeID; if(mirrorCandidates[0] != app->getLocalNodeNumID() ) mirrorNodeID = mirrorCandidates[0]; else mirrorNodeID = mirrorCandidates[1]; // set and store new mirror (this also sends the initial copy to the mirror) FhgfsOpsErr setRes = dir->setAndStoreMirrorNodeIDChecked(mirrorNodeID); if(setRes != FhgfsOpsErr_SUCCESS) { if(setRes == FhgfsOpsErr_INVAL) { // this dir already has a mirror node LogContext(logContext).log(Log_DEBUG, "Directory already has a mirror. " "DirID: " + entryInfo->getEntryID() ); } else LogContext(logContext).logErr("Setting dir mirror failed. " "DirID: " + entryInfo->getEntryID() + "; " "Error: " + FhgfsOpsErrTk::toErrString(setRes) ); } metaStore->releaseDir(entryInfo->getEntryID() ); return setRes; }
int main() { std::ofstream fout; fout.open("out.txt"); try { App app; app.SetLoggingFile("error.log"); app.LoadKernel("data/meta.tm"); app.SetReferenceFrame(Frame::ECLIPJ2000); // Set reference frame to ECLIPJ200, default is J2000 app.SetDefaultUnits(App::UT_DEFAULT); // Same as UT_METRIC, except Length is measured in km. This is set by default //app.SetDefaultUnits(App::UT_METRIC); // Default units are meters, meters per second and kilograms //app.SetDefaultUnits(App::UT_IMPERIAL); // Default units are miles, miles per hour and pounds //app.LoadSolarSystem(); // Loads Solar System. Optional parameter controls whether to load only planets and Sun or to load entire Solar System //app.LoadAllAvailableObjects(); // Loads all objects which were introduced in loaded kernels //app.LoadMoons(SpaceObject("Earth")); // Creates SpaceObjects instance and uses it to specify parent body //app.LoadMoons("Jupiter"); // Loads moons of Jupiter, internally the same as LoadMoons(SpaceObject("Jupiter")) //if(app.CheckObjectExists("Pluto")) // app.LoadMoons(app.RetrieveObject("Pluto")); // Same as LoadMoons(SpaceObject("Pluto")), except this doesn't construct new SpaceObject instance, instead it uses reference to already loaded SpaceObject instance app.AddObject(SpaceBody("europa")); app.AddObject(SpaceBody("MOON")); app.AddObject(SpaceBody("Io")); std::vector<SpaceObject*> barycenters = app.GetLoadedBarycenters(); std::vector<SpaceObject*> planets = app.GetLoadedPlanets(); std::vector<SpaceObject*> moons = app.GetLoadedMoons(); std::vector<SpaceObject*> jupiterMoons = app.GetLoadedMoonsOf(SpaceObject("Jupiter")); std::vector<SpaceObject*> marsMoons = app.GetLoadedMoonsOf(SpaceObject("mars")); app.LoadSolarSystem(true); std::vector<KernelData> kernels = CSpiceUtil::GetLoadedKernels(); fout << "Loaded kernels:" << std::endl; for(size_t i = 0; i < kernels.size(); i++) { KernelData kData = kernels[i]; fout << "\t" << kData.filename << " (" << kData.type << ")" << std::endl; } fout << std::endl; size_t objectsCount = app.GetObjectsLength(); for(size_t i = 0; i < objectsCount; i++) { const SpaceObject& obj = app.GetObjectByIndex(i); fout << obj.GetName() << " summary:" << std::endl; try { const SpaceBody& body = dynamic_cast<const SpaceBody&>(obj); fout << "Bulk parameters:" << std::endl; if(body.HasParameter(SpaceBody::BP_MASS)) fout << "\tMass: " << body.GetMass().ValueIn(app.MassUnit()) << " " << app.MassUnit().str() << std::endl; if(body.HasParameter(SpaceBody::BP_GM)) fout << "\tGM: " << body.GetGM().ValueIn(app.GMUnit()) << " " << app.GMUnit().str() << std::endl; if(body.HasParameter(SpaceBody::BP_ACC)) fout << "\tg: " << body.GetSurfaceAcceleration().ValueIn(app.AccelerationUnit()) << " " << app.AccelerationUnit().str() << std::endl; if(body.HasParameter(SpaceBody::BP_RADIUS)) { Length radius = body.GetRadius(); std::array<Length, 3> radii = body.GetRadii(); fout << "\tRadius: " << radius.ValueIn(app.LengthUnit()) << " (" << radii[0].ValueIn(app.LengthUnit()) << ", " << radii[1].ValueIn(app.LengthUnit()) << ", " << radii[2].ValueIn(app.LengthUnit()) << ") " << app.LengthUnit().str() << std::endl; } fout << std::endl; } catch(const std::bad_cast&) { } Date t("Aug 17 2000 15:51:01 UTC-5"); t += Time(1.0, Units::Common::days); Window spkCoverage = obj.GetCoverage(); std::vector<Interval> spkIntervals = spkCoverage.GetIntervals(); fout << "SPK state:" << std::endl; fout << "\tCoverage:" << std::endl; if(spkIntervals.size() == 0) { fout << "\t\tObject does not contain any state data" << std::endl; } for(size_t i = 0; i < spkIntervals.size(); i++) { Interval interval = spkIntervals[i]; Date begin(interval.GetLeft()); Date end(interval.GetRight()); fout << "\t\t" << begin.AsString() << " - " << end.AsString() << std::endl; } fout << std::endl; fout << "\t" << t.AsString() << " relative to " << app.GetReferenceFrame().GetName() << ":" << std::endl; if(spkCoverage.IsIncluded(t.AsDouble())) { Vector3T<Length> pos = obj.GetPosition(t, app.GetReferenceFrame()); Vector3T<Velocity> vel = obj.GetVelocity(t, app.GetReferenceFrame()); fout << "\t\tPos: " << pos.Length().ValueIn(app.LengthUnit()) << " (" << pos.x.ValueIn(app.LengthUnit()) << ", " << pos.y.ValueIn(app.LengthUnit()) << ", " << pos.z.ValueIn(app.LengthUnit()) << ") " << app.LengthUnit().str() << std::endl; fout << "\t\tVel: " << vel.Length().ValueIn(app.VelocityUnit()) << " (" << vel.x.ValueIn(app.VelocityUnit()) << ", " << vel.y.ValueIn(app.VelocityUnit()) << ", " << vel.z.ValueIn(app.VelocityUnit()) << ") " << app.VelocityUnit().str() << std::endl; } else { fout << "\t\tNo state data on this epoch" << std::endl; } fout << std::endl; try { const SpaceBody& body = dynamic_cast<const SpaceBody&>(obj); fout << "PCK orientation:" << std::endl; if(body.HasDefaultFrame()) { Frame bodyFrame = body.GetDefaultFrame(); fout << "(using frame " << bodyFrame.GetName() << ")" << std::endl; if(bodyFrame.HasAvailableData()) { bool dataAvailableAtT = true; fout << "\tCoverage:" << std::endl; if(bodyFrame.HasLimitedCoverage()) { Window pckCoverage = bodyFrame.GetCoverage(); std::vector<Interval> pckIntervals = pckCoverage.GetIntervals(); dataAvailableAtT = pckCoverage.IsIncluded(t.AsDouble()); if(pckIntervals.size() == 0) { fout << "\t\tObject does not contain any orientation data" << std::endl; } for(size_t i = 0; i < pckIntervals.size(); i++) { Interval interval = pckIntervals[i]; Date begin(interval.GetLeft()); Date end(interval.GetRight()); fout << "\t\t" << begin.AsString() << " - " << end.AsString() << std::endl; } fout << std::endl; } else { fout << "\t\tUnlimited" << std::endl; } fout << "\t" << t.AsString() << app.GetReferenceFrame().GetName() << ":" << std::endl; if(dataAvailableAtT) { Vector3 axisX = bodyFrame.AxisX(t, app.GetReferenceFrame()); Vector3 axisY = bodyFrame.AxisY(t, app.GetReferenceFrame()); Vector3 axisZ = bodyFrame.AxisZ(t, app.GetReferenceFrame()); fout << "\t\tX axis: (" << axisX.x << ", " << axisX.y << ", " << axisX.z << ")" << std::endl; fout << "\t\tY axis: (" << axisY.x << ", " << axisY.y << ", " << axisY.z << ")" << std::endl; fout << "\t\tZ axis: (" << axisZ.x << ", " << axisZ.y << ", " << axisZ.z << ")" << std::endl; const Matrix4x4& matrix = bodyFrame.GetTransformationMatrix(t, app.GetReferenceFrame()); fout << "\t\tTransformation matrix:" << std::endl; for(int row = 0; row < 4; row++) { fout << "\t\t\t"; for(int col = 0; col < 4; col++) { fout << std::fixed << std::setw(11) << matrix.Get(row, col) << std::defaultfloat << " "; } fout << std::endl; } } else { fout << "\t\tNo orientation data available on this epoch" << std::endl; } } else { fout << "\tFrame does not contain any orientation data" << std::endl; } } else { fout << "\tObject does not contain any orientation data" << std::endl; } } catch(const std::bad_cast&) { } fout << "===============================================================================" << std::endl; fout << std::endl; } std::cout << "All is fine. See out.txt for results" << std::endl; } catch(const std::exception& ex) { std::cout << std::endl; std::cout << "Error encountered:" << std::endl; std::cout << ex.what() << std::endl; std::cout << "See details in the error log file" << std::endl; } std::getchar(); return 0; }
int main(int argc, char** argv) { osg::ArgumentParser arguments(&argc,argv); // help? if ( arguments.read("--help") ) return usage(argv[0]); osg::Node* model = 0L; std::string filename; if (arguments.read("--model", filename)) { model = osgDB::readRefNodeFile(filename).release(); Registry::shaderGenerator().run(model); } // create a viewer: osgViewer::Viewer viewer(arguments); // Tell the database pager to not modify the unref settings viewer.getDatabasePager()->setUnrefImageDataAfterApplyPolicy( false, false ); // install our default manipulator (do this before calling load) EarthManipulator* manip = new EarthManipulator(); viewer.setCameraManipulator(manip); // load an earth file, and support all or our example command-line options // and earth file <external> tags osg::Group* node = osgEarth::Util::MapNodeHelper().load(arguments, &viewer, createUI()); if ( node ) { viewer.getCamera()->setNearFarRatio(0.00002); viewer.getCamera()->setSmallFeatureCullingPixelSize(-1.0f); viewer.setSceneData( node ); s_app.map = MapNode::get( node )->getMap(); s_app.addTriton(); s_app.addBuoyancyTest(model); // Zoom the camera to our area of interest: Viewpoint vp; vp.heading() = 25.0f; vp.pitch() = -25; vp.range() = 400.0; vp.focalPoint() = s_app.anchor; manip->setViewpoint(vp); while(!viewer.done()) { viewer.frame(); s_app.updateBuoyancyTest(); } } else { return usage(argv[0]); } }
static gboolean on_idle(gpointer data) { App *context = static_cast<App*>(data); context->poll(); return TRUE; }
void clearPressed(){ app->clear(); app->current_state->clean(); }
/** * Available start arguments: * /sample-data: Adds a list of sample books and students to the System on startup. */ int main(int argc, char *argv[]) { // Global instances used in the application: LMS* lmsInstance = new LMS(); IO* ioInstance = new IO(); App *app = new App(lmsInstance, ioInstance); // Build the menu structure: Menu* mQuery = new Menu("Query the library"); mQuery->AddAction("Show book info", Actions::BooksInfo); mQuery->AddAction("Show student info", Actions::StudentsInfo); mQuery->AddAction("Show borrowed books", Actions::BorrowedBooks); mQuery->AddAction("Show overdue books", Actions::OverdueBooks); mQuery->AddAction("Show book records", Actions::ShowRecords); mQuery->AddAction("Show all registered books", Actions::ShowAllBooks); mQuery->AddAction("Show all registered students", Actions::ShowAllStudents); Menu* mManageData = new Menu("Manage data"); mManageData->AddAction("Register a new book", Actions::CreateBook); mManageData->AddAction("Update a book", Actions::UpdateBook); mManageData->AddAction("Remove a book", Actions::RemoveBook); mManageData->AddAction("Register a new student", Actions::CreateStudent); mManageData->AddAction("Update a student", Actions::UpdateStudent); mManageData->AddAction("Remove a student", Actions::RemoveStudent); Menu* mExport = new Menu("Export data"); mExport->AddAction("Export books", Actions::ExportBooks); mExport->AddAction("Export students", Actions::ExportStudents); Menu* mRoot = new Menu("Main Menu"); mRoot->AddAction("Borrow a book", Actions::BorrowBook); mRoot->AddAction("Return a book", Actions::ReturnBook); mRoot->AddSubItem(mManageData); mRoot->AddSubItem(mQuery); mRoot->AddSubItem(mExport); // Show the start screen: cout << "Welcome to LMS (Library Management System)!" << endl; cout << "Enter the number of an action or menu to navigate through the programme." << endl; cout << "You can enter a single 'q' at any moment to quit an action or move a menu up." << endl; cout << "Have Fun!" << endl << endl; // Add some sample data if requested: // hint: argv[0] is the name of the program. if (argc > 1 && std::string(argv[1]) == "--sample-data") { lmsInstance->AddBook("1234567890", "how to C++", "Hans Hacker", "Coding Inc.", 2012, 3); lmsInstance->AddBook("1234567891", "How to Javascript", "Willi Web", "Coding Inc.", 2012, 5); lmsInstance->AddBook("1234567892", "How to have fun outside", "Ferdinand Fun", "Better Life Publications", 2012, 5); lmsInstance->AddStudent("0123456", "Remo Zumsteg", "Department of Industrial Engineering & Management", "*****@*****.**"); lmsInstance->AddStudent("0123457", "Hans Noetig", "Department of Education", "*****@*****.**"); lmsInstance->AddStudent("0123458", "Suppe Chasper", "Department of Art", "*****@*****.**"); } // Render the main menu: app->Render(mRoot); cout << "Good bye!" << endl; return 0; }
int main (int argc, char const* argv[]) { App app; return app.go("sfmlframework"); }
int main(int argc, char** argv) { App app; app.run(); return 0; }
int main(int argc, char **argv) { App app; return app.Entry(argc, argv); }
/** * This is the static nftw() callback, which is called for every file/subdir within * "<storageDir>/dentries". * * Note: This method gets access to the FileResyncerGatherSlave instance through the "thisStatic" * member. * * @param path full path to file * @param statBuf normal struct stat contents (as in "man stat(2)") * @param ftwEntryType FTW_... (e.g. FTW_F for files) * @param ftwBuf ftwBuf->level is depth relative to nftw search path; ftwBuf->base is index in * path where filename starts (typically used as "path+ftwBuf->base"). */ int FileResyncerGatherSlave::handleDiscoveredDentriesSubentry(const char* path, const struct stat* statBuf, int ftwEntryType, struct FTW* ftwBuf) { const char* logContext = "FileResyncerGatherSlave (handle dentries subentry)"; const char* entryName = path + ftwBuf->base; // skip too deep dirs (e.g. fsids dirs) if( (ftwEntryType == FTW_D) && (ftwBuf->level >= FILERESYNCGATHER_DENTRY_DEPTH) ) { // directory too deep to be interesting for us LogContext(logContext).log(Log_SPAM, std::string("Skipping subtree: ") + path); return FTW_SKIP_SUBTREE; } // continue to next entry if this is not a file at the right depth if( (ftwEntryType != FTW_F) || (ftwBuf->level != FILERESYNCGATHER_DENTRY_DEPTH) ) { // not a file or a file at the wrong depth level if(ftwEntryType != FTW_D) // don't spam log with all hash dirs (only print other entry types) LogContext(logContext).log( Log_SPAM, std::string("Skipping entry: ") + path + "; " "type: " + getFtwEntryTypeStr(ftwEntryType) ); return FTW_CONTINUE; } // we found a dentry file at the right depth... App* app = Program::getApp(); MetaStore *metaStore = app->getMetaStore(); thisStatic->numEntriesDiscovered.increase(); // reference parent dir (and find out whether this dentry refers to a file or a dir) std::string parentPath = StorageTk::getPathDirname(path); std::string parentDirID = StorageTk::getPathBasename(parentPath); // contents dir name equals ID DirInode* dirInode = metaStore->referenceDir(parentDirID, true); if(!dirInode) { // appearently, the dir has just been removed by user => ignore LogContext(logContext).log(Log_SPAM, std::string("Contents dir vanished before referencing: ") + path); return FTW_CONTINUE; } // got the parent dir inode, now get the entryInfo UInt16Set* resyncMirrorTargets = &thisStatic->resyncMirrorTargets; EntryInfo fileEntryInfo; FileInode* fileInode; StripePattern* pattern; bool gotMatch; bool getFileDentryRes = dirInode->getFileEntryInfo(entryName, fileEntryInfo); if(!getFileDentryRes) { // ether not a file or it was just moved/deleted LogContext(logContext).log(Log_SPAM, std::string("Discovered dentry not a file or vanished before it could be read: ") + path); goto release_parent; } // check if this is an inlined inode (non-inlined inodes will be handled in separate walk) if(! (fileEntryInfo.getIsInlined() ) ) goto release_parent; // dentry refers to a file => try to reference it fileInode = metaStore->referenceFile(&fileEntryInfo); if(!fileInode) { // file was just moved/deleted LogContext(logContext).log(Log_SPAM, std::string("Discovered file vanished before it could be referenced: ") + path); goto release_parent; } // got the file reference => check whether it matches our search pattern pattern = fileInode->getStripePattern(); gotMatch = testTargetMatch(resyncMirrorTargets, pattern); if(!gotMatch) goto release_file; thisStatic->numFilesMatched.increase(); // TODO: this file is a sync candidate // clean up release_file: metaStore->releaseFile(fileEntryInfo.getParentEntryID(), fileInode); release_parent: metaStore->releaseDir(parentDirID); return FTW_CONTINUE; }
/** * THE entry point for the application * * @param argc Number of arguments in array argv * @param argv Arguments array */ int main(int argc, char** argv) { /* Create the Qt core application object */ QApplication qapp(argc, argv); /* At least MIDI plugin requires this so best to declare it here for everyone */ qRegisterMetaType<QVariant>("QVariant"); #if defined(__APPLE__) || defined(Q_OS_MAC) /* Load plugins from within the bundle ONLY */ QDir dir(QApplication::applicationDirPath()); dir.cdUp(); dir.cd("plugins"); QApplication::setLibraryPaths(QStringList(dir.absolutePath())); #endif QLCi18n::init(); /* Let the world know... */ printVersion(); /* Parse command-line arguments */ if (parseArgs() == false) return 0; /* Load translation for main application */ QLCi18n::loadTranslation("qlcplus"); /* Handle debug messages */ #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) qInstallMsgHandler(qlcMessageHandler); #else qInstallMessageHandler(qlcMessageHandler); #endif /* Create and initialize the QLC application object */ App app; if (QLCArgs::enableOverscan == true) app.enableOverscan(); if (QLCArgs::noGui == true) app.disableGUI(); app.startup(); app.show(); if (QLCArgs::workspace.isEmpty() == false) { if (app.loadXML(QLCArgs::workspace) == QFile::NoError) app.updateFileOpenMenu(QLCArgs::workspace); } if (QLCArgs::operate == true) app.slotModeOperate(); if (QLCArgs::kioskMode == true) app.enableKioskMode(); if (QLCArgs::fullScreen == true) app.slotControlFullScreen(QLCArgs::fullScreenResize); if (QLCArgs::kioskMode == true && QLCArgs::closeButtonRect.isValid() == true) app.createKioskCloseButton(QLCArgs::closeButtonRect); if (QLCArgs::enableWebAccess == true) { WebAccess *webAccess = new WebAccess(app.doc(), VirtualConsole::instance(), SimpleDesk::instance()); QObject::connect(webAccess, SIGNAL(toggleDocMode()), &app, SLOT(slotModeToggle())); QObject::connect(webAccess, SIGNAL(loadProject(QString)), &app, SLOT(slotLoadDocFromMemory(QString))); QObject::connect(webAccess, SIGNAL(storeAutostartProject(QString)), &app, SLOT(slotSaveAutostart(QString))); } return qapp.exec(); }
/** * This is the static nftw() callback, which is called for every file/subdir within * "<storageDir>/inodes". * * Note: This method gets access to the FileResyncerGatherSlave instance through the "thisStatic" * member. * * @param path full path to file * @param statBuf normal struct stat contents (as in "man stat(2)") * @param ftwEntryType FTW_... (e.g. FTW_F for files) * @param ftwBuf ftwBuf->level is depth relative to nftw search path; ftwBuf->base is index in * path where filename starts (typically used as "path+ftwBuf->base"). */ int FileResyncerGatherSlave::handleDiscoveredInodesSubentry(const char* path, const struct stat* statBuf, int ftwEntryType, struct FTW* ftwBuf) { const char* logContext = "FileResyncerGatherSlave (handle inodes subentry)"; const char* entryName = path + ftwBuf->base; // skip too deep dirs (though there actually shouldn't be any) if( (ftwEntryType == FTW_D) && (ftwBuf->level >= FILERESYNCGATHER_DENTRY_DEPTH) ) { // directory too deep to be interesting for us LogContext(logContext).log(Log_SPAM, std::string("Skipping subtree: ") + path); return FTW_SKIP_SUBTREE; } // continue to next entry if this is not a file at the right depth if( (ftwEntryType != FTW_F) || (ftwBuf->level != FILERESYNCGATHER_DENTRY_DEPTH) ) { // not a file or a file at the wrong depth level if(ftwEntryType != FTW_D) // don't spam log with all hash dirs (only print other entry types) LogContext(logContext).log( Log_SPAM, std::string("Skipping entry: ") + path + "; " "type: " + getFtwEntryTypeStr(ftwEntryType) ); return FTW_CONTINUE; } // we found an inode file at the right depth... App* app = Program::getApp(); MetaStore *metaStore = app->getMetaStore(); thisStatic->numEntriesDiscovered.increase(); // find out whether it is a file inode DirInode* dirInode = NULL; FileInode* fileInode = NULL; bool referenceRes = metaStore->referenceInode(entryName, &fileInode, &dirInode); if(!referenceRes) { LogContext(logContext).log(Log_DEBUG, std::string("Inode loading failed: ") + path); return FTW_CONTINUE; } if(dirInode) { // skip dir inodes LogContext(logContext).log(Log_SPAM, std::string("Skipping discovered dir inode: ") + path); metaStore->releaseDir(entryName); return FTW_CONTINUE; } if(unlikely(!fileInode) ) return FTW_CONTINUE; // (should actually never happen, because referenceRes==true here) // file inode => check if it matches our search criteria StripePattern* pattern = fileInode->getStripePattern(); bool gotMatch = testTargetMatch(&thisStatic->resyncMirrorTargets, pattern); if(!gotMatch) goto release_file; thisStatic->numFilesMatched.increase(); // TODO: this file is a sync candidate release_file: // (note: parentID not relevant for non-inlined inodes) metaStore->releaseFile("RESYNCER_NO_PARENTID", fileInode); return FTW_CONTINUE; }
// Traditional main with Application object main(){ App m; m.run(); }
static inline int init_facilities(App & app, AppImpl * impl_){ //3.global logger logger_config_t lconf; lconf.dir = app.cmdopt().getoptstr("log-dir"); lconf.pattern = app.cmdopt().getoptstr("log-file"); lconf.lv = INT_LOG_LEVEL(app.cmdopt().getoptstr("log-level")); lconf.max_file_size = app.cmdopt().getoptint("log-size"); lconf.max_roll = app.cmdopt().getoptint("log-roll"); int ret = default_logger_init(lconf); if (ret){ fprintf(stderr, "logger init error = %d", ret); return -2; } //init timer ret = eztimer_init(); if (ret){ GLOG_ERR("eztimer init error :%d", ret); return -3; } eztimer_set_dispatcher(app_timer_dispatch); impl_->stcp = dctcp_default_pump(); if (!impl_->stcp){ GLOG_SER("dctcp loop init error !"); return -4; } dctcp_event_cb(impl_->stcp, app_stcp_listener, impl_); //control const char * console_listen = app.cmdopt().getoptstr("console-listen"); if (console_listen){ impl_->console = dctcp_listen(impl_->stcp, console_listen, "token:\r\n\r\n", app_console_listener, impl_); if (impl_->console < 0){ GLOG_SER("console init listen error : %d!", impl_->console); return -5; } } impl_->interval = app.cmdopt().getoptint("tick-interval"); impl_->maxtptick = app.cmdopt().getoptint("tick-maxproc"); //tzo set app.gmt_tz_offset(impl_->cmdopt->getoptint("tzo")); ////////////////////////////////////////////////////////////////////////////////// std::vector<dcshmobj_user_t*> shmusers = app.shm_users(); if (!shmusers.empty()){ const char * shmkey = app.cmdopt().getoptstr("shm"); if (!shmkey){ GLOG_ERR("not config shm key path setting !"); return -6; } for (size_t i = 0; i < shmusers.size(); ++i){ impl_->shm_pool.regis(shmusers[i]); } ret = impl_->shm_pool.start(shmkey); if (ret){ GLOG_ERR("shm pool start error ret:%d shm path:%s !", ret, shmkey); return -7; } } return 0; }