Software and Services, Portable Libraries  2019.Mar.01
A library for managing digital certificates
SoftwareAndServices::Library::Database::SqlAggregate Class Referenceabstract

The pure virtual methods are implemented in derived objects, where vendor specific code must be written. More...

#include <SaS/Sql/SqlAggregate.hpp>

+ Inheritance diagram for SoftwareAndServices::Library::Database::SqlAggregate:
+ Collaboration diagram for SoftwareAndServices::Library::Database::SqlAggregate:

Public Member Functions

 SqlAggregate (SQL &Db)
 SqlAggregate - Default Constructor. More...
 
virtual ~SqlAggregate ()
 SqlAggregate - Destructor. More...
 
virtual bool Add (SqlSchema &Schema, const char *AggName, std::vector< SQL::SqlDataType_e > &Args, const char *Desc, SQL::SqlDataType_e Returns)=0
 Add an Aggregate. More...
 
const std::vector< SQL::SqlDataType_e > * Args () const
 What arguments does this aggregate take? More...
 
virtual bool Create ()=0
 Call the database and create the aggregate as described in this object. More...
 
virtual InstanceCount_t decInstance () const
 Decrement the instance. More...
 
const char * Description () const
 Get the name of this aggregate, or NULL when not set. More...
 
virtual bool Description (const char *ADesc)=0
 Set the description of this aggregate in the SQL database. More...
 
virtual bool Drop ()=0
 Drop this aggregate from the database. More...
 
virtual InstanceCount_t getInstance () const
 
virtual InstanceCount_t incInstance () const
 Increment the instance. More...
 
const char * Name () const
 Get the name of this aggregate, or NULL when not set. More...
 
virtual bool Name (const char *NewName)=0
 Rename the name of this aggregate. More...
 
void operator delete (void *ToFree)
 
SQL::SqlDataType_e Returns () const
 What does this aggregate return? More...
 
SqlSchemaSchema () const
 Get the schema for this aggregate. More...
 

Static Public Member Functions

static const std::pair< std::multimap< const char *, SqlAggregate *, CStringCompareOperator >::iterator, std::multimap< const char *, SqlAggregate *, CStringCompareOperator >::iterator > Find (const char *ToFind)
 Find the named AGGREGATE. More...
 
static uint64_t GetAll (std::multimap< const char *, SqlAggregate *, CStringCompareOperator > &Results)
 Get all SqlAggregate objects. More...
 

Protected Attributes

std::vector< SQL::SqlDataType_e > * _Args
 Argments it takes. More...
 
const char * _Description
 Description. More...
 
const char * _Name
 Aggregate Name. More...
 
SQL::SqlDataType_e _Returns
 What the aggregate returns. More...
 
SqlSchema_Schema
 The schema. More...
 
SQL_Sql
 The controling SQL object. More...
 

Static Protected Attributes

static std::multimap< const char *, SqlAggregate *, CStringCompareOperator > * _All
 All Aggregates. More...
 
static pthread_mutex_t _Once
 

Detailed Description

The pure virtual methods are implemented in derived objects, where vendor specific code must be written.

The non pure virtual methods simply return the data in the object.

Defaults to: NOSUPERUSER, NOCREATEDB, NOCREATEAGGREGATE, NOINHERIT, NOLOGIN, NOREPLICATION, NOBYPASSRLS, CONNECTION LIMIT = -1 (no limit), VALID forever, not in any aggregates, and not ADMIN of any aggregate.

Note
Many of these methods will return true if the AGGREGATE object is being created and does not exist yet in the database. If there is an error, it will show up during CreateAggregate().
See the implementation specific objects for any limits or issues with an implementation.
See also
PG_SqlAggregate
MYSQL_SqlAggregate

Definition at line 78 of file SqlAggregate.hpp.

Constructor & Destructor Documentation

◆ SqlAggregate()

SoftwareAndServices::Library::Database::SqlAggregate::SqlAggregate ( SQL Db)

SqlAggregate - Default Constructor.

Note
This creates an object. To create a aggregate in the database, first create this object, setup all of the parameters by calling the methods in this object. Then call CreateAggregate() to create the AGGREGATE in the database.
If you want an SqlAggregate object for a AGGREGATE that already exists in the database, call the static method SqlAggregate::Find(const char*) to locate the existing SqlAggregate object.
If you do not know if the aggregate exists, you can call SqlAggregate::Find() and when it returns NULL you will know that no such aggregate exists in the database, or that the currently authenticated SQL user does not have access to find out.
Parameters
DbThe controlling SQL object.

◆ ~SqlAggregate()

virtual SoftwareAndServices::Library::Database::SqlAggregate::~SqlAggregate ( )
virtual

SqlAggregate - Destructor.

Member Function Documentation

◆ Add()

virtual bool SoftwareAndServices::Library::Database::SqlAggregate::Add ( SqlSchema Schema,
const char *  AggName,
std::vector< SQL::SqlDataType_e > &  Args,
const char *  Desc,
SQL::SqlDataType_e  Returns 
)
pure virtual

Add an Aggregate.

Parameters
SchemaThe SQLSCHEMA of the aggregate.
AggNameThe aggregate name.
ArgsThe arguments the aggregate takes. May be an empty list.
DescThe optional description of the aggregate. When no descriptions is desired, pass in a NULL.
ReturnsWhat the aggregate returns.
Returns
true if the SQL database allowed the new aggregate to be added. Can also fail if the SQL database implementation does not support users adding aggregates.

◆ Args()

const std::vector<SQL::SqlDataType_e>* SoftwareAndServices::Library::Database::SqlAggregate::Args ( ) const

What arguments does this aggregate take?

Returns
The list of data types this aggregate returns?

◆ Create()

virtual bool SoftwareAndServices::Library::Database::SqlAggregate::Create ( )
pure virtual

Call the database and create the aggregate as described in this object.

Returns
true if the database accepted the request.

◆ decInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< SqlAggregate >::decInstance ( ) const
inlinevirtualinherited

Decrement the instance.

Returns
The instance count, after decrementing it.

Definition at line 129 of file instance.hpp.

◆ Description() [1/2]

const char* SoftwareAndServices::Library::Database::SqlAggregate::Description ( ) const

Get the name of this aggregate, or NULL when not set.

Returns
The description, or NULL when none.

◆ Description() [2/2]

virtual bool SoftwareAndServices::Library::Database::SqlAggregate::Description ( const char *  ADesc)
pure virtual

Set the description of this aggregate in the SQL database.

Parameters
ADescThe aggregate description.
Returns
true when the database accepted the description.

◆ Drop()

virtual bool SoftwareAndServices::Library::Database::SqlAggregate::Drop ( )
pure virtual

Drop this aggregate from the database.

Returns
true if the database accepted the request.

◆ Find()

static const std::pair<std::multimap<const char*, SqlAggregate*,CStringCompareOperator>::iterator, std::multimap<const char*, SqlAggregate*,CStringCompareOperator>::iterator> SoftwareAndServices::Library::Database::SqlAggregate::Find ( const char *  ToFind)
static

Find the named AGGREGATE.

This is a static method.

{.c++}
const std::pair<std::multimap<const char*,
SqlAggregate*>::iterator,
std::multimap<const char*,
SqlAggregate*>::iterator>
Range;
std::multimap<const char*, SqlAggregate*>::const_iterator it;
SqlAggregate * AggRec = NULL;
// Find all aggregates named 'max'.
//
Range = Agg.Find("max");
for (it = Range.first; it != Range.second; it++ ) {
AggRec = it.second;
...
}
Parameters
ToFindThe aggregate name to find.
Returns
The iteraters that match. If ToFind is not found, Result.begin() will equal Results.end().

◆ GetAll()

static uint64_t SoftwareAndServices::Library::Database::SqlAggregate::GetAll ( std::multimap< const char *, SqlAggregate *, CStringCompareOperator > &  Results)
static

Get all SqlAggregate objects.

Parameters
ResultsWhere to store the results. Results will be cleared of any old data and filled in with new results if needed.
Returns
The number of entries in Results.

◆ getInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< SqlAggregate >::getInstance ( ) const
inlinevirtualinherited
Returns
The current instance count.

Definition at line 118 of file instance.hpp.

◆ incInstance()

virtual InstanceCount_t SoftwareAndServices::Library::Common::instance< SqlAggregate >::incInstance ( ) const
inlinevirtualinherited

Increment the instance.

Returns
The instance value, after incrementing it.

Definition at line 109 of file instance.hpp.

◆ Name() [1/2]

const char* SoftwareAndServices::Library::Database::SqlAggregate::Name ( ) const

Get the name of this aggregate, or NULL when not set.

Returns
The aggregate name or NULL when not set. It would be an error for an aggregate to not have a name.

◆ Name() [2/2]

virtual bool SoftwareAndServices::Library::Database::SqlAggregate::Name ( const char *  NewName)
pure virtual

Rename the name of this aggregate.

The Name is being changed, implements 'ALTER AGGREGATE Name() RENAME TO NewName'

Parameters
NewNameThe AGGREGATE name to use.
Returns
true if the database accepted the change.

Also returns true if the current name is the same as AggregateName (No change).

Checks NewName against existing AGGREGATE names in the database. If NewName already exists in the database with the same arguments, this method returns false.

◆ Returns()

SQL::SqlDataType_e SoftwareAndServices::Library::Database::SqlAggregate::Returns ( ) const

What does this aggregate return?

Returns
The data type this aggregate returns.

◆ Schema()

SqlSchema* SoftwareAndServices::Library::Database::SqlAggregate::Schema ( ) const

Get the schema for this aggregate.

Member Data Documentation

◆ _All

std::multimap<const char*, SqlAggregate*, CStringCompareOperator>* SoftwareAndServices::Library::Database::SqlAggregate::_All
staticprotected

All Aggregates.

Definition at line 311 of file SqlAggregate.hpp.

◆ _Args

std::vector<SQL::SqlDataType_e>* SoftwareAndServices::Library::Database::SqlAggregate::_Args
protected

Argments it takes.

Definition at line 300 of file SqlAggregate.hpp.

◆ _Description

const char* SoftwareAndServices::Library::Database::SqlAggregate::_Description
protected

Description.

Definition at line 305 of file SqlAggregate.hpp.

◆ _Name

const char* SoftwareAndServices::Library::Database::SqlAggregate::_Name
protected

Aggregate Name.

Definition at line 290 of file SqlAggregate.hpp.

◆ _Returns

SQL::SqlDataType_e SoftwareAndServices::Library::Database::SqlAggregate::_Returns
protected

What the aggregate returns.

Definition at line 295 of file SqlAggregate.hpp.

◆ _Schema

SqlSchema* SoftwareAndServices::Library::Database::SqlAggregate::_Schema
protected

The schema.

Definition at line 285 of file SqlAggregate.hpp.

◆ _Sql

SQL& SoftwareAndServices::Library::Database::SqlAggregate::_Sql
protected

The controling SQL object.

Definition at line 280 of file SqlAggregate.hpp.


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