Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
PVR::CPVREpgDatabase Class Reference

#include <EpgDatabase.h>

Inheritance diagram for PVR::CPVREpgDatabase:
CDatabase

Public Member Functions

 CPVREpgDatabase ()=default
 Create a new instance of the EPG database.
 
 ~CPVREpgDatabase () override=default
 Destroy this instance.
 
bool Open () override
 Open the database.
 
void Close () override
 Close the database.
 
void Lock ()
 Lock the database.
 
void Unlock ()
 Unlock the database.
 
int GetSchemaVersion () const override
 Get the minimal database version that is required to operate correctly.
 
const char * GetBaseDBName () const override
 Get the default sqlite database filename.
 
EPG methods
bool DeleteEpg ()
 Remove all EPG information from the database.
 
bool QueueDeleteEpgQuery (const CPVREpg &table)
 Queue deletionof an EPG table.
 
bool QueueDeleteTagQuery (const CPVREpgInfoTag &tag)
 Write the query to delete the given EPG tag to db query queue.
 
std::vector< std::shared_ptr< CPVREpg > > GetAll ()
 Get all EPG tables from the database. Does not get the EPG tables' entries.
 
std::vector< std::shared_ptr< CPVREpgInfoTag > > GetAllEpgTags (int iEpgID) const
 Get all tags for a given EPG id.
 
std::vector< std::string > GetAllIconPaths (int iEpgID) const
 Get all icon paths for a given EPG id.
 
bool HasTags (int iEpgID) const
 Check whether this EPG has any tags.
 
CDateTime GetLastEndTime (int iEpgID) const
 Get the end time of the last tag in this EPG.
 
std::pair< CDateTime, CDateTimeGetFirstAndLastEPGDate () const
 Get the start and end time across all EPGs.
 
CDateTime GetMinStartTime (int iEpgID, const CDateTime &minStart) const
 Get the start time of the first tag with a start time greater than the given min time.
 
CDateTime GetMaxEndTime (int iEpgID, const CDateTime &maxEnd) const
 Get the end time of the first tag with an end time less than the given max time.
 
std::vector< std::shared_ptr< CPVREpgInfoTag > > GetEpgTags (const PVREpgSearchData &searchData) const
 Get all EPG tags matching the given search criteria.
 
std::shared_ptr< CPVREpgInfoTagGetEpgTagByUniqueBroadcastID (int iEpgID, unsigned int iUniqueBroadcastId) const
 Get an EPG tag given its EPG id and unique broadcast ID.
 
std::shared_ptr< CPVREpgInfoTagGetEpgTagByDatabaseID (int iEpgID, int iDatabaseId) const
 Get an EPG tag given its EPG id and database ID.
 
std::shared_ptr< CPVREpgInfoTagGetEpgTagByStartTime (int iEpgID, const CDateTime &startTime) const
 Get an EPG tag given its EPG ID and start time.
 
std::shared_ptr< CPVREpgInfoTagGetEpgTagByMinStartTime (int iEpgID, const CDateTime &minStartTime) const
 Get the next EPG tag matching the given EPG id and min start time.
 
std::shared_ptr< CPVREpgInfoTagGetEpgTagByMaxEndTime (int iEpgID, const CDateTime &maxEndTime) const
 Get the next EPG tag matching the given EPG id and max end time.
 
std::vector< std::shared_ptr< CPVREpgInfoTag > > GetEpgTagsByMinStartMaxEndTime (int iEpgID, const CDateTime &minStartTime, const CDateTime &maxEndTime) const
 Get all EPG tags matching the given EPG id, min start time and max end time.
 
std::vector< std::shared_ptr< CPVREpgInfoTag > > GetEpgTagsByMinEndMaxStartTime (int iEpgID, const CDateTime &minEndTime, const CDateTime &maxStartTime) const
 Get all EPG tags matching the given EPG id, min end time and max start time.
 
bool QueueDeleteEpgTagsByMinEndMaxStartTimeQuery (int iEpgID, const CDateTime &minEndTime, const CDateTime &maxStartTime)
 Write the query to delete all EPG tags in range of given EPG id, min end time and max start time to db query queue. .
 
bool GetLastEpgScanTime (int iEpgId, CDateTime *lastScan) const
 Get the last stored EPG scan time.
 
bool QueuePersistLastEpgScanTimeQuery (int iEpgId, const CDateTime &lastScanTime)
 Write the query to update the last scan time for the given EPG to db query queue.
 
bool QueueDeleteLastEpgScanTimeQuery (const CPVREpg &table)
 Write the query to delete the last scan time for the given EPG to db query queue.
 
int Persist (const CPVREpg &epg, bool bQueueWrite)
 Persist an EPG table. It's entries are not persisted.
 
bool DeleteEpgTags (int iEpgId, const CDateTime &maxEndTime)
 Erase all EPG tags with the given epg ID and an end time less than the given time.
 
bool DeleteEpgTags (int iEpgId)
 Erase all EPG tags with the given epg ID.
 
bool QueueDeleteEpgTags (int iEpgId)
 Queue the erase all EPG tags with the given epg ID.
 
bool QueuePersistQuery (const CPVREpgInfoTag &tag)
 Write the query to persist the given EPG tag to db query queue.
 
int GetLastEPGId () const
 
- Public Member Functions inherited from CDatabase
 CDatabase ()
 
virtual ~CDatabase (void)
 
bool IsOpen ()
 
bool Compress (bool bForce=true)
 
void Interrupt ()
 
bool Open (const DatabaseSettings &db)
 
void BeginTransaction ()
 
virtual bool CommitTransaction ()
 
void RollbackTransaction ()
 
void CopyDB (const std::string &latestDb)
 
void DropAnalytics ()
 
std::string PrepareSQL (std::string strStmt,...) const
 
std::string GetSingleValue (const std::string &strTable, const std::string &strColumn, const std::string &strWhereClause=std::string(), const std::string &strOrderBy=std::string()) const
 Get a single value from a table.
 
std::string GetSingleValue (const std::string &query) const
 
std::string GetSingleValue (const std::string &query, const std::unique_ptr< dbiplus::Dataset > &ds) const
 Get a single value from a query on a dataset.
 
int GetSingleValueInt (const std::string &strTable, const std::string &strColumn, const std::string &strWhereClause=std::string(), const std::string &strOrderBy=std::string()) const
 Get a single integer value from a table.
 
int GetSingleValueInt (const std::string &query) const
 
int GetSingleValueInt (const std::string &query, const std::unique_ptr< dbiplus::Dataset > &ds) const
 Get a single integer value from a query on a dataset.
 
bool DeleteValues (const std::string &strTable, const Filter &filter=Filter())
 Delete values from a table.
 
bool ExecuteQuery (const std::string &strQuery)
 Execute a query that does not return any result. Note that if BeginMultipleExecute() has been called, the query will be queued until CommitMultipleExecute() is called.
 
bool ResultQuery (const std::string &strQuery) const
 Execute a query that returns a result.
 
bool BeginMultipleExecute ()
 Start a multiple execution queue. Any ExecuteQuery() function following this call will be queued rather than executed until CommitMultipleExecute() is performed. NOTE: Queries that rely on any queued execute query will not function as expected during this period!
 
bool CommitMultipleExecute ()
 Commit the multiple execution queue to the database. Queries are performed within a transaction, and the transaction is rolled back should any one query fail.
 
bool QueueInsertQuery (const std::string &strQuery)
 Put an INSERT or REPLACE query in the queue.
 
bool CommitInsertQueries ()
 Commit all queries in the queue.
 
size_t GetInsertQueriesCount ()
 Get the number of INSERT queries in the queue.
 
bool QueueDeleteQuery (const std::string &strQuery)
 Put a DELETE query in the queue.
 
bool CommitDeleteQueries ()
 Commit all queued DELETE queries.
 
size_t GetDeleteQueriesCount ()
 Get the number of DELETE queries in the queue.
 
virtual bool GetFilter (CDbUrl &dbUrl, Filter &filter, SortDescription &sorting)
 
virtual bool BuildSQL (const std::string &strBaseDir, const std::string &strQuery, Filter &filter, std::string &strSQL, CDbUrl &dbUrl)
 
virtual bool BuildSQL (const std::string &strBaseDir, const std::string &strQuery, Filter &filter, std::string &strSQL, CDbUrl &dbUrl, SortDescription &sorting)
 
bool Connect (const std::string &dbName, const DatabaseSettings &db, bool create)
 

EPG searches methods

std::vector< std::shared_ptr< CPVREpgSearchFilter > > GetSavedSearches (bool bRadio) const
 Get all saved searches from the database.
 
std::shared_ptr< CPVREpgSearchFilterGetSavedSearchById (bool bRadio, int iId) const
 Get the saved search matching the given id.
 
bool Persist (CPVREpgSearchFilter &epgSearch)
 Persist a search.
 
bool UpdateSavedSearchLastExecuted (const CPVREpgSearchFilter &epgSearch)
 Update time last executed for the given search.
 
bool Delete (const CPVREpgSearchFilter &epgSearch)
 Delete a saved search.
 
bool DeleteSavedSearches ()
 Delete all saved searches.
 

Additional Inherited Members

- Protected Member Functions inherited from CDatabase
void Split (const std::string &strFileNameAndPath, std::string &strPath, std::string &strFileName)
 
bool CreateDatabase ()
 Create database tables and analytics as needed. Calls CreateTables() and CreateAnalytics() on child classes.
 
int GetDBVersion ()
 
bool BuildSQL (const std::string &strQuery, const Filter &filter, std::string &strSQL) const
 
- Protected Attributes inherited from CDatabase
bool m_sqlite
 whether we use sqlite (defaults to true)
 
std::unique_ptr< dbiplus::Databasem_pDB
 
std::unique_ptr< dbiplus::Datasetm_pDS
 
std::unique_ptr< dbiplus::Datasetm_pDS2
 
const CProfileManagerm_profileManager
 

Constructor & Destructor Documentation

◆ CPVREpgDatabase()

PVR::CPVREpgDatabase::CPVREpgDatabase ( )
default

Create a new instance of the EPG database.

◆ ~CPVREpgDatabase()

PVR::CPVREpgDatabase::~CPVREpgDatabase ( )
overridedefault

Destroy this instance.

Member Function Documentation

◆ Close()

void CPVREpgDatabase::Close ( )
overridevirtual

Close the database.

Reimplemented from CDatabase.

◆ Delete()

bool CPVREpgDatabase::Delete ( const CPVREpgSearchFilter & epgSearch)

Delete a saved search.

Parameters
epgSearchThe search.
Returns
True on success, false otherwise.

◆ DeleteEpg()

bool CPVREpgDatabase::DeleteEpg ( )

Remove all EPG information from the database.

Returns
True if the EPG information was erased, false otherwise.

◆ DeleteEpgTags() [1/2]

bool CPVREpgDatabase::DeleteEpgTags ( int iEpgId)

Erase all EPG tags with the given epg ID.

Parameters
iEpgIdThe ID of the EPG.
Returns
True if the entries were removed successfully, false otherwise.

◆ DeleteEpgTags() [2/2]

bool CPVREpgDatabase::DeleteEpgTags ( int iEpgId,
const CDateTime & maxEndTime )

Erase all EPG tags with the given epg ID and an end time less than the given time.

Parameters
iEpgIdThe ID of the EPG.
maxEndTimeThe maximum allowed end time.
Returns
True if the entries were removed successfully, false otherwise.

◆ DeleteSavedSearches()

bool CPVREpgDatabase::DeleteSavedSearches ( )

Delete all saved searches.

Returns
True on success, false otherwise.

◆ GetAll()

std::vector< std::shared_ptr< CPVREpg > > CPVREpgDatabase::GetAll ( )

Get all EPG tables from the database. Does not get the EPG tables' entries.

Returns
The entries.

◆ GetAllEpgTags()

std::vector< std::shared_ptr< CPVREpgInfoTag > > CPVREpgDatabase::GetAllEpgTags ( int iEpgID) const

Get all tags for a given EPG id.

Parameters
iEpgIDThe ID of the EPG.
Returns
The entries.

◆ GetAllIconPaths()

std::vector< std::string > CPVREpgDatabase::GetAllIconPaths ( int iEpgID) const

Get all icon paths for a given EPG id.

Parameters
iEpgIDThe ID of the EPG.
Returns
The entries.

◆ GetBaseDBName()

const char * PVR::CPVREpgDatabase::GetBaseDBName ( ) const
inlineoverridevirtual

Get the default sqlite database filename.

Returns
The default filename.

Implements CDatabase.

◆ GetEpgTagByDatabaseID()

std::shared_ptr< CPVREpgInfoTag > CPVREpgDatabase::GetEpgTagByDatabaseID ( int iEpgID,
int iDatabaseId ) const

Get an EPG tag given its EPG id and database ID.

Parameters
iEpgIDThe ID of the EPG for the tag to get.
iDatabaseIdThe database ID for the tag to get.
Returns
The tag or nullptr, if not found.

◆ GetEpgTagByMaxEndTime()

std::shared_ptr< CPVREpgInfoTag > CPVREpgDatabase::GetEpgTagByMaxEndTime ( int iEpgID,
const CDateTime & maxEndTime ) const

Get the next EPG tag matching the given EPG id and max end time.

Parameters
iEpgIDThe ID of the EPG for the tag to get.
maxEndTimeThe max end time for the tag to get.
Returns
The tag or nullptr, if not found.

◆ GetEpgTagByMinStartTime()

std::shared_ptr< CPVREpgInfoTag > CPVREpgDatabase::GetEpgTagByMinStartTime ( int iEpgID,
const CDateTime & minStartTime ) const

Get the next EPG tag matching the given EPG id and min start time.

Parameters
iEpgIDThe ID of the EPG for the tag to get.
minStartTimeThe min start time for the tag to get.
Returns
The tag or nullptr, if not found.

◆ GetEpgTagByStartTime()

std::shared_ptr< CPVREpgInfoTag > CPVREpgDatabase::GetEpgTagByStartTime ( int iEpgID,
const CDateTime & startTime ) const

Get an EPG tag given its EPG ID and start time.

Parameters
iEpgIDThe ID of the EPG for the tag to get.
startTimeThe start time for the tag to get.
Returns
The tag or nullptr, if not found.

◆ GetEpgTagByUniqueBroadcastID()

std::shared_ptr< CPVREpgInfoTag > CPVREpgDatabase::GetEpgTagByUniqueBroadcastID ( int iEpgID,
unsigned int iUniqueBroadcastId ) const

Get an EPG tag given its EPG id and unique broadcast ID.

Parameters
iEpgIDThe ID of the EPG for the tag to get.
iUniqueBroadcastIdThe unique broadcast ID for the tag to get.
Returns
The tag or nullptr, if not found.

◆ GetEpgTags()

std::vector< std::shared_ptr< CPVREpgInfoTag > > CPVREpgDatabase::GetEpgTags ( const PVREpgSearchData & searchData) const

Get all EPG tags matching the given search criteria.

Parameters
searchDataThe search criteria.
Returns
The matching tags.

◆ GetEpgTagsByMinEndMaxStartTime()

std::vector< std::shared_ptr< CPVREpgInfoTag > > CPVREpgDatabase::GetEpgTagsByMinEndMaxStartTime ( int iEpgID,
const CDateTime & minEndTime,
const CDateTime & maxStartTime ) const

Get all EPG tags matching the given EPG id, min end time and max start time.

Parameters
iEpgIDThe ID of the EPG for the tags to get.
minEndTimeThe min end time for the tags to get.
maxStartTimeThe max start time for the tags to get.
Returns
The tags or empty vector, if no tags were found.

◆ GetEpgTagsByMinStartMaxEndTime()

std::vector< std::shared_ptr< CPVREpgInfoTag > > CPVREpgDatabase::GetEpgTagsByMinStartMaxEndTime ( int iEpgID,
const CDateTime & minStartTime,
const CDateTime & maxEndTime ) const

Get all EPG tags matching the given EPG id, min start time and max end time.

Parameters
iEpgIDThe ID of the EPG for the tags to get.
minStartTimeThe min start time for the tags to get.
maxEndTimeThe max end time for the tags to get.
Returns
The tags or empty vector, if no tags were found.

◆ GetFirstAndLastEPGDate()

std::pair< CDateTime, CDateTime > CPVREpgDatabase::GetFirstAndLastEPGDate ( ) const

Get the start and end time across all EPGs.

Returns
The times; first: start time, second: end time.

◆ GetLastEndTime()

CDateTime CPVREpgDatabase::GetLastEndTime ( int iEpgID) const

Get the end time of the last tag in this EPG.

Parameters
iEpgIDThe ID of the EPG.
Returns
The time.

◆ GetLastEPGId()

int CPVREpgDatabase::GetLastEPGId ( ) const
Returns
Last EPG id in the database

◆ GetLastEpgScanTime()

bool CPVREpgDatabase::GetLastEpgScanTime ( int iEpgId,
CDateTime * lastScan ) const

Get the last stored EPG scan time.

Parameters
iEpgIdThe table to update the time for. Use 0 for a global value.
lastScanThe last scan time or -1 if it wasn't found.
Returns
True if the time was fetched successfully, false otherwise.

◆ GetMaxEndTime()

CDateTime CPVREpgDatabase::GetMaxEndTime ( int iEpgID,
const CDateTime & maxEnd ) const

Get the end time of the first tag with an end time less than the given max time.

Parameters
iEpgIDThe ID of the EPG.
maxEndThe mx end time.
Returns
The time.

◆ GetMinStartTime()

CDateTime CPVREpgDatabase::GetMinStartTime ( int iEpgID,
const CDateTime & minStart ) const

Get the start time of the first tag with a start time greater than the given min time.

Parameters
iEpgIDThe ID of the EPG.
minStartThe min start time.
Returns
The time.

◆ GetSavedSearchById()

std::shared_ptr< CPVREpgSearchFilter > CPVREpgDatabase::GetSavedSearchById ( bool bRadio,
int iId ) const

Get the saved search matching the given id.

Parameters
bRadioWhether to fetch a TV or radio saved search.
iIdThe id.
Returns
The saved search or nullptr if not found.

◆ GetSavedSearches()

std::vector< std::shared_ptr< CPVREpgSearchFilter > > CPVREpgDatabase::GetSavedSearches ( bool bRadio) const

Get all saved searches from the database.

Parameters
bRadioWhether to fetch saved searches for radio or TV.
Returns
The searches.

◆ GetSchemaVersion()

int PVR::CPVREpgDatabase::GetSchemaVersion ( ) const
inlineoverridevirtual

Get the minimal database version that is required to operate correctly.

Returns
The minimal database version.

Implements CDatabase.

◆ HasTags()

bool CPVREpgDatabase::HasTags ( int iEpgID) const

Check whether this EPG has any tags.

Parameters
iEpgIDThe ID of the EPG.
Returns
True in case there are tags, false otherwise.

◆ Lock()

void CPVREpgDatabase::Lock ( )

Lock the database.

◆ Open()

bool CPVREpgDatabase::Open ( )
overridevirtual

Open the database.

Returns
True if it was opened successfully, false otherwise.

Reimplemented from CDatabase.

◆ Persist() [1/2]

int CPVREpgDatabase::Persist ( const CPVREpg & epg,
bool bQueueWrite )

Persist an EPG table. It's entries are not persisted.

Parameters
epgThe table to persist.
bQueueWriteIf true, don't execute the query immediately but queue it.
Returns
The database ID of this entry or 0 if bQueueWrite is false and the query was queued.

◆ Persist() [2/2]

bool CPVREpgDatabase::Persist ( CPVREpgSearchFilter & epgSearch)

Persist a search.

Parameters
epgSearchThe search.
Returns
True on success, false otherwise.

◆ QueueDeleteEpgQuery()

bool CPVREpgDatabase::QueueDeleteEpgQuery ( const CPVREpg & table)

Queue deletionof an EPG table.

Parameters
tagThe table to queue for deletion.
Returns
True on success, false otherwise.

◆ QueueDeleteEpgTags()

bool CPVREpgDatabase::QueueDeleteEpgTags ( int iEpgId)

Queue the erase all EPG tags with the given epg ID.

Parameters
iEpgIdThe ID of the EPG.
Returns
True if the entries were queued successfully, false otherwise.

◆ QueueDeleteEpgTagsByMinEndMaxStartTimeQuery()

bool CPVREpgDatabase::QueueDeleteEpgTagsByMinEndMaxStartTimeQuery ( int iEpgID,
const CDateTime & minEndTime,
const CDateTime & maxStartTime )

Write the query to delete all EPG tags in range of given EPG id, min end time and max start time to db query queue. .

Parameters
iEpgIDThe ID of the EPG for the tags to delete.
minEndTimeThe min end time for the tags to delete.
maxStartTimeThe max start time for the tags to delete.
Returns
True if it was removed or queued successfully, false otherwise.

◆ QueueDeleteLastEpgScanTimeQuery()

bool CPVREpgDatabase::QueueDeleteLastEpgScanTimeQuery ( const CPVREpg & table)

Write the query to delete the last scan time for the given EPG to db query queue.

Parameters
iEpgIdThe table to delete the time for.
Returns
True on success, false otherwise.

◆ QueueDeleteTagQuery()

bool CPVREpgDatabase::QueueDeleteTagQuery ( const CPVREpgInfoTag & tag)

Write the query to delete the given EPG tag to db query queue.

Parameters
tagThe EPG tag to remove.
Returns
True on success, false otherwise.

◆ QueuePersistLastEpgScanTimeQuery()

bool CPVREpgDatabase::QueuePersistLastEpgScanTimeQuery ( int iEpgId,
const CDateTime & lastScanTime )

Write the query to update the last scan time for the given EPG to db query queue.

Parameters
iEpgIdThe table to update the time for.
lastScanTimeThe time to write to the database.
Returns
True on success, false otherwise.

◆ QueuePersistQuery()

bool CPVREpgDatabase::QueuePersistQuery ( const CPVREpgInfoTag & tag)

Write the query to persist the given EPG tag to db query queue.

Parameters
tagThe tag to persist.
Returns
True on success, false otherwise.

◆ Unlock()

void CPVREpgDatabase::Unlock ( )

Unlock the database.

◆ UpdateSavedSearchLastExecuted()

bool CPVREpgDatabase::UpdateSavedSearchLastExecuted ( const CPVREpgSearchFilter & epgSearch)

Update time last executed for the given search.

Parameters
epgSearchThe search.
Returns
True on success, false otherwise.

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