/**
 * This method pushes a module onto the module stack.
 * The provided module becomes the new active module automatically.
 * The existing active module is paused, and the provided
 * module is told to Start.
 *
 * @param module the module that will be the new active module.
 */
void ModuleManager::push( ModulePtr module )
{
	if (currentModule())
		currentModule()->onPause();

	MF_ASSERT( module );

	modules_.push( module );

	module->onStart();
}
/**
 * This method removes all modules left on the module stack.
 * This allows for a quick graceful exit from the application.
 */
void ModuleManager::popAll()
{
	while ( currentModule() )
	{
		//NOTE - don't call our own pop method,
		//simply because we don't want to resume
		//any of the modules further down the stack
		//when they become the next "current module"
		currentModule()->onStop();
		modules_.pop();
	}
}
/**
 * This method removes the current module from the module stack.
 * The current module is told to Stop.
 * The new active module ( if there is one ) is told to resume,
 * where previously it was paused during an earlier push() operation.
 */
void ModuleManager::pop()
{
	int exitCode;

	ModulePtr current = currentModule();

	if ( current )
	{
		exitCode = current->onStop();
		modules_.pop();
	}

	if ( currentModule() )
		currentModule()->onResume( exitCode );
}
Esempio n. 4
0
static Module * topLevelModule(Evaluator * ex, Node * in) {
  Module * m = currentModule(ex, in);
  if (m != NULL) {
    Project * p = m->project();
    if (p == NULL) {
      diag::error(in->location()) << "Could not find top-level module.";
      return NULL;
    }
    return p->mainModule();
  }
  return NULL;
}
Esempio n. 5
0
// Avoid multiple fromUtf8(), copies and hashing of the module name.
// This is only called when metaTypeDataLock is locked.
static QHashedString moduleFromUtf8(const char *module)
{
    if (!module)
        return QHashedString();

    static const char *lastModule = 0;
    static QHashedString lastModuleStr;

    // Separate plugins may have different strings at the same address
    QHashedCStringRef currentModule(module, ::strlen(module));
    if ((lastModule != module) || (lastModuleStr.hash() != currentModule.hash())) {
        lastModuleStr = QString::fromUtf8(module);
        lastModuleStr.hash();
        lastModule = module;
    }

    return lastModuleStr;
}