/* private */ auto_ptr<Geometry> GeometryPrecisionReducer::fixPolygonalTopology(const geom::Geometry& geom ) { /** * If precision model was *not* changed, need to flip * geometry to targetPM, buffer in that model, then flip back */ auto_ptr<Geometry> tmp; auto_ptr<GeometryFactory> tmpFactory; const Geometry* geomToBuffer = &geom; if ( ! newFactory ) { tmpFactory = createFactory(*geom.getFactory(), targetPM); tmp.reset( tmpFactory->createGeometry(&geom) ); geomToBuffer = tmp.get(); } auto_ptr<Geometry> bufGeom ( geomToBuffer->buffer(0) ); if ( ! newFactory ) { // a slick way to copy the geometry with the original precision factory bufGeom.reset( geom.getFactory()->createGeometry(bufGeom.get()) ); } return bufGeom; }
// Response to all POST request // 3 requests are correct : // - /CreateFactory --> Receive Faust code / Compile Data / Send back JSON Interface // - /CreateInstance --> Receive factoryIndex / Create instance // - /DeleteFactory --> Receive factoryIndex / Delete factory int DSPServer::answerPost(MHD_Connection* connection, const char* url, const char* upload_data, size_t* upload_data_size, void** con_cls) { dsp_server_connection_info* info = (dsp_server_connection_info*)*con_cls; if (*upload_data_size != 0) { return info->postProcess(upload_data, upload_data_size); } else { if (strcmp(url, "/CreateFactory") == 0) { return createFactory(connection, info); } else if (strcmp(url, "/CrossCompileFactory") == 0) { return crossCompileFactory(connection, info); } else if (strcmp(url, "/GetFactoryFromSHAKey") == 0) { return getFactoryFromSHAKey(connection, info); } else if(strcmp(url, "/DeleteFactory") == 0) { return deleteFactory(connection, info); } else if (strcmp(url, "/CreateInstance") == 0) { return createInstance(connection, info); } else if (strcmp(url, "/DeleteInstance") == 0) { return deleteInstance(connection, info); } else if (strcmp(url, "/StartInstance") == 0) { return start(connection, info); } else if(strcmp(url, "/StopInstance") == 0) { return stop(connection, info); } else { return sendPage(connection, "", MHD_HTTP_BAD_REQUEST, "text/html"); } } }
int main(int argc, char* argv[]) { if (argc != 4) { printHelp(argv); return 1; } // QUADRATURE RULE if (strlen(argv[1]) > 1) { printHelp(argv); return 2; } QuadratureFactory* factory = createFactory(argv[1][0]); // FUNCTION TO BE USED/TESTED int functionIndex = atoi(argv[2]); if (functionIndex == 0) { printHelp(argv); return 3; } fptr func = chooseFunc(functionIndex); // INTEGRATION GRID IntegrationGrid grid = createGrid(argv[3]); //grid.print(); CompositeIntegrator integrator(func, factory, grid); printf("performing integration\n"); integrator.integrate(); printf("result of integrating function %d = %5.3lf\n", functionIndex, integrator.getResult()); return 0; }
JNIEXPORT void JNICALL Java_quickfix_ThreadedSocketInitiator_create ( JNIEnv *pEnv, jobject obj ) { QF_STACK_TRY JVM::set( pEnv ); JVMObject jobject( obj ); JavaLogFactory* pLogFactory = 0; try { pLogFactory = &createLogFactory( jobject ); } catch ( JVMException& ) {} FIX::Initiator* pInitiator = 0; try { if ( pLogFactory ) { pInitiator = new FIX::ThreadedSocketInitiator( createApplication( jobject ), createFactory( jobject ), getSettings( jobject ), *pLogFactory ); } else { pInitiator = new FIX::ThreadedSocketInitiator( createApplication( jobject ), createFactory( jobject ), getSettings( jobject )); } } catch( FIX::ConfigError& e ) { throwNew( "Lquickfix/ConfigError;", e.what() ); return; } jobject.setLong( "cppPointer", ( long ) pInitiator ); QF_STACK_CATCH }
void IndexDefinition::defineIndex(EnIndexKind enIxKind, TyFSType tyType, vector<uima::lowlevel::TyFSFeature> const & crKeyFeatures, vector<uima::lowlevel::IndexComparator::EnKeyFeatureComp> const & crComparators, IndexDefinition::TyIndexID const & crID, bool bIsPermanent) { assert(!iv_bIsCommitted); // if index does not yet exist if (! isValidIndexId(crID)) { // create comparator assert( crKeyFeatures.size() == crComparators.size() ); uima::lowlevel::IndexComparator * pComparator = new uima::lowlevel::IndexComparator(*this, tyType); assert( EXISTS(pComparator) ); size_t i; for (i=0; i<crKeyFeatures.size(); ++i) { pComparator->addKey(crKeyFeatures[i], crComparators[i]); } iv_vecComparators.push_back(pComparator); // create factory with the comparator internal::IndexFactory* pFactory = createFactory(enIxKind, tyType, pComparator); assert( pFactory != NULL ); // register factory for index ID UIMA_TPRINT("creating index"); assert( iv_mapFactories.find(crID) == iv_mapFactories.end() ); iv_mapFactories[crID] = pFactory; assert( iv_crTypeSystem.subsumes( pFactory->getType(), tyType ) ); assert( iv_mapIndexTypes.find(crID) == iv_mapIndexTypes.end() ); // register type for index ID iv_mapIndexTypes[crID] = tyType; // register if index is contains permanent FSs assert( iv_mapIsPermanentFlags.find(crID) == iv_mapIsPermanentFlags.end() ); iv_mapIsPermanentFlags[crID] = bIsPermanent; } else { // check if index is compatible with existing one UIMA_TPRINT(" An index with ID " << crID << " already exists, checking if it is compatible"); if (! isCompatibleIndexDefinition( enIxKind, tyType, crKeyFeatures, crComparators, crID, bIsPermanent) ) { UIMA_EXC_THROW_NEW(IncompatibleIndexDefinitionsException, UIMA_ERR_INCOMPATIBLE_INDEX_DEFINITIONS, ErrorMessage(UIMA_MSG_ID_EXC_INCOMPATIBLE_INDEX_DEFINITIONS, crID), UIMA_MSG_ID_EXCON_CREATING_INDEXES_FROM_CONFIG, ErrorInfo::recoverable); } } }
int main(void) { auto runtime_ = CommonAPI::Runtime::load(); std::shared_ptr<CommonAPI::Factory> factory = runtime_->createFactory(); const std::string serviceAddress_ = "local:commonapi.tests.TestPolymorphicInterface:commonapi.tests.TestPolymorphicInterface"; auto testPolymorphicInterfaceStub = std::make_shared<TestPolymorphicInterfaceStubDefaultImpl>(); bool success = factory->registerService(testPolymorphicInterfaceStub, serviceAddress_); assert(success); while(true) { } return 0; }
void Plugins::PluginManager::checkPluginEnabledStates() { // re-create all the member infos. m_pluginInfos.clear(); m_pluginInfosByType.clear(); m_factoriesByType.clear(); m_pluginInfos = findPlugins(); // reload all the plugins plus their enabled state if( m_pluginInfos.isEmpty() ) // try it a second time with syscoca handleNoPluginsFound(); QList<PluginFactory*> allFactories; // sort the plugin infos by type foreach( const KPluginInfo &pluginInfo, m_pluginInfos ) { Type type; if( pluginInfo.category() == QLatin1String("Storage") ) type = Storage; else if( pluginInfo.category() == QLatin1String("Collection") ) type = Collection; else if( pluginInfo.category() == QLatin1String("Service") ) type = Service; else if( pluginInfo.category() == QLatin1String("Importer") ) type = Importer; else { warning() << pluginInfo.pluginName() << " has unknown category"; continue; } m_pluginInfosByType[ type ] << pluginInfo; // create the factories and sort them by type PluginFactory *factory = createFactory( pluginInfo ); if( factory ) { m_factoriesByType[ type ] << factory; allFactories << factory; } }
std::shared_ptr<Factory> Runtime::createFactory(const std::string factoryName, const bool nullOnInvalidName) { return createFactory(std::shared_ptr<MainLoopContext>(NULL), factoryName, nullOnInvalidName); }
/** * @test Proxy Receives Just His Own Answers. * - start 2 proxies in own threads * - call test method in each proxy * - now each proxy should have received the answer to his own request */ TEST_F(MainLoopIndependenceTest, ProxyReceivesJustHisOwnAnswers) { std::shared_ptr<PingPongTestStub> stubThirdParty = std::make_shared<PingPongTestStub>(); auto runtime = CommonAPI::Runtime::load(); ASSERT_TRUE(runtime->getServicePublisher()->registerService(stubThirdParty, testAddress6, runtime->createFactory())); CommonAPI::CallStatus callStatusProxy1, callStatusProxy2; uint32_t inIntProxy1, outIntProxy1, inIntProxy2, outIntProxy2; std::string inStrProxy1, outStrProxy1, inStrProxy2, outStrProxy2; inIntProxy1 = 1; inIntProxy2 = 2; outIntProxy1 = outIntProxy2 = 0; std::thread mainLoopRunnerProxy1([&]() { threadCtx1_.mainLoop_->run(); }); std::thread mainLoopRunnerProxy2([&]() { threadCtx2_.mainLoop_->run(); }); mainLoopRunnerProxy1.detach(); mainLoopRunnerProxy2.detach(); while(!(threadCtx1_.proxyThirdParty_->isAvailable() && threadCtx2_.proxyThirdParty_->isAvailable())) { usleep(5000); } mainLoopThread1_ = std::thread([&]() { threadCtx1_.proxyThirdParty_->testPredefinedTypeMethod(inIntProxy1, inStrProxy1, callStatusProxy1, outIntProxy1, outStrProxy1); }); mainLoopThread2_ = std::thread([&]() { threadCtx2_.proxyThirdParty_->testPredefinedTypeMethod(inIntProxy2, inStrProxy2, callStatusProxy2, outIntProxy2, outStrProxy2); }); mainLoopThread1_.detach(); mainLoopThread2_.detach(); sleep(5); // now each proxy should have received the answer to his own request ASSERT_EQ(1, outIntProxy1); ASSERT_EQ(2, outIntProxy2); sleep(1); }