Audacity 3.2.0
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
audacity::sqlite::AggregateFunction Class Referencefinal

A class representing an aggregate function in a SQLite database. More...

#include <Function.h>

Collaboration diagram for audacity::sqlite::AggregateFunction:
[legend]

Public Member Functions

 AggregateFunction ()=default
 
 AggregateFunction (const AggregateFunction &)=delete
 
 AggregateFunction (AggregateFunction &&) noexcept
 
AggregateFunctionoperator= (const AggregateFunction &)=delete
 
AggregateFunctionoperator= (AggregateFunction &&) noexcept
 
 ~AggregateFunction ()
 

Private Member Functions

template<typename StepFunctionType , typename FinalFunctionType >
 AggregateFunction (sqlite3 *connection, std::string name, StepFunctionType stepFunction, FinalFunctionType finalFunction)
 
void Register (std::size_t arity)
 

Static Private Member Functions

static void CallStepFunction (sqlite3_context *context, int argc, sqlite3_value **argv)
 
static void CallFinalFunction (sqlite3_context *context)
 

Private Attributes

sqlite3 * mConnection { nullptr }
 
std::string mName
 
details::SQLiteFunctorWithArgs mStepFunctor
 
details::SQLiteFunctor mFinalFunctor
 

Friends

class Connection
 

Detailed Description

A class representing an aggregate function in a SQLite database.

Definition at line 180 of file Function.h.

Constructor & Destructor Documentation

◆ AggregateFunction() [1/4]

template<typename StepFunctionType , typename FinalFunctionType >
audacity::sqlite::AggregateFunction::AggregateFunction ( sqlite3 *  connection,
std::string  name,
StepFunctionType  stepFunction,
FinalFunctionType  finalFunction 
)
inlineprivate

Definition at line 183 of file Function.h.

186 : mConnection { connection }
187 , mName { std::move(name) }
189 std::move(stepFunction)) }
190 , mFinalFunctor { details::MakeSQLiteFunctor(std::move(finalFunction)) }
191 {
192 Register(details::GetFunctionArity<StepFunctionType>());
193 }
wxString name
Definition: TagsEditor.cpp:166
details::SQLiteFunctor mFinalFunctor
Definition: Function.h:216
void Register(std::size_t arity)
Definition: Function.cpp:192
details::SQLiteFunctorWithArgs mStepFunctor
Definition: Function.h:215
auto MakeSQLiteFunctor(CallbackType callback)
Definition: Function.h:137
auto MakeSQLiteFunctorWithArgs(CallbackType callback)
Definition: Function.h:122

◆ AggregateFunction() [2/4]

audacity::sqlite::AggregateFunction::AggregateFunction ( )
default

◆ AggregateFunction() [3/4]

audacity::sqlite::AggregateFunction::AggregateFunction ( const AggregateFunction )
delete

◆ AggregateFunction() [4/4]

audacity::sqlite::AggregateFunction::AggregateFunction ( AggregateFunction &&  rhs)
noexcept

Definition at line 212 of file Function.cpp.

213{
214 *this = std::move(rhs);
215}

◆ ~AggregateFunction()

audacity::sqlite::AggregateFunction::~AggregateFunction ( )

Definition at line 227 of file Function.cpp.

228{
229 if (mConnection)
230 {
231 sqlite3_create_function (
232 mConnection, mName.c_str(), 0, SQLITE_UTF8, nullptr,
233 nullptr, nullptr, nullptr);
234 }
235}

References mConnection, and mName.

Member Function Documentation

◆ CallFinalFunction()

void audacity::sqlite::AggregateFunction::CallFinalFunction ( sqlite3_context *  context)
staticprivate

Definition at line 206 of file Function.cpp.

207{
208 auto* function = static_cast<AggregateFunction*>(sqlite3_user_data(context));
209 function->mFinalFunctor(context);
210}

References mFinalFunctor.

Referenced by Register().

Here is the caller graph for this function:

◆ CallStepFunction()

void audacity::sqlite::AggregateFunction::CallStepFunction ( sqlite3_context *  context,
int  argc,
sqlite3_value **  argv 
)
staticprivate

Definition at line 199 of file Function.cpp.

201{
202 auto* function = static_cast<AggregateFunction*>(sqlite3_user_data(context));
203 function->mStepFunctor(context, argc, argv);
204}
UTILITY_API const char *const * argv
A copy of argv; responsibility of application startup to assign it.
UTILITY_API int argc
A copy of argc; responsibility of application startup to assign it.

References CommandLineArgs::argc, CommandLineArgs::argv, and mStepFunctor.

Referenced by Register().

Here is the caller graph for this function:

◆ operator=() [1/2]

AggregateFunction & audacity::sqlite::AggregateFunction::operator= ( AggregateFunction &&  rhs)
noexcept

Definition at line 217 of file Function.cpp.

218{
219 std::swap(mConnection, rhs.mConnection);
220 std::swap(mName, rhs.mName);
221 std::swap(mStepFunctor, rhs.mStepFunctor);
222 std::swap(mFinalFunctor, rhs.mFinalFunctor);
223
224 return *this;
225}
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:634

References anonymous_namespace{NoteTrack.cpp}::swap().

Here is the call graph for this function:

◆ operator=() [2/2]

AggregateFunction & audacity::sqlite::AggregateFunction::operator= ( const AggregateFunction )
delete

◆ Register()

void audacity::sqlite::AggregateFunction::Register ( std::size_t  arity)
private

Definition at line 192 of file Function.cpp.

193{
194 sqlite3_create_function (
195 mConnection, mName.c_str(), arity, SQLITE_UTF8, this,
197}
static void CallStepFunction(sqlite3_context *context, int argc, sqlite3_value **argv)
Definition: Function.cpp:199
static void CallFinalFunction(sqlite3_context *context)
Definition: Function.cpp:206

References CallFinalFunction(), CallStepFunction(), mConnection, and mName.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ Connection

friend class Connection
friend

Definition at line 217 of file Function.h.

Member Data Documentation

◆ mConnection

sqlite3* audacity::sqlite::AggregateFunction::mConnection { nullptr }
private

Definition at line 213 of file Function.h.

Referenced by Register(), and ~AggregateFunction().

◆ mFinalFunctor

details::SQLiteFunctor audacity::sqlite::AggregateFunction::mFinalFunctor
private

Definition at line 216 of file Function.h.

Referenced by CallFinalFunction().

◆ mName

std::string audacity::sqlite::AggregateFunction::mName
private

Definition at line 214 of file Function.h.

Referenced by Register(), and ~AggregateFunction().

◆ mStepFunctor

details::SQLiteFunctorWithArgs audacity::sqlite::AggregateFunction::mStepFunctor
private

Definition at line 215 of file Function.h.

Referenced by CallStepFunction().


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