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 (const FilePath &librariesPath, const FilePath &dbFilePath) noexcept
 
 WorkspaceLibraryScanner (const WorkspaceLibraryScanner &other)=delete
 
 ~WorkspaceLibraryScanner () noexcept
 
int getProgressPercent () const noexcept
 
void startScan () noexcept
 
WorkspaceLibraryScanneroperator= (const WorkspaceLibraryScanner &rhs)=delete
 

Private Member Functions

void run () noexcept override
 
void scan () noexcept
 
void getLibrariesOfDirectory (std::shared_ptr< TransactionalFileSystem > fs, const QString &root, QList< std::shared_ptr< Library >> &libs) noexcept
 
QHash< FilePath, int > updateLibraries (SQLiteDatabase &db, WorkspaceLibraryDbWriter &writer, const QList< std::shared_ptr< Library >> &libs)
 
template<typename ElementType >
int addElementsToDb (WorkspaceLibraryDbWriter &writer, std::shared_ptr< TransactionalFileSystem > fs, const FilePath &libPath, const QStringList &dirs, int libId)
 
template<typename ElementType >
int addElementToDb (WorkspaceLibraryDbWriter &writer, int libId, const ElementType &element)
 
template<typename ElementType >
void addTranslationsToDb (WorkspaceLibraryDbWriter &writer, int elementId, const ElementType &element)
 
template<typename ElementType >
void addToCategories (WorkspaceLibraryDbWriter &writer, int elementId, const ElementType &element)
 
template<>
int addElementToDb (WorkspaceLibraryDbWriter &writer, int libId, const ComponentCategory &element)
 
template<>
int addElementToDb (WorkspaceLibraryDbWriter &writer, int libId, const PackageCategory &element)
 
template<>
int addElementToDb (WorkspaceLibraryDbWriter &writer, int libId, const Device &element)
 

Private Attributes

const FilePath mLibrariesPath
 Path to workspace libraries directory. More...
 
const FilePath mDbFilePath
 Path to the SQLite database file. More...
 
QSemaphore mSemaphore
 
volatile bool mAbort
 
int mLastProgressPercent
 

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 ( const FilePath librariesPath,
const FilePath dbFilePath 
)
noexcept

◆ WorkspaceLibraryScanner() [2/2]

◆ ~WorkspaceLibraryScanner()

~WorkspaceLibraryScanner ( )
noexcept

Member Function Documentation

◆ getProgressPercent()

int getProgressPercent ( ) const
inlinenoexcept
+ Here is the call graph for this function:

◆ startScan()

void startScan ( )
noexcept
+ Here is the caller graph for this function:

◆ operator=()

WorkspaceLibraryScanner& operator= ( const WorkspaceLibraryScanner rhs)
delete
+ Here is the caller graph for this function:

◆ 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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scan()

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

◆ getLibrariesOfDirectory()

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

◆ updateLibraries()

QHash< FilePath, int > updateLibraries ( SQLiteDatabase db,
WorkspaceLibraryDbWriter writer,
const QList< std::shared_ptr< Library >> &  libs 
)
private
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addElementsToDb()

int addElementsToDb ( WorkspaceLibraryDbWriter writer,
std::shared_ptr< TransactionalFileSystem fs,
const FilePath libPath,
const QStringList &  dirs,
int  libId 
)
private
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addElementToDb() [1/4]

int addElementToDb ( WorkspaceLibraryDbWriter writer,
int  libId,
const ElementType &  element 
)
private
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addTranslationsToDb()

void addTranslationsToDb ( WorkspaceLibraryDbWriter writer,
int  elementId,
const ElementType &  element 
)
private
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addToCategories()

void addToCategories ( WorkspaceLibraryDbWriter writer,
int  elementId,
const ElementType &  element 
)
private
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addElementToDb() [2/4]

int addElementToDb ( WorkspaceLibraryDbWriter writer,
int  libId,
const ComponentCategory element 
)
private

◆ addElementToDb() [3/4]

int addElementToDb ( WorkspaceLibraryDbWriter writer,
int  libId,
const PackageCategory element 
)
private

◆ addElementToDb() [4/4]

int addElementToDb ( WorkspaceLibraryDbWriter writer,
int  libId,
const Device element 
)
private
+ Here is the call graph for this function:

Member Data Documentation

◆ mLibrariesPath

const FilePath mLibrariesPath
private

Path to workspace libraries directory.

◆ mDbFilePath

const FilePath mDbFilePath
private

Path to the SQLite database file.

◆ mSemaphore

QSemaphore mSemaphore
private

◆ mAbort

volatile bool mAbort
private

◆ mLastProgressPercent

int mLastProgressPercent
private

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