当前位置: 首页>>代码示例>>C++>>正文


C++ cast_to_fptr函数代码示例

本文整理汇总了C++中cast_to_fptr函数的典型用法代码示例。如果您正苦于以下问题:C++ cast_to_fptr函数的具体用法?C++ cast_to_fptr怎么用?C++ cast_to_fptr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cast_to_fptr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cast_to_fptr

QWidget *QgsAuthMethodRegistry::editWidget( const QString &authMethodKey, QWidget *parent )
{
  editFactoryFunction_t * editFactory =
    ( editFactoryFunction_t * ) cast_to_fptr( function( authMethodKey, "editWidget" ) );

  if ( !editFactory )
    return 0;

  return editFactory( parent );
}
开发者ID:dakcarto,项目名称:QGIS,代码行数:10,代码来源:qgsauthmethodregistry.cpp

示例2: cast_to_fptr

QWidget* QgsProviderRegistry::selectWidget( const QString & providerKey,
    QWidget * parent, Qt::WFlags fl )
{
  selectFactoryFunction_t * selectFactory =
    ( selectFactoryFunction_t * ) cast_to_fptr( function( providerKey, "selectWidget" ) );

  if ( !selectFactory )
    return 0;

  return selectFactory( parent, fl );
}
开发者ID:AnAvidDeveloper,项目名称:QGIS,代码行数:11,代码来源:qgsproviderregistry.cpp

示例3: cast_to_fptr

QWidget *QgsProviderRegistry::createSelectionWidget( const QString &providerKey,
    QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
{
  selectFactoryFunction_t *selectFactory =
    reinterpret_cast< selectFactoryFunction_t * >( cast_to_fptr( function( providerKey, "selectWidget" ) ) );

  if ( !selectFactory )
    return nullptr;

  return selectFactory( parent, fl, widgetMode );
}
开发者ID:CS-SI,项目名称:QGIS,代码行数:11,代码来源:qgsproviderregistry.cpp

示例4: library

/** Copied from QgsVectorLayer::setDataProvider
 *  TODO: Make it work in the generic environment
 *
 *  TODO: Is this class really the best place to put a data provider loader?
 *        It seems more sensible to provide the code in one place rather than
 *        in qgsrasterlayer, qgsvectorlayer, serversourceselect, etc.
 */
QgsDataProvider *QgsProviderRegistry::provider( QString const & providerKey, QString const & dataSource )
{
  // XXX should I check for and possibly delete any pre-existing providers?
  // XXX How often will that scenario occur?

  // load the plugin
  QString lib = library( providerKey );

#ifdef TESTPROVIDERLIB
  const char *cLib = lib.toUtf8();

  // test code to help debug provider loading problems
  //  void *handle = dlopen(cLib, RTLD_LAZY);
  void *handle = dlopen( cOgrLib, RTLD_LAZY | RTLD_GLOBAL );
  if ( !handle )
  {
    QgsLogger::warning( "Error in dlopen" );
  }
  else
  {
    QgsDebugMsg( "dlopen suceeded" );
    dlclose( handle );
  }

#endif
  // load the data provider
  QLibrary myLib( lib );

  QgsDebugMsg( "Library name is " + myLib.fileName() );
  if ( !myLib.load() )
  {
    QgsMessageLog::logMessage( QObject::tr( "Failed to load %1: %2" ).arg( lib ).arg( myLib.errorString() ) );
    return 0;
  }

  classFactoryFunction_t *classFactory = ( classFactoryFunction_t * ) cast_to_fptr( myLib.resolve( "classFactory" ) );
  if ( !classFactory )
  {
    QgsDebugMsg( QString( "Failed to load %1: no classFactory method" ).arg( lib ) );
    return 0;
  }

  QgsDataProvider *dataProvider = classFactory( &dataSource );
  if ( !dataProvider )
  {
    QgsMessageLog::logMessage( QObject::tr( "Unable to instantiate the data provider plugin %1" ).arg( lib ) );
    myLib.unload();
    return 0;
  }

  QgsDebugMsg( QString( "Instantiated the data provider plugin: %1" ).arg( dataProvider->name() ) );
  return dataProvider;
} // QgsProviderRegistry::setDataProvider
开发者ID:AnAvidDeveloper,项目名称:QGIS,代码行数:60,代码来源:qgsproviderregistry.cpp

示例5: registerGui_function

void QgsProviderRegistry::registerGuis( QWidget *parent )
{
  typedef void registerGui_function( QWidget * parent );

  foreach ( const QString &provider, providerList() )
  {
    registerGui_function *registerGui = ( registerGui_function * ) cast_to_fptr( function( provider, "registerGui" ) );

    if ( !registerGui )
      continue;

    registerGui( parent );
  }
开发者ID:AnAvidDeveloper,项目名称:QGIS,代码行数:13,代码来源:qgsproviderregistry.cpp

示例6: registerGui_function

void QgsProviderRegistry::registerGuis( QWidget *parent )
{
  typedef void registerGui_function( QWidget * parent );

  Q_FOREACH ( const QString &provider, providerList() )
  {
    registerGui_function *registerGui = reinterpret_cast< registerGui_function * >( cast_to_fptr( function( provider, "registerGui" ) ) );

    if ( !registerGui )
      continue;

    registerGui( parent );
  }
开发者ID:CS-SI,项目名称:QGIS,代码行数:13,代码来源:qgsproviderregistry.cpp

示例7: library

QgsAuthMethod *QgsAuthMethodRegistry::authMethod( const QString &authMethodKey )
{
  // load the plugin
  QString lib = library( authMethodKey );

#ifdef TESTAUTHMETHODLIB
  const char *cLib = lib.toUtf8();

  // test code to help debug auth method plugin loading problems
  //  void *handle = dlopen(cLib, RTLD_LAZY);
  void *handle = dlopen( cOgrLib, RTLD_LAZY | RTLD_GLOBAL );
  if ( !handle )
  {
    QgsLogger::warning( "Error in dlopen" );
  }
  else
  {
    QgsDebugMsg( "dlopen suceeded" );
    dlclose( handle );
  }

#endif
  // load the auth method
  QLibrary myLib( lib );

  QgsDebugMsg( "Auth method library name is " + myLib.fileName() );
  if ( !myLib.load() )
  {
    QgsMessageLog::logMessage( QObject::tr( "Failed to load %1: %2" ).arg( lib, myLib.errorString() ) );
    return 0;
  }

  classFactoryFunction_t *classFactory = ( classFactoryFunction_t * ) cast_to_fptr( myLib.resolve( "classFactory" ) );
  if ( !classFactory )
  {
    QgsDebugMsg( QString( "Failed to load %1: no classFactory method" ).arg( lib ) );
    return 0;
  }

  QgsAuthMethod *authMethod = classFactory();
  if ( !authMethod )
  {
    QgsMessageLog::logMessage( QObject::tr( "Unable to instantiate the auth method plugin %1" ).arg( lib ) );
    myLib.unload();
    return 0;
  }

  QgsDebugMsg( QString( "Instantiated the auth method plugin: %1" ).arg( authMethod->key() ) );
  return authMethod;
}
开发者ID:landryb,项目名称:QGIS,代码行数:50,代码来源:qgsauthmethodregistry.cpp

示例8: lib

QgsTransaction* QgsTransaction::create( const QString& connString, const QString& providerKey )
{
  std::unique_ptr< QLibrary > lib( QgsProviderRegistry::instance()->providerLibrary( providerKey ) );
  if ( !lib )
    return nullptr;

  createTransaction_t* createTransaction = reinterpret_cast< createTransaction_t* >( cast_to_fptr( lib->resolve( "createTransaction" ) ) );
  if ( !createTransaction )
    return nullptr;

  QgsTransaction* ts = createTransaction( connString );

  return ts;
}
开发者ID:wongjimsan,项目名称:QGIS,代码行数:14,代码来源:qgstransaction.cpp

示例9: G_parser

int GRASS_LIB_EXPORT G_parser( int argc, char **argv )
{
    QgsDebugMsg( "Entered" );
    G_parser_type* fn = ( G_parser_type* ) cast_to_fptr( QgsGrassGisLib::instance()->resolve( "G_parser" ) );
    int ret = fn( argc, argv );

    if ( ret == 0 ) // parsed OK
    {
        // It would be useful to determine the region from input raster layers if
        // no one is given by environment variable but there seems to be no way to
        // get access to module options. Everything is in static variables in
        // parser.c and there are no access functions to them.
    }
    return ret;
}
开发者ID:Benardi-atmadja,项目名称:QGIS,代码行数:15,代码来源:qgsgrassgislib.cpp

示例10: library

int QgsProviderRegistry::providerCapabilities( const QString &providerKey ) const
{
  std::unique_ptr< QLibrary > library( createProviderLibrary( providerKey ) );
  if ( !library )
  {
    return QgsDataProvider::NoDataCapabilities;
  }

  dataCapabilities_t *dataCapabilities = reinterpret_cast< dataCapabilities_t *>( cast_to_fptr( library->resolve( "dataCapabilities" ) ) );
  if ( !dataCapabilities )
  {
    return QgsDataProvider::NoDataCapabilities;
  }

  return dataCapabilities();
}
开发者ID:CS-SI,项目名称:QGIS,代码行数:16,代码来源:qgsproviderregistry.cpp

示例11: providerLibrary

int QgsProviderRegistry::providerCapabilities( const QString &providerKey ) const
{
    QLibrary *library = providerLibrary( providerKey );
    if ( !library )
    {
        return QgsDataProvider::NoDataCapabilities;
    }

    dataCapabilities_t * dataCapabilities = ( dataCapabilities_t * ) cast_to_fptr( library->resolve( "dataCapabilities" ) );
    if ( !dataCapabilities )
    {
        return QgsDataProvider::NoDataCapabilities;
    }

    return dataCapabilities();
}
开发者ID:spatialthoughts,项目名称:QGIS,代码行数:16,代码来源:qgsproviderregistry.cpp

示例12: while

QgsProviderRegistry::~QgsProviderRegistry()
{
  Providers::const_iterator it = mProviders.begin();

  while ( it != mProviders.end() )
  {
    QString lib = it->second->library();
    QLibrary myLib( lib );
    if ( myLib.isLoaded() )
    {
      cleanupProviderFunction_t* cleanupFunc = ( cleanupProviderFunction_t* ) cast_to_fptr( myLib.resolve( "cleanupProvider" ) );
      if ( cleanupFunc )
        cleanupFunc();
    }
    ++it;
  }
}
开发者ID:AnAvidDeveloper,项目名称:QGIS,代码行数:17,代码来源:qgsproviderregistry.cpp

示例13: cast_to_fptr

QgsRasterDataProvider *QgsRasterDataProvider::create( const QString &providerKey,
    const QString &uri,
    const QString &format, int nBands,
    Qgis::DataType type,
    int width, int height, double *geoTransform,
    const QgsCoordinateReferenceSystem &crs,
    const QStringList &createOptions )
{
  createFunction_t *createFn = reinterpret_cast< createFunction_t * >( cast_to_fptr( QgsProviderRegistry::instance()->function( providerKey, "create" ) ) );
  if ( !createFn )
  {
    QgsDebugMsg( "Cannot resolve 'create' function in " + providerKey + " provider" );
    // TODO: it would be good to return invalid QgsRasterDataProvider
    // with QgsError set, but QgsRasterDataProvider has pure virtual methods
    return nullptr;
  }
  return createFn( uri, format, nBands, type, width, height, geoTransform, crs, createOptions );
}
开发者ID:lyhkop,项目名称:QGIS,代码行数:18,代码来源:qgsrasterdataprovider.cpp

示例14: while

QgsAuthMethodRegistry::~QgsAuthMethodRegistry()
{
  AuthMethods::const_iterator it = mAuthMethods.begin();

  while ( it != mAuthMethods.end() )
  {
    QgsDebugMsg( QString( "cleanup: %1" ).arg( it->first ) );
    QString lib = it->second->library();
    QLibrary myLib( lib );
    if ( myLib.isLoaded() )
    {
      cleanupAuthMethod_t* cleanupFunc = ( cleanupAuthMethod_t* ) cast_to_fptr( myLib.resolve( "cleanupAuthMethod" ) );
      if ( cleanupFunc )
        cleanupFunc();
    }
    // clear cached QgsAuthMethodMetadata *
    delete it->second;
    ++it;
  }
}
开发者ID:landryb,项目名称:QGIS,代码行数:20,代码来源:qgsauthmethodregistry.cpp

示例15: cast_to_fptr

QgsTransaction* QgsTransaction::create( const QString& connString, const QString& providerKey )
{

  QLibrary* lib = QgsProviderRegistry::instance()->providerLibrary( providerKey );
  if ( !lib )
  {
    return 0;
  }

  createTransaction_t* createTransaction = ( createTransaction_t* ) cast_to_fptr( lib->resolve( "createTransaction" ) );
  if ( !createTransaction )
  {
    return 0;
  }

  QgsTransaction* ts = createTransaction( connString );

  delete lib;

  return ts;
}
开发者ID:stevenmizuno,项目名称:QGIS,代码行数:21,代码来源:qgstransaction.cpp


注:本文中的cast_to_fptr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。