本文整理汇总了C++中setInstance函数的典型用法代码示例。如果您正苦于以下问题:C++ setInstance函数的具体用法?C++ setInstance怎么用?C++ setInstance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setInstance函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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();
}
示例2: KYSession
void KYSession::createInstance()
{
if (!me) {
me = new KYSession();
setInstance(me);
}
}
示例3: setInstance
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();
}
示例4: KDevPlugin
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*)));
}
示例5: deleteDemandDrivenData
// 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());
}
示例6: RK_TRACE
RKDummyPart::RKDummyPart (QObject *parent, QWidget *widget) : KParts::Part (parent) {
RK_TRACE (MISC);
setWidget (widget);
KInstance* instance = new KInstance ("rkward");
setInstance (instance);
}
示例7: _widget
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)));
}
示例8: setInstance
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()
);
}
}
}
示例9: m_capabilities
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();
}
示例10: setInstance
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();
}
示例11: engine
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);
}
示例12: KDevBuildTool
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;
}
示例13: KDevMakeFrontend
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*)) );
}
示例14: protocol
SocketListener::SocketListener( String p_name )
: protocol( logger ) {
name = p_name;
lastConnectionId = 0;
setInstance( p_name );
attachLogger();
}
示例15: setInstance
CEventQueue::~CEventQueue()
{
delete m_buffer;
ARCH->setSignalHandler(CArch::kINTERRUPT, NULL, NULL);
ARCH->setSignalHandler(CArch::kTERMINATE, NULL, NULL);
ARCH->closeMutex(m_mutex);
setInstance(NULL);
}