LibrePCB Developers Documentation
WorkspaceLibraryScanner Class Referencefinal

The WorkspaceLibraryScanner class. More...

#include <workspacelibraryscanner.h>

Inherits QThread.

+ Collaboration diagram for WorkspaceLibraryScanner:

Signals

void scanStarted ()
 
void scanLibraryListUpdated (int libraryCount)
 
void scanProgressUpdate (int percent)
 
void scanSucceeded (int elementCount)
 
void scanFailed (QString errorMsg)
 
void scanFinished ()
 

Public Member Functions

 WorkspaceLibraryScanner (Workspace &ws, const FilePath &dbFilePath) noexcept
 
 WorkspaceLibraryScanner (const WorkspaceLibraryScanner &other)=delete
 
 ~WorkspaceLibraryScanner () noexcept
 
void startScan () noexcept
 
WorkspaceLibraryScanneroperator= (const WorkspaceLibraryScanner &rhs)=delete
 
template<>
QVariant optionalToVariant (const tl::optional< QString > &opt) noexcept
 
template<>
QVariant optionalToVariant (const tl::optional< ElementName > &opt) noexcept
 

Private Member Functions

void run () noexcept override
 
void scan () noexcept
 
QHash< QString, int > updateLibraries (SQLiteDatabase &db, const QHash< QString, std::shared_ptr< library::Library >> &libs)
 
void clearAllTables (SQLiteDatabase &db)
 
void getLibrariesOfDirectory (std::shared_ptr< TransactionalFileSystem > fs, const QString &root, QHash< QString, std::shared_ptr< library::Library >> &libs) noexcept
 
template<typename ElementType >
int addCategoriesToDb (SQLiteDatabase &db, std::shared_ptr< TransactionalFileSystem > fs, const QString &libPath, const QStringList &dirs, const QString &table, const QString &idColumn, int libId)
 
template<typename ElementType >
int addElementsToDb (SQLiteDatabase &db, std::shared_ptr< TransactionalFileSystem > fs, const QString &libPath, const QStringList &dirs, const QString &table, const QString &idColumn, int libId)
 
template<typename ElementType >
void addElementToDb (SQLiteDatabase &db, const QString &table, const QString &idColumn, int libId, const QString &path, const ElementType &element)
 
template<typename ElementType >
void addElementTranslationsToDb (SQLiteDatabase &db, const QString &table, const QString &idColumn, int id, const ElementType &element)
 
void addElementCategoriesToDb (SQLiteDatabase &db, const QString &table, const QString &idColumn, int id, const QSet< Uuid > &categories)
 
template<>
void addElementToDb (SQLiteDatabase &db, const QString &table, const QString &idColumn, int libId, const QString &path, const Device &element)
 

Static Private Member Functions

template<typename T >
static QVariant optionalToVariant (const T &opt) noexcept
 

Private Attributes

WorkspacemWorkspace
 
FilePath mDbFilePath
 
QSemaphore mSemaphore
 
volatile bool mAbort
 

Detailed Description

The WorkspaceLibraryScanner class.

Warning
Be very careful with dependencies to other objects as the run() method is executed in a separate thread! Keep the number of dependencies as small as possible and consider thread synchronization and object lifetimes.

Constructor & Destructor Documentation

◆ WorkspaceLibraryScanner() [1/2]

WorkspaceLibraryScanner ( Workspace ws,
const FilePath dbFilePath 
)
noexcept

◆ WorkspaceLibraryScanner() [2/2]

◆ ~WorkspaceLibraryScanner()

~WorkspaceLibraryScanner ( )
noexcept

Member Function Documentation

◆ startScan()

void startScan ( )
noexcept

◆ operator=()

WorkspaceLibraryScanner& operator= ( const WorkspaceLibraryScanner rhs)
delete

◆ scanStarted

void scanStarted ( )
signal
+ Here is the caller graph for this function:

◆ scanLibraryListUpdated

void scanLibraryListUpdated ( int  libraryCount)
signal
+ Here is the caller graph for this function:

◆ scanProgressUpdate

void scanProgressUpdate ( int  percent)
signal
+ Here is the caller graph for this function:

◆ scanSucceeded

void scanSucceeded ( int  elementCount)
signal
+ Here is the caller graph for this function:

◆ scanFailed

void scanFailed ( QString  errorMsg)
signal
+ Here is the caller graph for this function:

◆ scanFinished

void scanFinished ( )
signal
+ Here is the caller graph for this function:

◆ run()

void run ( )
overrideprivatenoexcept

◆ scan()

void scan ( )
privatenoexcept
+ Here is the call graph for this function:

◆ updateLibraries()

QHash< QString, int > updateLibraries ( SQLiteDatabase db,
const QHash< QString, std::shared_ptr< library::Library >> &  libs 
)
private
+ Here is the call graph for this function:

◆ clearAllTables()

void clearAllTables ( SQLiteDatabase db)
private
+ Here is the call graph for this function:

◆ getLibrariesOfDirectory()

void getLibrariesOfDirectory ( std::shared_ptr< TransactionalFileSystem fs,
const QString &  root,
QHash< QString, std::shared_ptr< library::Library >> &  libs 
)
privatenoexcept
+ Here is the call graph for this function:

◆ addCategoriesToDb()

int addCategoriesToDb ( SQLiteDatabase db,
std::shared_ptr< TransactionalFileSystem fs,
const QString &  libPath,
const QStringList &  dirs,
const QString &  table,
const QString &  idColumn,
int  libId 
)
private
+ Here is the call graph for this function:

◆ addElementsToDb()

int addElementsToDb ( SQLiteDatabase db,
std::shared_ptr< TransactionalFileSystem fs,
const QString &  libPath,
const QStringList &  dirs,
const QString &  table,
const QString &  idColumn,
int  libId 
)
private

◆ addElementToDb() [1/2]

void addElementToDb ( SQLiteDatabase db,
const QString &  table,
const QString &  idColumn,
int  libId,
const QString &  path,
const ElementType &  element 
)
private
+ Here is the call graph for this function:

◆ addElementTranslationsToDb()

void addElementTranslationsToDb ( SQLiteDatabase db,
const QString &  table,
const QString &  idColumn,
int  id,
const ElementType &  element 
)
private
+ Here is the call graph for this function:

◆ addElementCategoriesToDb()

void addElementCategoriesToDb ( SQLiteDatabase db,
const QString &  table,
const QString &  idColumn,
int  id,
const QSet< Uuid > &  categories 
)
private
+ Here is the call graph for this function:

◆ optionalToVariant() [1/3]

static QVariant optionalToVariant ( const T &  opt)
staticprivatenoexcept

◆ optionalToVariant() [2/3]

QVariant optionalToVariant ( const tl::optional< QString > &  opt)
noexcept

◆ optionalToVariant() [3/3]

QVariant optionalToVariant ( const tl::optional< ElementName > &  opt)
noexcept

◆ addElementToDb() [2/2]

void addElementToDb ( SQLiteDatabase db,
const QString &  table,
const QString &  idColumn,
int  libId,
const QString &  path,
const Device element 
)
private

Member Data Documentation

◆ mWorkspace

Workspace& mWorkspace
private

◆ mDbFilePath

FilePath mDbFilePath
private

◆ mSemaphore

QSemaphore mSemaphore
private

◆ mAbort

volatile bool mAbort
private

The documentation for this class was generated from the following files: