bool Plugin::init() { library.load(); if(!library.isLoaded()) { qCritical() << "Couldn't load library" << library.fileName() << ":" << library.errorString(); return false; } initFunction = (FRAKTALEXPLORER_INITPLUGIN_FUNCTION) library.resolve(FRAKTALEXPLORER_INITPLUGIN_NAME); if(!initFunction) { qCritical() << "Couldn't load the symbol" << FRAKTALEXPLORER_INITPLUGIN_NAME << "from" << library.fileName() << ":" << library.errorString(); return false; } int ret = initFunction(); if(!ret) { qDebug() << "Successful init plugin"; return true; } else { qCritical() << "Couldn't init plugin, return value" << ret; return false; } }
void ThreadPool::run() { if(isRunning) return; //Threads are already running. isRunning = true; for(int i = 0; i < count; i++) { threads.push_back(std::thread([&] (void) -> void { DBConnection dbc(dbWriteLock); dbc.open(DB_FILE); ServiceLocator sl; sl.setAsServiceLocator(); sl.setDBConnection(&dbc); initFunction(); while(true) { poolLock.wait(); if(!isRunning) break; int handle = this->popHandle(); sl.setClientSocketHandle(handle); runFunction(handle); } deinitFunction(); dbc.close(); })); } }
/// \brief Initiate the ultracopier event dispatcher and check if no other session is running EventDispatcher::EventDispatcher() { copyServer=new CopyListener(&optionDialog); connect(&localListener,SIGNAL(cli(QStringList,bool,bool)),&cliParser,SLOT(cli(QStringList,bool,bool)),Qt::QueuedConnection); connect(themes, SIGNAL(newThemeOptions(QString,QWidget*,bool,bool)), &optionDialog, SLOT(newThemeOptions(QString,QWidget*,bool,bool))); connect(&cliParser, SIGNAL(newCopy(QStringList)), copyServer, SLOT(newCopy(QStringList))); connect(&cliParser, SIGNAL(newCopy(QStringList,QString)), copyServer, SLOT(newCopy(QStringList,QString))); connect(&cliParser, SIGNAL(newMove(QStringList)), copyServer, SLOT(newMove(QStringList))); connect(&cliParser, SIGNAL(newMove(QStringList,QString)), copyServer, SLOT(newMove(QStringList,QString))); copyMoveEventIdIndex=0; backgroundIcon=NULL; stopIt=false; sessionloader=new SessionLoader(&optionDialog); copyEngineList=new CopyEngineManager(&optionDialog); core=new Core(copyEngineList); qRegisterMetaType<CatchState>("CatchState"); qRegisterMetaType<ListeningState>("ListeningState"); qRegisterMetaType<QList<QUrl> >("QList<QUrl>"); qRegisterMetaType<QList<ProgressionItem> >("QList<ProgressionItem>"); qRegisterMetaType<QList<returnActionOnCopyList> >("QList<returnActionOnCopyList>"); ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); //show the ultracopier information ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Information,QString("ULTRACOPIER_VERSION: ")+ULTRACOPIER_VERSION); ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Information,QString("Qt version: %1 (%2)").arg(qVersion()).arg(QT_VERSION)); ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Information,QString("ULTRACOPIER_PLATFORM_NAME: ")+ULTRACOPIER_PLATFORM_NAME); ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Information,QString("Application path: %1 (%2)").arg(QCoreApplication::applicationFilePath()).arg(QCoreApplication::applicationPid())); ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Information,COMPILERINFO); ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Information,QString("Local socket: ")+ExtraSocket::pathSocket(ULTRACOPIER_SOCKETNAME)); //To lunch some initialization after QApplication::exec() to quit eventually lunchInitFunction.setInterval(0); lunchInitFunction.setSingleShot(true); connect(&lunchInitFunction,SIGNAL(timeout()),this,SLOT(initFunction()),Qt::QueuedConnection); lunchInitFunction.start(); //add the options to use QList<QPair<QString, QVariant> > KeysList; //add the options hidden, will not show in options pannel KeysList.clear(); KeysList.append(qMakePair(QString("Last_version_used"),QVariant("na"))); KeysList.append(qMakePair(QString("ActionOnManualOpen"),QVariant(1))); KeysList.append(qMakePair(QString("GroupWindowWhen"),QVariant(0))); options->addOptionGroup("Ultracopier",KeysList); if(options->getOptionValue("Ultracopier","Last_version_used")!=QVariant("na") && options->getOptionValue("Ultracopier","Last_version_used")!=QVariant(ULTRACOPIER_VERSION)) { //then ultracopier have been updated } options->setOptionValue("Ultracopier","Last_version_used",QVariant(ULTRACOPIER_VERSION)); int a=options->getOptionValue("Ultracopier","ActionOnManualOpen").toInt(); if(a<0 || a>2) options->setOptionValue("Ultracopier","ActionOnManualOpen",QVariant(1)); a=options->getOptionValue("Ultracopier","GroupWindowWhen").toInt(); if(a<0 || a>5) options->setOptionValue("Ultracopier","GroupWindowWhen",QVariant(0)); KeysList.clear(); KeysList.append(qMakePair(QString("List"),QVariant(QStringList() << "Ultracopier-0.3"))); options->addOptionGroup("CopyEngine",KeysList); connect(&cliParser, SIGNAL(newTransferList(QString,QString,QString)),core, SLOT(newTransferList(QString,QString,QString))); }
/** * Create the output workspace group. * @param baseName :: The base name for the output workspace. Suffix "Workspace" * will be added to it. * @param function :: A function to calculate the values. Must be of the * MultiDomainFunction type. * @param domain :: Domain created earlier with this creator (unused) * @param values :: Values created earlier with this creator (unused) * @param outputWorkspacePropertyName :: Name for the property to hold the * output workspace. If * empty the property won't be created. * @return A shared pointer to the created workspace. */ boost::shared_ptr<API::Workspace> MultiDomainCreator::createOutputWorkspace( const std::string &baseName, API::IFunction_sptr function, boost::shared_ptr<API::FunctionDomain> domain, boost::shared_ptr<API::FunctionValues> values, const std::string &outputWorkspacePropertyName) { UNUSED_ARG(domain); UNUSED_ARG(values); auto mdFunction = boost::dynamic_pointer_cast<API::MultiDomainFunction>(function); if (!mdFunction) { throw std::runtime_error("A MultiDomainFunction is expected to be used " "with MultiDomainCreator."); } // split the function into independent parts std::vector<API::IFunction_sptr> functions = mdFunction->createEquivalentFunctions(); // there must be as many parts as there are domains if (functions.size() != m_creators.size()) { throw std::runtime_error("Number of functions and domains don't match"); } API::WorkspaceGroup_sptr outWS = API::WorkspaceGroup_sptr(new API::WorkspaceGroup()); for (size_t i = 0; i < functions.size(); ++i) { std::string localName = baseName + "Workspace_" + boost::lexical_cast<std::string>(i); auto fun = functions[i]; auto creator = m_creators[i]; boost::shared_ptr<API::FunctionDomain> localDomain; boost::shared_ptr<API::FunctionValues> localValues; fun->setUpForFit(); creator->createDomain(localDomain, localValues); creator->initFunction(fun); auto ws = creator->createOutputWorkspace(localName, fun, localDomain, localValues, ""); API::AnalysisDataService::Instance().addOrReplace(localName, ws); outWS->addWorkspace(ws); } if (!outputWorkspacePropertyName.empty()) { declareProperty( new API::WorkspaceProperty<API::WorkspaceGroup>( outputWorkspacePropertyName, "", Kernel::Direction::Output), "Name of the output Workspace holding resulting simulated spectrum"); m_manager->setPropertyValue(outputWorkspacePropertyName, baseName + "Workspaces"); m_manager->setProperty(outputWorkspacePropertyName, outWS); } return outWS; }
int LayerFunctionProbe::initLayerFunctionProbe(const char * probeName, HyPerCol * hc) { int status = initStatsProbe(probeName, hc); if (status == PV_SUCCESS) { initFunction(); if (function==NULL) { fprintf(stderr, "%s \"%s\" error: rank %d unable to construct LayerFunction.\n", getParent()->parameters()->groupKeywordFromName(probeName), probeName, getParent()->columnId()); status = PV_FAILURE; exit(EXIT_FAILURE); } } return status; }
void Module::RunInitFunctions() { if(_initArrayCount > 0) { void (*initFunction)(); for(size_t i = 0; i < _initArrayCount; i ++) { if(_initArray[i] == 0 || _initArray[i] == UINT32_MAX) continue; initFunction = reinterpret_cast<void (*)()>(_initArray[i]); initFunction(); } } }
tChyba initFrames() { //globalni ht int ret = htInit( &ptrhtGlobal ); if( ret != S_BEZ_CHYB ){ return S_INTERNI_CHYBA; } //init table ret = initTable(); if( ret != S_BEZ_CHYB ){ return S_INTERNI_CHYBA; } //init func ret = initFunction(); if( ret != S_BEZ_CHYB ){ return S_INTERNI_CHYBA; } //inicializace zasobniku lokalnich ramcu a lokalniho ramce return initStack(); }
void QgsEditFormConfig::writeXml( QDomNode& node ) const { QDomDocument doc( node.ownerDocument() ); QDomElement efField = doc.createElement( "editform" ); QDomText efText = doc.createTextNode( QgsProject::instance()->writePath( uiForm() ) ); efField.appendChild( efText ); node.appendChild( efField ); QDomElement efiField = doc.createElement( "editforminit" ); if ( !initFunction().isEmpty() ) efiField.appendChild( doc.createTextNode( initFunction() ) ); node.appendChild( efiField ); QDomElement eficsField = doc.createElement( "editforminitcodesource" ); eficsField.appendChild( doc.createTextNode( QString::number( initCodeSource() ) ) ); node.appendChild( eficsField ); QDomElement efifpField = doc.createElement( "editforminitfilepath" ); efifpField.appendChild( doc.createTextNode( QgsProject::instance()->writePath( initFilePath() ) ) ); node.appendChild( efifpField ); QDomElement eficField = doc.createElement( "editforminitcode" ); eficField.appendChild( doc.createCDATASection( initCode() ) ); node.appendChild( eficField ); QDomElement fFSuppElem = doc.createElement( "featformsuppress" ); QDomText fFSuppText = doc.createTextNode( QString::number( suppress() ) ); fFSuppElem.appendChild( fFSuppText ); node.appendChild( fFSuppElem ); // tab display QDomElement editorLayoutElem = doc.createElement( "editorlayout" ); switch ( layout() ) { case QgsEditFormConfig::UiFileLayout: editorLayoutElem.appendChild( doc.createTextNode( "uifilelayout" ) ); break; case QgsEditFormConfig::TabLayout: editorLayoutElem.appendChild( doc.createTextNode( "tablayout" ) ); break; case QgsEditFormConfig::GeneratedLayout: default: editorLayoutElem.appendChild( doc.createTextNode( "generatedlayout" ) ); break; } node.appendChild( editorLayoutElem ); // tabs and groups of edit form if ( tabs().size() > 0 ) { QDomElement tabsElem = doc.createElement( "attributeEditorForm" ); for ( QList< QgsAttributeEditorElement* >::const_iterator it = mAttributeEditorElements.constBegin(); it != mAttributeEditorElements.constEnd(); ++it ) { QDomElement attributeEditorWidgetElem = ( *it )->toDomElement( doc ); tabsElem.appendChild( attributeEditorWidgetElem ); } node.appendChild( tabsElem ); } //// TODO: MAKE THIS MORE GENERIC, SO INDIVIDUALL WIDGETS CAN NOT ONLY SAVE STRINGS /// SEE QgsEditorWidgetFactory::writeConfig QDomElement widgetsElem = doc.createElement( "widgets" ); QMap<QString, QgsEditorWidgetConfig >::ConstIterator configIt( mWidgetConfigs.constBegin() ); while ( configIt != mWidgetConfigs.constEnd() ) { if ( mFields.indexFromName( configIt.key() ) == -1 ) { QDomElement widgetElem = doc.createElement( "widget" ); widgetElem.setAttribute( "name", configIt.key() ); QDomElement configElem = doc.createElement( "config" ); widgetElem.appendChild( configElem ); QgsEditorWidgetConfig::ConstIterator cfgIt( configIt.value().constBegin() ); while ( cfgIt != configIt.value().constEnd() ) { QDomElement optionElem = doc.createElement( "option" ); optionElem.setAttribute( "key", cfgIt.key() ); optionElem.setAttribute( "value", cfgIt.value().toString() ); configElem.appendChild( optionElem ); ++cfgIt; } widgetsElem.appendChild( widgetElem ); } ++configIt; } node.appendChild( widgetsElem ); //// END TODO }
void Epoll::run() { initFunction(); wait(); }
/** * Group: * C * * Function: * Gua_Status System_LoadFunctionWrapper(void *nspace, Gua_Short argc, Gua_Object *argv, Gua_Object *object, Gua_String error) * * Description: * Load function wrapper. * * Arguments: * nspace, a pointer to a structure Gua_Namespace. Must do a cast before use it; * argc, the number of arguments to pass to the function; * argv, an array containing the arguments to the function; * argv[0] is the function name; * object, a structure containing the return object of the function; * error, a pointer to the error message. * * Results: * Loads a system dynamic library. */ Gua_Status System_LoadFunctionWrapper(void *nspace, Gua_Short argc, Gua_Object *argv, Gua_Object *object, Gua_String error) { Gua_Namespace *top; Gua_Short status; Gua_String p; Gua_String q; Gua_String name; Gua_String prefix; Gua_String prefixToCamelCase; Gua_Integer removeLibPrefix; Gua_String functionName; top = (Gua_Namespace *)nspace; while (top->previous) { top = (Gua_Namespace *)top->previous; } #ifdef _WINDOWS_ HINSTANCE library; Gua_Status __cdecl (*initFunction) (void *nspace, int argc, char *argv[], char **env, Gua_String error); #else void *library; Gua_Status (*initFunction) (void *nspace, int argc, char *argv[], char **env, Gua_String error); #endif Gua_String errMessage; if (argc == 0) { errMessage = (Gua_String) Gua_Alloc(sizeof(char) * MAX_ERROR_MSG_SIZE + 1); sprintf(errMessage, "%s\n", "no function specified"); strcat(error, errMessage); Gua_Free(errMessage); return GUA_ERROR; } if (argc != 2) { errMessage = (Gua_String) Gua_Alloc(sizeof(char) * MAX_ERROR_MSG_SIZE + 1); sprintf(errMessage, "%s %-.20s...\n", "wrong number of arguments for function", Gua_ObjectToString(argv[0])); strcat(error, errMessage); Gua_Free(errMessage); return GUA_ERROR; } if (Gua_ObjectType(argv[1]) != OBJECT_TYPE_STRING) { errMessage = (Gua_String) Gua_Alloc(sizeof(char) * MAX_ERROR_MSG_SIZE + 1); sprintf(errMessage, "%s %-.20s...\n", "illegal argument 1 for function", Gua_ObjectToString(argv[0])); strcat(error, errMessage); Gua_Free(errMessage); return GUA_ERROR; } status = GUA_OK; prefix = (char *)Gua_Alloc(sizeof(char) * EXPRESSION_SIZE + 1); memset(prefix, '\0', EXPRESSION_SIZE + 1); prefixToCamelCase = (char *)Gua_Alloc(sizeof(char) * EXPRESSION_SIZE + 1); memset(prefixToCamelCase, '\0', EXPRESSION_SIZE + 1); functionName = (char *)Gua_Alloc(sizeof(char) * EXPRESSION_SIZE + 1); memset(functionName, '\0', EXPRESSION_SIZE + 1); Fs_Name(Gua_ObjectToString(argv[1]), &name); p = name; q = prefix; while (Gua_IsSpace(*p)) { p++; } removeLibPrefix = 1; while (*p) { /* Skip the "lib" prefix. */ if (removeLibPrefix) { if (*p == 'l') { p++; if (*p == 'i') { p++; if (*p == 'b') { p++; } } } else { removeLibPrefix = 0; } } *q = *p; p++; q++; if ((*p == '.') || (*p == '-') || Gua_IsNumber(*p)) { break; } } *q = '\0'; /* Converts the library name do CamelCase. */ System_ToCamelCase(prefixToCamelCase, prefix); sprintf(functionName, "%s_Init", prefixToCamelCase); #ifdef _WINDOWS_ library = LoadLibrary(TEXT(Gua_ObjectToString(argv[1]))); if (library != NULL) { initFunction = (Gua_Status __cdecl (*) (void *nspace, int argc, char *argv[], char **env, Gua_String error)) GetProcAddress(library, functionName); if (initFunction != NULL) { status = initFunction(top, appArgc, appArgv, appEnv, error); } else { errMessage = (Gua_String) Gua_Alloc(sizeof(char) * MAX_ERROR_MSG_SIZE + 1); sprintf(errMessage, "%s \"%s\"\n", "could not load function", functionName); strcat(error, errMessage); Gua_Free(errMessage); status = GUA_ERROR; } /* We can not call FreeLibrary(library) as this would remove the functions * from memory and the interpreter could not call them when needed. So * we add the library handle to a list and free it later when the application * exits. */ System_AddListItem(&libraryList, library); } else { errMessage = (Gua_String) Gua_Alloc(sizeof(char) * MAX_ERROR_MSG_SIZE + 1); sprintf(errMessage, "%s \"%s\"\n", "could not loading library", Gua_ObjectToString(argv[1])); strcat(error, errMessage); Gua_Free(errMessage); status = GUA_ERROR; } #else library = dlopen(Gua_ObjectToString(argv[1]), RTLD_NOW | RTLD_GLOBAL); if (library != NULL) { initFunction = (Gua_Status (*) (void *nspace, int argc, char *argv[], char **env, Gua_String error)) dlsym(library, functionName); if (initFunction != NULL) { status = initFunction(top, appArgc, appArgv, appEnv, error); } else { errMessage = (Gua_String) Gua_Alloc(sizeof(char) * MAX_ERROR_MSG_SIZE + 1); sprintf(errMessage, "%s", dlerror()); strcat(error, errMessage); Gua_Free(errMessage); status = GUA_ERROR; } /* We can not call dlclose(library) as this would remove the functions * from memory and the interpreter could not call them when needed. So * we add the library handle to a list and free it later when the application * exits. */ System_AddListItem(&libraryList, library); } else { errMessage = (Gua_String) Gua_Alloc(sizeof(char) * MAX_ERROR_MSG_SIZE + 1); sprintf(errMessage, "%s", dlerror()); strcat(error, errMessage); Gua_Free(errMessage); status = GUA_ERROR; } #endif Gua_Free(name); Gua_Free(prefix); Gua_Free(prefixToCamelCase); Gua_Free(functionName); return status; }