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

#include <PVRDatabase.h>

Inheritance diagram for PVR::CPVRDatabase:
CDatabase

Public Member Functions

 CPVRDatabase ()=default
 Create a new instance of the PVR database.
 
 ~CPVRDatabase () override=default
 
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.
 
Channel methods
bool DeleteChannels ()
 Remove all channels from the database.
 
int Get (bool bRadio, const std::vector< std::shared_ptr< CPVRClient > > &clients, std::map< std::pair< int, int >, std::shared_ptr< CPVRChannel > > &results) const
 Get channels from the database.
 
bool Persist (CPVRChannel &channel, bool bCommit)
 Add or update a channel entry in the database.
 
bool QueueDeleteQuery (const CPVRChannel &channel)
 Remove a channel entry from the database.
 
Channel group member methods
bool QueueDeleteQuery (const CPVRChannelGroupMember &groupMember)
 Remove a channel group member entry from the database.
 
Channel provider methods
bool DeleteProviders ()
 Remove all providers from the database.
 
bool Persist (CPVRProvider &provider, bool updateRecord=false)
 Add or update a provider entry in the database.
 
bool Delete (const CPVRProvider &provider)
 Remove a provider entry from the database.
 
bool Get (CPVRProviders &results, const std::vector< std::shared_ptr< CPVRClient > > &clients) const
 Get the list of providers from the database.
 
int GetMaxProviderId () const
 Get the maximum provider id in the database.
 
Channel group methods
bool DeleteChannelGroups ()
 Remove all channel groups from the database.
 
bool Delete (const CPVRChannelGroup &group)
 Delete a channel group and all its members from the database.
 
int GetLocalGroups (CPVRChannelGroups &results) const
 Get all local channel groups.
 
int Get (CPVRChannelGroups &results, const std::vector< std::shared_ptr< CPVRClient > > &clients) const
 Get client-supplied channel groups.
 
std::vector< std::shared_ptr< CPVRChannelGroupMember > > Get (const CPVRChannelGroup &group, const std::vector< std::shared_ptr< CPVRClient > > &clients) const
 Get the members of a channel group.
 
bool Persist (CPVRChannelGroup &group)
 Add or update a channel group entry in the database.
 
bool ResetEPG ()
 Reset all epg ids to 0.
 
Timer methods
std::vector< std::shared_ptr< CPVRTimerInfoTag > > GetTimers (CPVRTimers &timers, const std::vector< std::shared_ptr< CPVRClient > > &clients) const
 Get the timers.
 
bool Persist (CPVRTimerInfoTag &timer)
 Add or update a timer entry in the database.
 
bool Delete (const CPVRTimerInfoTag &timer)
 Remove a timer from the database.
 
bool DeleteTimers ()
 Remove all timer entries from the database.
 
- 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)
 

Client methods

bool DeleteClients ()
 Remove all client entries from the database.
 
bool Persist (const CPVRClient &client)
 Add or update a client entry in the database.
 
bool Delete (const CPVRClient &client)
 Remove a client entry from the database.
 
int GetPriority (const CPVRClient &client) const
 Get the priority for a given client from the database.
 
bool UpdateLastWatched (const CPVRChannel &channel, int groupId)
 Updates the last watched timestamp for the channel.
 
bool UpdateLastWatched (const CPVRChannelGroup &group)
 Updates the last watched timestamp for the channel group.
 
bool UpdateLastOpened (const CPVRChannelGroup &group)
 Updates the last opened timestamp for the channel group.
 

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

◆ CPVRDatabase()

PVR::CPVRDatabase::CPVRDatabase ( )
default

Create a new instance of the PVR database.

◆ ~CPVRDatabase()

PVR::CPVRDatabase::~CPVRDatabase ( )
overridedefault

Member Function Documentation

◆ Close()

void CPVRDatabase::Close ( )
overridevirtual

Close the database.

Reimplemented from CDatabase.

◆ Delete() [1/4]

bool CPVRDatabase::Delete ( const CPVRChannelGroup & group)

Delete a channel group and all its members from the database.

Parameters
groupThe group to delete.
Returns
True if the group was deleted successfully, false otherwise.

◆ Delete() [2/4]

bool CPVRDatabase::Delete ( const CPVRClient & client)

Remove a client entry from the database.

Parameters
clientThe client to remove.
Returns
True if the client was removed, false otherwise.

◆ Delete() [3/4]

bool CPVRDatabase::Delete ( const CPVRProvider & provider)

Remove a provider entry from the database.

Parameters
providerThe provider to remove.
Returns
True if the provider was removed, false otherwise.

◆ Delete() [4/4]

bool CPVRDatabase::Delete ( const CPVRTimerInfoTag & timer)

Remove a timer from the database.

Parameters
timerThe timer to remove.
Returns
True if the timer was removed, false otherwise.

◆ DeleteChannelGroups()

bool CPVRDatabase::DeleteChannelGroups ( )

Remove all channel groups from the database.

Returns
True if all channel groups were removed.

◆ DeleteChannels()

bool CPVRDatabase::DeleteChannels ( )

Remove all channels from the database.

Returns
True if all channels were removed, false otherwise.

◆ DeleteClients()

bool CPVRDatabase::DeleteClients ( )

Remove all client entries from the database.

Returns
True if all client entries were removed, false otherwise.

◆ DeleteProviders()

bool CPVRDatabase::DeleteProviders ( )

Remove all providers from the database.

Returns
True if all providers were removed, false otherwise.

◆ DeleteTimers()

bool CPVRDatabase::DeleteTimers ( )

Remove all timer entries from the database.

Returns
True if all timer entries were removed, false otherwise.

◆ Get() [1/4]

int CPVRDatabase::Get ( bool bRadio,
const std::vector< std::shared_ptr< CPVRClient > > & clients,
std::map< std::pair< int, int >, std::shared_ptr< CPVRChannel > > & results ) const

Get channels from the database.

Parameters
bRadioWhether to fetch radio or TV channels.
clientsThe PVR clients the channels should be loaded for. Leave empty for all clients.
resultsThe container for the channels.
Returns
The number of channels loaded.

◆ Get() [2/4]

std::vector< std::shared_ptr< CPVRChannelGroupMember > > CPVRDatabase::Get ( const CPVRChannelGroup & group,
const std::vector< std::shared_ptr< CPVRClient > > & clients ) const

Get the members of a channel group.

Parameters
groupThe group to get the members for.
clientsThe PVR clients the group members should be loaded for. Leave empty for all clients.
Returns
The group members.

◆ Get() [3/4]

int CPVRDatabase::Get ( CPVRChannelGroups & results,
const std::vector< std::shared_ptr< CPVRClient > > & clients ) const

Get client-supplied channel groups.

Parameters
resultsThe container to store the results in.
clientsThe PVR clients the groups should be loaded for. Leave empty for all clients.
Returns
The number of groups loaded.

◆ Get() [4/4]

bool CPVRDatabase::Get ( CPVRProviders & results,
const std::vector< std::shared_ptr< CPVRClient > > & clients ) const

Get the list of providers from the database.

Parameters
resultsThe providers to store the results in.
clientsThe PVR clients the providers should be loaded for. Leave empty for all clients.
Returns
The amount of providers that were added.

◆ GetBaseDBName()

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

Get the default sqlite database filename.

Returns
The default filename.

Implements CDatabase.

◆ GetLocalGroups()

int CPVRDatabase::GetLocalGroups ( CPVRChannelGroups & results) const

Get all local channel groups.

Parameters
resultsThe container to store the results in.
Returns
The number of groups loaded.

◆ GetMaxProviderId()

int CPVRDatabase::GetMaxProviderId ( ) const

Get the maximum provider id in the database.

Returns
The maximum provider id in the database

◆ GetPriority()

int CPVRDatabase::GetPriority ( const CPVRClient & client) const

Get the priority for a given client from the database.

Parameters
clientThe client.
Returns
The priority.

◆ GetSchemaVersion()

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

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

Returns
The minimal database version.

Implements CDatabase.

◆ GetTimers()

std::vector< std::shared_ptr< CPVRTimerInfoTag > > CPVRDatabase::GetTimers ( CPVRTimers & timers,
const std::vector< std::shared_ptr< CPVRClient > > & clients ) const

Get the timers.

Parameters
timersThe container for the timers.
clientsThe PVR clients the timers should be loaded for. Leave empty for all clients.
Returns
The timers.

◆ Lock()

void CPVRDatabase::Lock ( )

Lock the database.

◆ Open()

bool CPVRDatabase::Open ( )
overridevirtual

Open the database.

Returns
True if it was opened successfully, false otherwise.

Reimplemented from CDatabase.

◆ Persist() [1/5]

bool CPVRDatabase::Persist ( const CPVRClient & client)

Add or update a client entry in the database.

Parameters
clientThe client to persist.
Returns
True when persisted, false otherwise.

◆ Persist() [2/5]

bool CPVRDatabase::Persist ( CPVRChannel & channel,
bool bCommit )

Add or update a channel entry in the database.

Parameters
channelThe channel to persist.
bCommitqueue only or queue and commit
Returns
True when persisted or queued, false otherwise.

◆ Persist() [3/5]

bool CPVRDatabase::Persist ( CPVRChannelGroup & group)

Add or update a channel group entry in the database.

Parameters
groupThe group to persist.
Returns
True if the group was persisted successfully, false otherwise.

◆ Persist() [4/5]

bool CPVRDatabase::Persist ( CPVRProvider & provider,
bool updateRecord = false )

Add or update a provider entry in the database.

Parameters
providerThe provider to persist.
updateRecordTrue if record to be updated, false for insert
Returns
True when persisted, false otherwise.

◆ Persist() [5/5]

bool CPVRDatabase::Persist ( CPVRTimerInfoTag & timer)

Add or update a timer entry in the database.

Parameters
channelThe timer to persist.
Returns
True if persisted, false otherwise.

◆ QueueDeleteQuery() [1/2]

bool CPVRDatabase::QueueDeleteQuery ( const CPVRChannel & channel)

Remove a channel entry from the database.

Parameters
channelThe channel to remove.
Returns
True if the channel was removed, false otherwise.

◆ QueueDeleteQuery() [2/2]

bool CPVRDatabase::QueueDeleteQuery ( const CPVRChannelGroupMember & groupMember)

Remove a channel group member entry from the database.

Parameters
groupMemberThe group member to remove.
Returns
True if the member was removed, false otherwise.

◆ ResetEPG()

bool CPVRDatabase::ResetEPG ( )

Reset all epg ids to 0.

Returns
True when reset, false otherwise.

◆ Unlock()

void CPVRDatabase::Unlock ( )

Unlock the database.

◆ UpdateLastOpened()

bool CPVRDatabase::UpdateLastOpened ( const CPVRChannelGroup & group)

Updates the last opened timestamp for the channel group.

Parameters
groupthe group
Returns
whether the update was successful

◆ UpdateLastWatched() [1/2]

bool CPVRDatabase::UpdateLastWatched ( const CPVRChannel & channel,
int groupId )

Updates the last watched timestamp for the channel.

Parameters
channelthe channel
groupIdthe id of the group used to watch the channel
Returns
whether the update was successful

◆ UpdateLastWatched() [2/2]

bool CPVRDatabase::UpdateLastWatched ( const CPVRChannelGroup & group)

Updates the last watched timestamp for the channel group.

Parameters
groupthe group
Returns
whether the update was successful

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