本文整理汇总了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 );
}
示例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 );
}
示例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 );
}
示例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
示例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 );
}
示例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 );
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
}
示例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 );
}
示例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;
}
}
示例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;
}