int main() { auto foo = Foo{}; foo.setInstance(std::make_unique<Bar>()); auto bar = std::make_unique<Bar>(); foo.setInstance(std::move(bar)); foo.bar_->hello(); }
KDiff3Part::KDiff3Part( QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name ) : KParts::ReadOnlyPart(parent, name) { // we need an instance setInstance( KDiff3PartFactory::instance() ); // this should be your custom internal widget m_widget = new KDiff3App( parentWidget, widgetName, this ); // This hack is necessary to avoid a crash when the program terminates. m_bIsShell = dynamic_cast<KParts::MainWindow*>(parentWidget)!=0; // notify the part that this is our internal widget setWidget(m_widget); // create our actions //KStdAction::open(this, SLOT(fileOpen()), actionCollection()); //KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection()); //KStdAction::save(this, SLOT(save()), actionCollection()); setXMLFile("kdiff3_part.rc"); // we are read-write by default setReadWrite(true); // we are not modified since we haven't done anything yet setModified(false); }
void KYSession::createInstance() { if (!me) { me = new KYSession(); setInstance(me); } }
void RenderScene::initialize(int argc, char**argv){ //set global RenderScene variable to this instance setInstance(); //setup glut environment glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowPosition(100, 100); glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); glutCreateWindow(windowTitle.c_str()); glutDisplayFunc(displayWrapper); glClearColor(1.0, 0.0, 0.0, 1.0); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glutIdleFunc(runWrapper); glutPassiveMotionFunc(mouseCallback); glutMainLoop(); }
EditorChooserPart::EditorChooserPart(QObject *parent, const char *name, const QStringList &) : KDevPlugin(&data, parent, name ? name : "EditorChooserPart") { setInstance(EditorChooserFactory::instance()); connect(core(), SIGNAL(configWidget(KDialogBase*)), this, SLOT(configWidget(KDialogBase*))); }
// Sync mesh update with changes on other processors void Foam::polyMesh::syncUpdateMesh() { // Update zones. Since boundary depends on zones, they need to be // updated first. HJ, 20/May/2014 pointZones_.updateMesh(); faceZones_.updateMesh(); cellZones_.updateMesh(); // Update boundaryMesh (note that patches themselves already ok) boundary_.updateMesh(); // Clear out parallel data. HJ, 27/Nov/2009 deleteDemandDrivenData(globalMeshDataPtr_); setInstance(time().timeName()); // Reset valid directions (could change by faces put into empty patches) geometricD_ = Vector<label>::zero; solutionD_ = Vector<label>::zero; // Update all function objects // Moved from fvMesh.C in 1.6.x merge. HJ, 29/Aug/2010 // Instantiate a dummy mapPolyMesh autoPtr<mapPolyMesh> mapPtr(new mapPolyMesh(*this)); meshObjectBase::allUpdateTopology<polyMesh>(*this, mapPtr()); }
RKDummyPart::RKDummyPart (QObject *parent, QWidget *widget) : KParts::Part (parent) { RK_TRACE (MISC); setWidget (widget); KInstance* instance = new KInstance ("rkward"); setInstance (instance); }
PluginPart::PluginPart(QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name, const QStringList &args) : KParts::ReadOnlyPart(parent, name), _widget(0), _args(args), _destructed(0L) { setInstance(PluginFactory::instance()); kdDebug(1432) << "PluginPart::PluginPart" << endl; // we have to keep the class name of KParts::PluginBrowserExtension // to let khtml find it _extension = static_cast< PluginBrowserExtension * >(new KParts::BrowserExtension(this)); _liveconnect = new PluginLiveConnectExtension(this); // Only create this if we have no parent since the parent part is // responsible for "Save As" then if(!parent || !parent->inherits("Part")) { new KAction(i18n("&Save As..."), CTRL + Key_S, this, SLOT(saveAs()), actionCollection(), "saveDocument"); setXMLFile("nspluginpart.rc"); } // create _loader = NSPluginLoader::instance(); _callback = new NSPluginCallback(this); // create a canvas to insert our widget _canvas = new PluginCanvasWidget(parentWidget, widgetName); //_canvas->setFocusPolicy( QWidget::ClickFocus ); _canvas->setFocusPolicy(QWidget::WheelFocus); _canvas->setBackgroundMode(QWidget::NoBackground); setWidget(_canvas); _canvas->show(); QObject::connect(_canvas, SIGNAL(resized(int, int)), this, SLOT(pluginResized(int, int))); }
void ViewCluster::setSolution(CCP::Solution * sol){ if (sol == 0){ setInstance(_instance); return; } CCP::Point * tmpCenter = 0; _sol = sol; scene()->clear(); qreal ellipseSize = (qMin(_instanceSize.width(), _instanceSize.height())/(_instance->numPoints()*4)); this->fitInView(scene()->sceneRect(), Qt::KeepAspectRatio); for (unsigned short i = 0; i < _instance->numCenters(); i++){ tmpCenter = _sol->centerOfCluster(i); scene()->addEllipse(tmpCenter->position().x() - ellipseSize*0.5, tmpCenter->position().y() - ellipseSize*0.5, ellipseSize, ellipseSize, QPen(QBrush(Qt::blue), 2)); for (unsigned short k = 0; k < _sol->cluster(i)->numPoints(); ++k){ scene()->addEllipse(_sol->cluster(i)->getPoint(k)->position().x() - ellipseSize*0.35 , _sol->cluster(i)->getPoint(k)->position().y() - ellipseSize*0.35 , ellipseSize*0.7, ellipseSize*0.7, QPen(QBrush(Qt::black), 0)); scene()->addLine(tmpCenter->position().x() , tmpCenter->position().y() , _sol->cluster(i)->getPoint(k)->position().x() , _sol->cluster(i)->getPoint(k)->position().y() ); } } }
KopeteRichTextEditPart::KopeteRichTextEditPart( QWidget *parent, const char *name, int capabilities ) : KParts::ReadOnlyPart( parent, name ? name : "rich_text_part" ), m_capabilities( capabilities ), m_richTextEnabled( true ) { // we need an instance setInstance( KopeteRichTextEditPartFactory::instance() ); editor = new KopeteTextEdit( parent ); editor->setReadOnly( false ); setWidget( editor ); m_richTextAvailable = ( m_capabilities & Kopete::Protocol::RichFormatting || m_capabilities & Kopete::Protocol::Alignment || m_capabilities & Kopete::Protocol::RichFont || m_capabilities & Kopete::Protocol::RichColor ); createActions(); setXMLFile( "kopeterichtexteditpartfull.rc" ); enableRichText->setEnabled( m_richTextAvailable ); enableRichText->setChecked( m_richTextAvailable ); slotSetRichTextEnabled( m_richTextAvailable ); //Set colors, font readConfig(); }
void GlutFramework::startFramework( int argc, char *argv[], std::string title, int width, int height, int posx, int posy, double fps) { // Sets the instance to this, used in the callback wrapper functions setInstance(); this->frameTime = 1.0 / fps * 1000.0; // Initialize GLUT glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutInitWindowSize(width, height); glutInitWindowPosition(0, 100); this->window = glutCreateWindow(title.c_str()); init(); // Initialize // Function callbacks with wrapper functions glutDisplayFunc(displayWrapper); glutReshapeFunc(reshapeWrapper); glutIdleFunc(runWrapper); glutMouseFunc(mouseButtonPressWrapper); glutMotionFunc(mouseMoveWrapper); glutKeyboardFunc(keyboardDownWrapper); glutKeyboardUpFunc(keyboardUpWrapper); glutSpecialFunc(specialKeyboardDownWrapper); glutSpecialUpFunc(specialKeyboardUpWrapper); glutMainLoop(); }
Kaboodle::Player::Player(QWidget *widgetParent, const char *widgetName, QObject *parent, const char *name) : KMediaPlayer::Player(widgetParent, widgetName, parent, name) , engine(new Engine(this)) , widget(new View(widgetParent, widgetName, this)) , uncompleted(true) , embedded(false) { setInstance(KaboodleFactory::instance()); connect(&ticker, SIGNAL(timeout()), SLOT(tickerTimeout())); ticker.start(500); setState(Empty); playAction = new KAction(i18n("&Play"), 0, this, SLOT(play()), actionCollection(), "play"); pauseAction = new KAction(i18n("&Pause"), 0, this, SLOT(pause()), actionCollection(), "pause"); stopAction = new KAction(i18n("&Stop"), 0, this, SLOT(stop()), actionCollection(), "stop"); loopAction = new KToggleAction(i18n("&Looping"), 0, this, SLOT(loop()), actionCollection(), "loop"); stopAction->setEnabled(false); playAction->setEnabled(false); pauseAction->setEnabled(false); connect(this, SIGNAL(loopingChanged(bool)), loopAction, SLOT(setChecked(bool))); KParts::Part::setWidget(widget); setXMLFile("kaboodlepartui.rc"); extension = new BrowserExtension(this); extension->setURLDropHandlingEnabled(true); }
AntProjectPart::AntProjectPart(QObject *parent, const char *name, const QStringList &) : KDevBuildTool(&data, parent, name ? name : "AntProjectPart") { setInstance(AntProjectFactory::instance()); setXMLFile("kdevantproject.rc"); m_buildProjectAction = new KAction(i18n("&Build Project"), "make_kdevelop", Key_F8, this, SLOT(slotBuild()), actionCollection(), "build_build" ); m_buildProjectAction->setToolTip(i18n("Build project")); m_buildProjectAction->setWhatsThis(i18n("<b>Build project</b><p>Executes <b>ant dist</b> command to build the project.")); KActionMenu *menu = new KActionMenu(i18n("Build &Target"), actionCollection(), "build_target" ); menu->setToolTip(i18n("Build target")); menu->setWhatsThis(i18n("<b>Build target</b><p>Executes <b>ant target_name</b> command to build the specified target.")); m_targetMenu = menu->popupMenu(); connect(m_targetMenu, SIGNAL(activated(int)), this, SLOT(slotTargetMenuActivated(int))); connect(core(), SIGNAL(projectConfigWidget(KDialogBase*)), this, SLOT(projectConfigWidget(KDialogBase*))); connect(core(), SIGNAL(contextMenu(QPopupMenu *, const Context *)), this, SLOT(contextMenu(QPopupMenu *, const Context *))); m_antOptionsWidget = 0; }
ReplacePart::ReplacePart(QObject *parent, const char *name, const QStringList& ) : KDevPlugin( &data, parent, name ? name : "ReplacePart" ) { setInstance(ReplaceFactory::instance()); setXMLFile("kdevpart_replace.rc"); m_widget = new ReplaceWidget(this); m_widget->setIcon( SmallIcon("filefind") ); m_widget->setCaption(i18n("Replace")); QWhatsThis::add (m_widget, i18n("<b>Replace</b><p>" "This window shows a preview of a string replace " "operation. Uncheck a line to exclude that replacement. " "Uncheck a file to exclude the whole file from the " "operation. " "Clicking on a line in the list will automatically " "open the corresponding source file and set the " "cursor to the line with the match." )); mainWindow()->embedOutputView( m_widget, i18n("Replace"), i18n("Project wide string replacement") ); mainWindow()->setViewAvailable( m_widget, false ); KAction * action = new KAction(i18n("Find-Select-Replace..."), 0, CTRL+SHIFT+Key_R, this, SLOT(slotReplace()), actionCollection(), "edit_replace_across"); action->setToolTip( i18n("Project wide string replacement") ); action->setWhatsThis( i18n("<b>Find-Select-Replace</b><p>" "Opens the project wide string replacement dialog. There you " "can enter a string or a regular expression which is then " "searched for within all files in the locations " "you specify. Matches will be displayed in the <b>Replace</b> window, you " "can replace them with the specified string, exclude them from replace operation or cancel the whole replace.") ); connect( core(), SIGNAL(contextMenu(QPopupMenu *, const Context *)), this, SLOT(contextMenu(QPopupMenu *, const Context *)) ); }
MakeViewPart::MakeViewPart(QObject *parent, const char *name, const QStringList &) : KDevMakeFrontend(&data, parent, name) { setInstance(MakeViewFactory::instance()); setXMLFile("kdevmakeview.rc"); m_dcop = new KDevMakeFrontendIface(this); m_widget = new MakeWidget(this); m_widget->setIcon( SmallIcon("exec") ); m_widget->setCaption(i18n("Messages Output")); QWhatsThis::add(m_widget, i18n("<b>Messages output</b><p>" "The messages window shows the output of the compiler and " "used build tools like make, ant, uic, dcopidl etc. " "For compiler error messages, click on the error message. " "This will automatically open the source file and set the " "cursor to the line that caused the compiler error/warning.")); mainWindow()->embedOutputView(m_widget, i18n("Messages"), i18n("Compiler output messages")); KAction *action; action = new KAction( i18n("&Next Error"), Key_F4, m_widget, SLOT(nextError()), actionCollection(), "view_next_error"); action->setToolTip( i18n("Go to the next error") ); action->setWhatsThis(i18n("<b>Next error</b><p>Switches to the file and line where the next error was reported from.")); action = new KAction( i18n("&Previous Error"), SHIFT+Key_F4, m_widget, SLOT(prevError()), actionCollection(), "view_previous_error"); action->setToolTip( i18n("Go to the previous error") ); action->setWhatsThis(i18n("<b>Previous error</b><p>Switches to the file and line where the previous error was reported from.")); connect( core(), SIGNAL(stopButtonClicked(KDevPlugin*)), this, SLOT(slotStopButtonClicked(KDevPlugin*)) ); }
SocketListener::SocketListener( String p_name ) : protocol( logger ) { name = p_name; lastConnectionId = 0; setInstance( p_name ); attachLogger(); }
CEventQueue::~CEventQueue() { delete m_buffer; ARCH->setSignalHandler(CArch::kINTERRUPT, NULL, NULL); ARCH->setSignalHandler(CArch::kTERMINATE, NULL, NULL); ARCH->closeMutex(m_mutex); setInstance(NULL); }
CEventQueue::CEventQueue() : m_nextType(CEvent::kLast) { setInstance(this); m_mutex = ARCH->newMutex(); ARCH->setSignalHandler(CArch::kINTERRUPT, &interrupt, NULL); ARCH->setSignalHandler(CArch::kTERMINATE, &interrupt, NULL); m_buffer = new CSimpleEventQueueBuffer; }
extern "C" void Java_org_tof_player_VorbisDecoder_nativeClose(JNIEnv * env,jobject thiz) { VorbisDecoder * decoder=getInstance(env,thiz); if (decoder) { decoder->Close(); delete decoder; setInstance(env,thiz,0); } }
TestPlugin::TestPlugin(Kontact::Core *_core, const char *name, const QStringList &) : Kontact::Plugin(_core, _core, name) { setInstance(TestPluginFactory::instance()); insertNewAction(new KAction("Test", 0, this, SLOT(slotTestMenu()), actionCollection(), "edit_test")); setXMLFile("kptestplugin.rc"); }
QT_BEGIN_NAMESPACE QQmlAndroidActivity::QQmlAndroidActivity(QObject *parent) : QQmlAndroidContextWrapper(parent), m_window(new QQmlAndroidWindow(this)), m_contentView(0), m_optionsMenu(0), m_actionBar(0) { // TODO: multiple activities? setInstance(QtAndroid::androidActivity()); }
QgsCredentialDialog::QgsCredentialDialog( QWidget *parent, Qt::WFlags fl ) : QDialog( parent, fl ) { setupUi( this ); setInstance( this ); connect( this, SIGNAL( credentialsRequested( QString, QString *, QString *, QString, bool * ) ), this, SLOT( requestCredentials( QString, QString *, QString *, QString, bool * ) ), Qt::BlockingQueuedConnection ); }
KarmPlugin::KarmPlugin(Kontact::Core *core, const char *, const QStringList &) : Kontact::Plugin(core, core, "KArm") { setInstance(KarmPluginFactory::instance()); (void)dcopClient(); insertNewAction(new KAction(i18n("New Task"), "karm", CTRL + SHIFT + Key_W, this, SLOT(newTask()), actionCollection(), "new_task")); }
PerforcePart::PerforcePart( QObject *parent, const char *name, const QStringList & ) : KDevVersionControl( &data, parent, name ? name : "PerforcePart" ) { setInstance(PerforceFactory::instance()); setupActions(); connect( core(), SIGNAL(contextMenu(QPopupMenu *, const Context *)), this, SLOT(contextMenu(QPopupMenu *, const Context *)) ); }
UIChooserPart::UIChooserPart(QObject *parent, const char *name, const QStringList &) : KDevPlugin( &data, parent, name ? name : "UIChooserPart") { setInstance(UIChooserFactory::instance()); _configProxy = new ConfigWidgetProxy( core() ); _configProxy->createGlobalConfigPage( i18n("User Interface"), UICHOOSERSETTINGSPAGE, info()->icon() ); connect( _configProxy, SIGNAL(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int )), this, SLOT(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int )) ); }
KugarPart::KugarPart( QWidget *parentWidget, const char *widgetName, QObject* parent, const char* name, bool singleViewMode ) : KoDocument( parentWidget, widgetName, parent, name, singleViewMode ), m_templateOk( false ) { setInstance( KugarFactory::global(), false ); m_reportEngine = new Kugar::MReportEngine(); connect( m_reportEngine, SIGNAL( preferedTemplate( const QString & ) ), SLOT( slotPreferredTemplate( const QString & ) ) ); }
RKConsolePart::RKConsolePart (RKConsole *console) : KParts::Part (0) { RK_TRACE (APP); KInstance* instance = new KInstance ("rkward"); setInstance (instance); setWidget (console); setXMLFile ("rkconsolepart.rc"); }
void GlGlut::start(int *argc, char *argv[]) { setInstance(); // Init glut glutInit(argc, argv); glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH); glutInitWindowSize(screen_width, screen_height); glutCreateWindow(WINDOW_TITLE); // Register callbacks glutDisplayFunc(displayWrapper); glutKeyboardFunc(keyboardWrapper); glutMouseFunc(mouseClickWrapper); glutMotionFunc(mouseMotionWrapper); glutReshapeFunc(reshapeWrapper); // glew? #ifdef _WIN32 GLenum err = glewInit(); if (GLEW_OK != err) { cerr << "Fatal Error: " << glewGetErrorString(err) << endl; exit(1); } #endif // Turn on depth testing glEnable(GL_DEPTH_TEST); // Turn on culling glFrontFace(GL_CW); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); // Setup mesh = new Mesh(); mesh->read_obj_file("bunny.mesh"); mesh->rebuild_vertex_norms(); // Shaders Check_GPU_Status(); printf("Loading shader phong_directional...\n"); phong_dir = Setup_GLSL("phong_directional"); printf("Loading shader phong_point...\n"); phong_point = Setup_GLSL("phong_point"); printf("Loading shader checkerboard...\n"); checkerboard = Setup_GLSL("checkerboard"); printf("Loading shader wood...\n"); wood = Setup_GLSL("wood"); programObject = wood; // Start reshape(screen_width, screen_height); glutIdleFunc(idleWrapper); glutMainLoop(); }
/*----------------------------------------------------------------------------*/ static enum Result pinInterruptInit(void *object, const void *configBase) { const struct PinInterruptConfig * const config = configBase; assert(config); const struct Pin input = pinInit(config->pin); assert(pinValid(input)); /* Try to allocate a new channel */ struct PinInterrupt * const interrupt = object; const int channel = setInstance(interrupt); if (channel == -1) return E_BUSY; /* Configure the pin */ pinInput(input); pinSetPull(input, config->pull); interrupt->callback = 0; interrupt->channel = channel; interrupt->enabled = false; interrupt->event = config->event; interrupt->pin = input.data; const uint8_t index = interrupt->channel >> 2; const uint32_t mask = 1UL << interrupt->channel; /* Enable peripheral */ if (!sysClockStatus(CLK_PINT)) sysClockEnable(CLK_PINT); /* Select pin and port */ LPC_SYSCON->PINTSEL[index] = (LPC_SYSCON->PINTSEL[index] & ~PINTSEL_CHANNEL_MASK(channel)) | PINTSEL_CHANNEL(channel, input.data.port, input.data.offset); /* Configure interrupt as edge sensitive */ LPC_GPIO_INT->ISEL &= ~mask; /* Configure edge sensitivity options */ if (config->event == PIN_RISING || config->event == PIN_TOGGLE) LPC_GPIO_INT->SIENR = mask; if (config->event == PIN_FALLING || config->event == PIN_TOGGLE) LPC_GPIO_INT->SIENF = mask; #ifdef CONFIG_PM /* Interrupt will wake the controller from low-power modes */ LPC_SYSCON->STARTERP0 |= STARTERP0_PINT(interrupt->channel); #endif /* Configure interrupt priority, interrupt is disabled by default */ irqSetPriority(calcVector(interrupt->channel), config->priority); return E_OK; }
SocketServer::SocketServer( String p_name ) : SocketListener( p_name ) { name = p_name; continueConnecting = true; shutdownInProgress = false; listenThread = ( RFC_HND )NULL; SocketListener::setMsgType( Message::MsgType_Default ); setInstance( p_name ); attachLogger(); }