Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

hk_database Class Reference

represents a particular database on the SQL Server More...

#include <hk_database.h>

Inheritance diagram for hk_database:

hk_class List of all members.

Public Types

enum  enum_storage { st_overwrite, st_storechanges }
enum  enum_storagemode { central, local }

Public Member Functions

virtual ~hk_database ()
virtual bool set_name (const hk_string &n)
hk_string name (void)
vector< hk_string > * tablelist (bool with_systemtable=false)
vector< hk_string > * viewlist ()
vector< hk_string > * tableviewlist (bool with_systemtable=false)
vector< hk_string > * querylist (void)
vector< hk_string > * formlist (void)
vector< hk_string > * reportlist (void)
hk_datasourcenew_table (const hk_string &name="", hk_presentation *p=NULL)
hk_datasourcenew_resultquery (hk_presentation *p=NULL)
hk_actionquerynew_actionquery (void)
hk_datasourcenew_view (const hk_string &name="", hk_presentation *p=NULL)
hk_datasourceload_datasource (const hk_string &name, datasourcetype dt=dt_table, hk_presentation *p=NULL)
virtual bool delete_table (const hk_string &table, enum_interaction x=interactive)
virtual bool delete_view (const hk_string &view, enum_interaction x=interactive)
bool table_exists (const hk_string &tablename)
bool view_exists (const hk_string &viewname)
bool query_exists (const hk_string &queryname)
bool form_exists (const hk_string &formname)
bool report_exists (const hk_string &reportname)
hk_connectionconnection (void) const
ofstream * savestream (const hk_string &name, filetype type, bool ask_before_overwrite=true)
ofstream * savestream (const hk_string &name, filetype type, bool ask_before_overwrite, bool with_header, bool ask_for_new_name=false)
ofstream * savestream (enum_storage storage, const hk_string &name, filetype type, bool ask_before_overwrite, bool with_header, bool ask_for_new_name)
STRINGSTREAM * savestringstream (filetype type)
STRINGSTREAM * savestringstream (filetype type, bool with_header)
bool delete_file (const hk_string &name, filetype type, enum_interaction x=interactive)
hk_presentationexisting_presentation (const hk_string &name, hk_presentation::enum_presentationtype t)
hk_formexisting_form (const hk_string name)
hk_reportexisting_report (const hk_string name)
void save (const hk_string &statement, const hk_string &name, filetype type, bool ask_before_overwrite=true, bool ask_for_new_name=false)
void save (enum_storage storage, const hk_string &statement, const hk_string &name, filetype type, bool ask_before_overwrite=true, bool ask_for_new_name=false)
hk_string load (const hk_string &name, filetype type)
hk_string database_path (void)
hk_string fileendings (filetype e)
hk_string fileendings (objecttype e)
bool copy_table (hk_datasource *fromdatasource, bool schema_and_data, bool replacetable, bool ask, progress_dialogtype *progressdialog=NULL)
bool copy_view (hk_datasource *fromdatasource, progress_dialogtype *progressdialog=NULL, const hk_string &newname="")
hk_formnew_formvisible (void)
hk_formnew_dialogformvisible (void)
hk_reportnew_reportvisible (void)
hk_dstable * new_tablevisible (void)
hk_dsquery * new_queryvisible (void)
void set_usewidgetparent (hk_class *)
bool rename_table (const hk_string &originalname, const hk_string &newname, enum_interaction x=interactive)
bool rename_file (const hk_string &originalname, const hk_string &newname, filetype type, enum_interaction x=interactive)
void disable (void)
bool store_connectionfile (const hk_url &url, bool store_password=false)
void set_storagemode (filetype, enum_storagemode load, enum_storagemode store)
enum_storagemode storagemode (filetype)
enum_storagemode loadmode (filetype)
bool create_centralstoragetable (void)
bool has_centralstoragetable (void)
hk_string load_local (const hk_string &name, filetype type)
hk_string load_central (const hk_string &name, filetype type)
void save_local (enum_storage storage, const hk_string &statement, const hk_string &name, filetype type, bool ask_before_overwrite, bool ask_for_new_name)
void save_local (const hk_string &statement, const hk_string &name, filetype type, bool ask_before_overwrite, bool ask_for_new_name)
void save_central (const hk_string &statement, const hk_string &name, filetype type, bool ask_before_overwrite, bool ask_for_new_name)
void save_central (enum_storage storage, const hk_string &statement, const hk_string &name, filetype type, bool ask_before_overwrite, bool ask_for_new_name)
bool delete_localfile (const hk_string &name, filetype type, enum_interaction x=interactive)
bool delete_centralfile (const hk_string &name, filetype type, enum_interaction x=interactive)
vector< hk_string > * filelist (filetype type)
vector< hk_string > * local_filelist (filetype type)
vector< hk_string > * central_filelist (filetype type)
void save_configuration (void)
list< hk_presentation * > * presentationlist () const
void set_databasecharset (const hk_string &charset)
hk_string databasecharset (void) const
void set_automatic_data_update (bool u)
bool is_automatic_data_update (void)

Static Public Member Functions

static void set_new_formvisiblefunction (newform_type *)
static void set_new_dialogformvisiblefunction (newform_type *)
static void set_new_reportvisiblefunction (newreport_type *)
static void set_new_tablevisiblefunction (newtable_type *)
static void set_new_queryvisiblefunction (newquery_type *)

Protected Member Functions

 hk_database (hk_connection *c)
bool select_db (const hk_string &newname)
void inform_datasources_before_closing (void)
virtual void driver_specific_tablelist (void)
virtual void driver_specific_viewlist (void)
virtual hk_datasourcedriver_specific_new_table (hk_presentation *p)
virtual hk_datasourcedriver_specific_new_view (hk_presentation *p)
virtual hk_datasourcedriver_specific_new_resultquery (hk_presentation *p)
virtual hk_actionquerydriver_specific_new_actionquery (void)
virtual bool driver_specific_rename_table (const hk_string &oldname, const hk_string &newname)
virtual bool driver_specific_select_db (void)
virtual void driver_specific_set_name (void)
void ds_remove (hk_data *ds)
virtual void connection_connected (void)
virtual void connection_disconnected (void)
void dbvisible_add (hk_dbvisible *v)
void dbvisible_remove (hk_dbvisible *v)
void clear_visiblelist (void)
virtual void before_source_vanishes (void)
void presentation_add (hk_presentation *p)
void presentation_remove (hk_presentation *p)
void load_configuration (void)
virtual void savedata (ostream &s)
virtual void loaddata (const hk_string &definition)
void inform_datasources_filelist_changes (listtype type)

Protected Attributes

hk_connectionp_connection
vector< hk_stringp_tablelist
vector< hk_stringp_viewlist
vector< hk_stringp_tableviewlist
hk_url p_url

Friends

class hk_datasource
class hk_actionquery
class hk_connection
class hk_dbvisible
class hk_presentation

Detailed Description

represents a particular database on the SQL Server

Version:
Revision
1.61
Author:
Horst Knorr (hk_classes@knoda.org)
represents a particular existing database on the SQL Server. To use it set the name of an existing database with set_name To create a new database use hk_connection::create_database.


Member Enumeration Documentation

enum hk_database::enum_storage
 

Enumeration values:
st_overwrite 
st_storechanges 

enum hk_database::enum_storagemode
 

Enumeration values:
central 
local 


Constructor & Destructor Documentation

virtual hk_database::~hk_database  )  [virtual]
 

hk_database::hk_database hk_connection c  )  [protected]
 


Member Function Documentation

virtual void hk_database::before_source_vanishes void   )  [protected, virtual]
 

vector<hk_string>* hk_database::central_filelist filetype  type  ) 
 

void hk_database::clear_visiblelist void   )  [protected]
 

hk_connection* hk_database::connection void   )  const [inline]
 

Returns:
the parent connection

virtual void hk_database::connection_connected void   )  [protected, virtual]
 

virtual void hk_database::connection_disconnected void   )  [protected, virtual]
 

bool hk_database::copy_table hk_datasource fromdatasource,
bool  schema_and_data,
bool  replacetable,
bool  ask,
progress_dialogtype progressdialog = NULL
 

creates a new table and uses an existing datasource as a template

Parameters:
fromdatasource the datasource which is used as a template
schema_and_data if true the table will be created and the data copied, if false the data will be not copied
replacetable see parameter ask for details
ask ask=true and replacetable=true => you will be warned before overwriting an old table ask=true and replacetable=false => a new name will be asked ask=false and replacetable=true => an old table will be overwritten without warning ask=false and replacetable=false => copy_table immediately stops and returns false, if a table already exists

bool hk_database::copy_view hk_datasource fromdatasource,
progress_dialogtype progressdialog = NULL,
const hk_string newname = ""
 

bool hk_database::create_centralstoragetable void   ) 
 

hk_string hk_database::database_path void   ) 
 

returns the path where hk_classes stores forms, queries, and reports usually ~/.hk_classes/dbdriver/host/dbname

hk_string hk_database::databasecharset void   )  const
 

void hk_database::dbvisible_add hk_dbvisible v  )  [protected]
 

void hk_database::dbvisible_remove hk_dbvisible v  )  [protected]
 

bool hk_database::delete_centralfile const hk_string name,
filetype  type,
enum_interaction  x = interactive
 

bool hk_database::delete_file const hk_string name,
filetype  type,
enum_interaction  x = interactive
 

deletes a file physically. Usually you don't have to use this function

Parameters:
name name of the file
type type of the file (i.e. query or form)
Returns:
true if successful else false

bool hk_database::delete_localfile const hk_string name,
filetype  type,
enum_interaction  x = interactive
 

virtual bool hk_database::delete_table const hk_string table,
enum_interaction  x = interactive
[virtual]
 

removes a table from the database and deletes all data.

virtual bool hk_database::delete_view const hk_string view,
enum_interaction  x = interactive
[virtual]
 

void hk_database::disable void   ) 
 

informs the datasources and visible objects that the database shuts down and sets the database name to ""

virtual hk_actionquery* hk_database::driver_specific_new_actionquery void   )  [inline, protected, virtual]
 

virtual hk_datasource* hk_database::driver_specific_new_resultquery hk_presentation p  )  [protected, virtual]
 

virtual hk_datasource* hk_database::driver_specific_new_table hk_presentation p  )  [protected, virtual]
 

virtual hk_datasource* hk_database::driver_specific_new_view hk_presentation p  )  [protected, virtual]
 

virtual bool hk_database::driver_specific_rename_table const hk_string oldname,
const hk_string newname
[inline, protected, virtual]
 

virtual bool hk_database::driver_specific_select_db void   )  [inline, protected, virtual]
 

virtual void hk_database::driver_specific_set_name void   )  [inline, protected, virtual]
 

virtual void hk_database::driver_specific_tablelist void   )  [inline, protected, virtual]
 

driver_specific_tablelist has to set the protected variable p_tablelist

virtual void hk_database::driver_specific_viewlist void   )  [inline, protected, virtual]
 

void hk_database::ds_remove hk_data ds  )  [protected]
 

hk_form* hk_database::existing_form const hk_string  name  ) 
 

hk_presentation* hk_database::existing_presentation const hk_string name,
hk_presentation::enum_presentationtype  t
 

looks whether there is a already created hk_presentation object (form or report) usefull if you need a handle to an already opened form

Parameters:
name name of the presentation
t type of the presentation( form or report)
Returns:
the object if existing else NULL

hk_report* hk_database::existing_report const hk_string  name  ) 
 

hk_string hk_database::fileendings objecttype  e  ) 
 

hk_string hk_database::fileendings filetype  e  ) 
 

vector<hk_string>* hk_database::filelist filetype  type  ) 
 

bool hk_database::form_exists const hk_string formname  ) 
 

vector<hk_string>* hk_database::formlist void   ) 
 

Returns:
a list of the names of all existing form in this database

bool hk_database::has_centralstoragetable void   ) 
 

void hk_database::inform_datasources_before_closing void   )  [protected]
 

void hk_database::inform_datasources_filelist_changes listtype  type  )  [protected]
 

bool hk_database::is_automatic_data_update void   ) 
 

hk_string hk_database::load const hk_string name,
filetype  type
 

load physically from a file. Usually you don't have to use this function

Parameters:
name the name of the file
type the type of the file (i.e. form or query)
Returns:
the content of the file

hk_string hk_database::load_central const hk_string name,
filetype  type
 

void hk_database::load_configuration void   )  [protected]
 

hk_datasource* hk_database::load_datasource const hk_string name,
datasourcetype  dt = dt_table,
hk_presentation p = NULL
 

loads an existing table or resultquery

Parameters:
name name of the query or table
query if true this function tries to load a query with the name "name" else a table
p <internal use="" only=""> if this datasource is part of a form or a report this is the pointer to this hk_presentation object
Returns:
a datasource (either a table or a resultquery) if successful else NULL

hk_string hk_database::load_local const hk_string name,
filetype  type
 

virtual void hk_database::loaddata const hk_string definition  )  [protected, virtual]
 

loads the object's values out of the definition string. Especially used to load queries, forms and reports

Reimplemented from hk_class.

enum_storagemode hk_database::loadmode filetype   ) 
 

vector<hk_string>* hk_database::local_filelist filetype  type  ) 
 

hk_string hk_database::name void   ) 
 

hk_actionquery* hk_database::new_actionquery void   ) 
 

If you want to work with your own ddl queries, create a hk_action element with this function. A ddlquery (ddl= Data Definition Language) allows you to execute all non-SELECT queries (i.e. UPDATE, INSERT queries). This type of query has no result.

hk_form* hk_database::new_dialogformvisible void   ) 
 

hk_form* hk_database::new_formvisible void   ) 
 

hk_dsquery* hk_database::new_queryvisible void   ) 
 

hk_report* hk_database::new_reportvisible void   ) 
 

hk_datasource* hk_database::new_resultquery hk_presentation p = NULL  ) 
 

if you want to work with your own dmlquery ( a SELECT ... statement), create a hk_datasource element with this function (dml= data manipulation language). All Select queries are possible (i.e. GROUP BY). The resulting data cant be edited.

hk_datasource* hk_database::new_table const hk_string name = "",
hk_presentation p = NULL
 

if you want to work with a particular table, create a hk_datasource element with this function. In a table, the data can be edited.

hk_dstable* hk_database::new_tablevisible void   ) 
 

hk_datasource* hk_database::new_view const hk_string name = "",
hk_presentation p = NULL
 

void hk_database::presentation_add hk_presentation p  )  [protected]
 

void hk_database::presentation_remove hk_presentation p  )  [protected]
 

list<hk_presentation*>* hk_database::presentationlist  )  const
 

bool hk_database::query_exists const hk_string queryname  ) 
 

vector<hk_string>* hk_database::querylist void   ) 
 

Returns:
a list of the names of all existing queries in this database

bool hk_database::rename_file const hk_string originalname,
const hk_string newname,
filetype  type,
enum_interaction  x = interactive
 

renames files (queries, forms and reports) and also handles table renaming

Parameters:
originaltable old name of the table
newname new name of the tbale,
filetype the type of file, see hk_definitions::filetype for details
x if set to interactive warningmessages wil be displayed in case of an error

bool hk_database::rename_table const hk_string originalname,
const hk_string newname,
enum_interaction  x = interactive
 

renames the table

Parameters:
originaltable old name of the table
newname new name of the tbale,
x if set to interactive warningmessages wil be displayed in case of an error

bool hk_database::report_exists const hk_string reportname  ) 
 

vector<hk_string>* hk_database::reportlist void   ) 
 

Returns:
a list of the names of all existing reports in this database

void hk_database::save enum_storage  storage,
const hk_string statement,
const hk_string name,
filetype  type,
bool  ask_before_overwrite = true,
bool  ask_for_new_name = false
 

void hk_database::save const hk_string statement,
const hk_string name,
filetype  type,
bool  ask_before_overwrite = true,
bool  ask_for_new_name = false
 

save physically in a file. Usually you don't have to use this function

Parameters:
statement the content to store
name the name of the file
type the type of the file (i.e. form or query)

void hk_database::save_central enum_storage  storage,
const hk_string statement,
const hk_string name,
filetype  type,
bool  ask_before_overwrite,
bool  ask_for_new_name
 

void hk_database::save_central const hk_string statement,
const hk_string name,
filetype  type,
bool  ask_before_overwrite,
bool  ask_for_new_name
 

void hk_database::save_configuration void   ) 
 

void hk_database::save_local const hk_string statement,
const hk_string name,
filetype  type,
bool  ask_before_overwrite,
bool  ask_for_new_name
 

void hk_database::save_local enum_storage  storage,
const hk_string statement,
const hk_string name,
filetype  type,
bool  ask_before_overwrite,
bool  ask_for_new_name
 

virtual void hk_database::savedata ostream &  s  )  [protected, virtual]
 

stores the object's values to stream s. Especially used to store queries, forms and reports

Reimplemented from hk_class.

ofstream* hk_database::savestream enum_storage  storage,
const hk_string name,
filetype  type,
bool  ask_before_overwrite,
bool  with_header,
bool  ask_for_new_name
 

ofstream* hk_database::savestream const hk_string name,
filetype  type,
bool  ask_before_overwrite,
bool  with_header,
bool  ask_for_new_name = false
 

ofstream* hk_database::savestream const hk_string name,
filetype  type,
bool  ask_before_overwrite = true
 

creates a stream object to store a file. Usually you don't have to use this function

Parameters:
name the name of the file
type the type of the file (i.e. query or form)
ask_before_overwrite if true and a file of this type and this name already exists you will be asked whether or not to overwrite this file
Returns:
the stream if successful else NULL

STRINGSTREAM* hk_database::savestringstream filetype  type,
bool  with_header
 

STRINGSTREAM* hk_database::savestringstream filetype  type  ) 
 

bool hk_database::select_db const hk_string newname  )  [protected]
 

void hk_database::set_automatic_data_update bool  u  ) 
 

void hk_database::set_databasecharset const hk_string charset  ) 
 

virtual bool hk_database::set_name const hk_string n  )  [virtual]
 

name of the database.

static void hk_database::set_new_dialogformvisiblefunction newform_type *   )  [static]
 

static void hk_database::set_new_formvisiblefunction newform_type *   )  [static]
 

static void hk_database::set_new_queryvisiblefunction newquery_type  )  [static]
 

static void hk_database::set_new_reportvisiblefunction newreport_type  )  [static]
 

static void hk_database::set_new_tablevisiblefunction newtable_type  )  [static]
 

void hk_database::set_storagemode filetype  ,
enum_storagemode  load,
enum_storagemode  store
 

void hk_database::set_usewidgetparent hk_class  ) 
 

enum_storagemode hk_database::storagemode filetype   ) 
 

bool hk_database::store_connectionfile const hk_url &  url,
bool  store_password = false
 

bool hk_database::table_exists const hk_string tablename  ) 
 

checks whether a table exists

vector<hk_string>* hk_database::tablelist bool  with_systemtable = false  ) 
 

if hk_connection is connected, the tablelist shows all existing tables in this database after you set the name of an existing database with set_name. The list will be created new every time you call this function. So be careful. Never use i.e. for_each(tablelist()->begin(),tablelist()->end(),anyfunction) Use instead: vector<hk_string>* mylist=tablelist(); for_each(mylist->begin(),mylist->end(),anyfunction)

vector<hk_string>* hk_database::tableviewlist bool  with_systemtable = false  ) 
 

bool hk_database::view_exists const hk_string viewname  ) 
 

vector<hk_string>* hk_database::viewlist  ) 
 


Friends And Related Function Documentation

friend class hk_actionquery [friend]
 

friend class hk_connection [friend]
 

friend class hk_datasource [friend]
 

friend class hk_dbvisible [friend]
 

friend class hk_presentation [friend]
 


Member Data Documentation

hk_connection* hk_database::p_connection [protected]
 

vector<hk_string> hk_database::p_tablelist [protected]
 

vector<hk_string> hk_database::p_tableviewlist [protected]
 

hk_url hk_database::p_url [protected]
 

vector<hk_string> hk_database::p_viewlist [protected]
 


The documentation for this class was generated from the following file:
Generated on Thu Mar 9 18:40:41 2006 for hk_classes by  doxygen 1.4.1