LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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 ()
 
void scanInProgressChanged (bool inProgress)
 

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
 
bool cancelScan () noexcept
 
WorkspaceLibraryScanneroperator= (const WorkspaceLibraryScanner &rhs)=delete
 

Private Types

enum class  State
 

Private Member Functions

void run () noexcept override
 
void scan () noexcept
 
void getLibrariesOfDirectory (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, 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<typename ElementType >
void addResourcesToDb (WorkspaceLibraryDbWriter &writer, int elementId, const ElementType &element)
 
template<typename ElementType >
std::unique_ptr< ElementType > openAndMigrate (const FilePath &fp)
 
bool abortRequested () const noexcept
 
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 Package &element)
 
template<>
int addElementToDb (WorkspaceLibraryDbWriter &writer, int libId, const Component &element)
 
template<>
int addElementToDb (WorkspaceLibraryDbWriter &writer, int libId, const Device &element)
 
template<>
int addElementToDb (WorkspaceLibraryDbWriter &writer, int libId, const Organization &element)
 

Private Attributes

const FilePath mLibrariesPath
 Path to workspace libraries directory.
 
const FilePath mDbFilePath
 Path to the SQLite database file.
 
std::mutex mMutex
 Mutex to protect mState.
 
State mState
 Protected by mMutex.
 
std::condition_variable mStateCV
 To notify about mState changes.
 
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.

Member Enumeration Documentation

◆ State

enum class State
strongprivate
Enumerator
Idle 
StartRequested 
Scanning 
CancelRequested 
ShutdownRequested 

Constructor & Destructor Documentation

◆ WorkspaceLibraryScanner() [1/2]

WorkspaceLibraryScanner ( const FilePath librariesPath,
const FilePath dbFilePath 
)
noexcept
+ Here is the call graph for this function:

◆ WorkspaceLibraryScanner() [2/2]

◆ ~WorkspaceLibraryScanner()

~WorkspaceLibraryScanner ( )
noexcept

Member Function Documentation

◆ getProgressPercent()

int getProgressPercent ( ) const
inlinenoexcept

◆ startScan()

void startScan ( )
noexcept

◆ cancelScan()

bool cancelScan ( )
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:

◆ scanInProgressChanged

void scanInProgressChanged ( bool  inProgress)
signal
+ Here is the caller graph for this function:

◆ run()

void run ( )
overrideprivatenoexcept
+ Here is the call 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 ( 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()

template<typename ElementType >
int addElementsToDb ( WorkspaceLibraryDbWriter writer,
const FilePath libPath,
const QStringList &  dirs,
int  libId 
)
private
+ Here is the call graph for this function:

◆ addElementToDb() [1/7]

template<typename ElementType >
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()

template<typename ElementType >
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()

template<typename ElementType >
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:

◆ addResourcesToDb()

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

◆ openAndMigrate()

template<typename ElementType >
std::unique_ptr< ElementType > openAndMigrate ( const FilePath fp)
private
+ Here is the call graph for this function:

◆ abortRequested()

bool abortRequested ( ) const
privatenoexcept
+ Here is the caller graph for this function:

◆ addElementToDb() [2/7]

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

◆ addElementToDb() [3/7]

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

◆ addElementToDb() [4/7]

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

◆ addElementToDb() [5/7]

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

◆ addElementToDb() [6/7]

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

◆ addElementToDb() [7/7]

template<>
int addElementToDb ( WorkspaceLibraryDbWriter writer,
int  libId,
const Organization 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.

◆ mMutex

std::mutex mMutex
mutableprivate

Mutex to protect mState.

◆ mState

State mState
private

Protected by mMutex.

◆ mStateCV

std::condition_variable mStateCV
private

To notify about mState changes.

◆ mLastProgressPercent

int mLastProgressPercent
private

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