CONZEPT 16 C++ API
C16::Database Class Reference

Database hosted by a server. More...

#include "C16/Database.hpp"

Detailed Description

Database hosted by a server.

Classes

class  Connection
 Connection to a database. More...
 
class  Diagnosis
 Diagnosis of a database. More...
 

Public Types

enum  Status { Status::READ_ONLY = 1, Status::BACKUP = 2, Status::UPDATE = 4, Status::DIAGNOSIS = 8 }
 Status of a database. More...
 

Public Member Functions

 Database (const Client &client, const std::string &server_name, const std::string &name, const std::string &user_name, const std::string &user_password=std::string(), const std::string &server_password=std::string())
 Constructs and connects to a database. More...
 
 ~Database ()
 Disconnects from and destructs the database. More...
 
bool origin () const
 Gets if the database is the origin database. More...
 
const std::string & name () const
 Gets the name of the database. More...
 
const std::string & version () const
 Gets the version of the database. More...
 
int user_id () const
 Gets the id of the user accessing the database. More...
 
int user_number () const
 Gets the number of user accessing the database. More...
 
long int size () const
 Gets the size of the database in units of kilobytes. More...
 
long int size_free () const
 Gets the size of free space of the database in units of kilobytes. More...
 
Flags< Statusstatus () const
 Gets the status of the database. More...
 
int user_count () const
 Gets the count of users currently accessing the database. More...
 
int backup_duration_remaining () const
 Gets the remaining backup duration of the database in units of seconds. More...
 
void backup (unsigned int duration_minutes) const
 Transfers the database to backup mode. More...
 
Diagnosis::Result diagnose (const Flags< Diagnosis::Option > &options, const Diagnosis::Callback &callback=Diagnosis::Callback()) const
 Diagnoses the database. More...
 
const Serverserver () const
 Gets the server hosting the database. More...
 
const Transactionstransactions () const
 Gets the transactions performed by the user accessing the database. More...
 
Transactionstransactions ()
 Gets the transactions performed by the user accessing the database. More...
 
const Tablestables () const
 Gets the tables of the database. More...
 
const Subrecordssubrecords () const
 Gets the subrecords of the database. More...
 
const Keyskeys () const
 Gets the keys of the database. More...
 
const Linkslinks () const
 Gets the links of the database. More...
 
const Fieldsfields () const
 Gets the fields of the database. More...
 
const Textstexts () const
 Gets the texts of the database. More...
 
Textstexts ()
 Gets the texts of the database. More...
 
const Proceduresprocedures () const
 Gets the procedures of the database. More...
 
Proceduresprocedures ()
 Gets the procedures of the database. More...
 
const BinaryDirectorybinary_directory_root () const
 Gets the root binary directory of the database. More...
 
BinaryDirectorybinary_directory_root ()
 Gets the root binary directory of the database. More...
 
const Usersusers () const
 Gets the users accessing the database. More...
 
Usersusers ()
 Gets the users accessing the database. More...
 

Member Enumeration Documentation

◆ Status

enum C16::Database::Status
strong

Status of a database.

Enumerator
READ_ONLY 

Database in read-only mode.

BACKUP 

Database in backup mode.

UPDATE 

Database in update mode.

DIAGNOSIS 

Database diagnosing.

Constructor & Destructor Documentation

◆ Database()

C16::Database::Database ( const Client client,
const std::string &  server_name,
const std::string &  name,
const std::string &  user_name,
const std::string &  user_password = std::string(),
const std::string &  server_password = std::string() 
)

Constructs and connects to a database.

Parameters
clientClient to access the server
server_nameName of the server hosting the database
nameName of the database
user_nameName of the user to access the database
user_passwordPassword of the user to access the database
server_passwordPassword of the server hosting the database
Exceptions
Connection::ExceptionDatabase connection exception occurred.
Examples
using namespace C16;
void database_connect()
{
// Constructs a client.
Client client;
// Constructs and connects to a database.
Database database(client, "myserver", "mydatabase", "myuser");
...
}

◆ ~Database()

C16::Database::~Database ( )

Disconnects from and destructs the database.

Member Function Documentation

◆ origin()

bool C16::Database::origin ( ) const

Gets if the database is the origin database.

The origin database is the database where the call of DLLCall() originates from.

◆ name()

const std::string& C16::Database::name ( ) const

Gets the name of the database.

◆ version()

const std::string& C16::Database::version ( ) const

Gets the version of the database.

Returns
String representing the version of the database

The version is represented by a string of the form <major>.<minor>, where the parts in angle brackets (< ... >) contain the following data:

  • <major> – Major version of the database. An integer consisting of one digit.
  • <minor> – Minor version of the database. An integer consisting of one digit.

Examples: 5.0, 5.4, 5.8

◆ user_id()

int C16::Database::user_id ( ) const

Gets the id of the user accessing the database.

◆ user_number()

int C16::Database::user_number ( ) const

Gets the number of user accessing the database.

◆ size()

long int C16::Database::size ( ) const

Gets the size of the database in units of kilobytes.

Note
The size includes free space.

◆ size_free()

long int C16::Database::size_free ( ) const

Gets the size of free space of the database in units of kilobytes.

◆ status()

Flags<Status> C16::Database::status ( ) const

Gets the status of the database.

The status is represented by flags of the enumeration Status.

Examples
#include "C16/Library.hpp"
using namespace C16;
void database_status(const Database& database)
{
// Gets the status of the database.
// Database in backup mode.
...
}

◆ user_count()

int C16::Database::user_count ( ) const

Gets the count of users currently accessing the database.

◆ backup_duration_remaining()

int C16::Database::backup_duration_remaining ( ) const

Gets the remaining backup duration of the database in units of seconds.

Note
The remaining backup duration is zero if the database is not in backup mode.

◆ backup()

void C16::Database::backup ( unsigned int  duration_minutes) const

Transfers the database to backup mode.

Parameters
duration_minutesBackup duration in units of minutes

◆ diagnose()

Diagnosis::Result C16::Database::diagnose ( const Flags< Diagnosis::Option > &  options,
const Diagnosis::Callback callback = Diagnosis::Callback() 
) const

Diagnoses the database.

Parameters
optionsOptions represented by flags of the enumeration Diagnosis::Options
callbackCallback that will be called in a loop during the diagnosis
Returns
Result of the diagnosis
Exceptions
Exception::UnavailabilityDatabase diagnosis unavailable.
Database diagnosis is unavailable for the origin database.
Note
Database diagnosis is unavailable for the origin database.
Examples
#include "C16/Library.hpp"
using namespace C16;
void database_diagnose(const Database& database)
{
// Diagnose database.
// Diagnose database with key analysis and recovery.
{
}
);
// Diagnose database with callback.
result = key.reorganize(
{},
[] (Database::Diagnosis::Status status, float progress) noexcept
{
...
}
);
}

◆ server()

const Server& C16::Database::server ( ) const

Gets the server hosting the database.

◆ transactions() [1/2]

const Transactions& C16::Database::transactions ( ) const

Gets the transactions performed by the user accessing the database.

◆ transactions() [2/2]

Transactions& C16::Database::transactions ( )

Gets the transactions performed by the user accessing the database.

◆ tables()

const Tables& C16::Database::tables ( ) const

Gets the tables of the database.

◆ subrecords()

const Subrecords& C16::Database::subrecords ( ) const

Gets the subrecords of the database.

◆ keys()

const Keys& C16::Database::keys ( ) const

Gets the keys of the database.

◆ links()

const Links& C16::Database::links ( ) const

Gets the links of the database.

◆ fields()

const Fields& C16::Database::fields ( ) const

Gets the fields of the database.

◆ texts() [1/2]

const Texts& C16::Database::texts ( ) const

Gets the texts of the database.

◆ texts() [2/2]

Texts& C16::Database::texts ( )

Gets the texts of the database.

◆ procedures() [1/2]

const Procedures& C16::Database::procedures ( ) const

Gets the procedures of the database.

◆ procedures() [2/2]

Procedures& C16::Database::procedures ( )

Gets the procedures of the database.

◆ binary_directory_root() [1/2]

const BinaryDirectory& C16::Database::binary_directory_root ( ) const

Gets the root binary directory of the database.

Exceptions
Exception::UnavailabilityBinary objects unavailable.
Binary objects are unavailable for the origin database.
Note
Binary objects are unavailable for the origin database.

◆ binary_directory_root() [2/2]

BinaryDirectory& C16::Database::binary_directory_root ( )

Gets the root binary directory of the database.

Exceptions
Exception::UnavailabilityBinary objects unavailable.
Binary objects are unavailable for the origin database.
Note
Binary objects are unavailable for the origin database.

◆ users() [1/2]

const Users& C16::Database::users ( ) const

Gets the users accessing the database.

◆ users() [2/2]

Users& C16::Database::users ( )

Gets the users accessing the database.

C16::Database::Diagnosis::Option::KEY_ANALYSIS
@ KEY_ANALYSIS
Option to perform a key analysis.
C16::Database::Status::BACKUP
@ BACKUP
Database in backup mode.
C16::Database::status
Flags< Status > status() const
Gets the status of the database.
C16::Database::Diagnosis::Result
Result
Result of a diagnosis of a database.
Definition: Database.hpp:359
Library.hpp
CONZEPT 16 C++ API.
C16::Flags
Set of enumerators.
Definition: Flags.hpp:15
C16::Database::diagnose
Diagnosis::Result diagnose(const Flags< Diagnosis::Option > &options, const Diagnosis::Callback &callback=Diagnosis::Callback()) const
Diagnoses the database.
LibraryApplication.hpp
CONZEPT 16 C++ API for applications.
C16::Database
Database hosted by a server.
Definition: Database.hpp:38
C16::Database::Diagnosis::Option::RECOVERY
@ RECOVERY
Option to perform a recovery.
C16::Client
Client to access a server hosting databases.
Definition: Client.hpp:21
C16
Namespace.
Definition: Array.hpp:6
C16::Database::Diagnosis::Status
Status
Status of a diagnosis of a database.
Definition: Database.hpp:338