GDBMS 1.0
Public Member Functions | Protected Member Functions | Protected Attributes
hash_table Class Reference

#include <hash_table.h>

Inheritance diagram for hash_table:
tr_twin_ht

List of all members.

Public Member Functions

 hash_table (char *table_name, char *folder_name, int columns_nr, char *columns, char *columns_searchby, char *unique)
 A constructor.
 hash_table (char *table_name, char *folder_name, char *columns, char *columns_searchby, char *unique)
 A constructor.
 ~hash_table ()
 A destructor.
void AddRecord (char *column_names, char *values)
 Adds a record to the hash table..
void DeleteRecord (char *column_name, char *value)
 Deletes the first occurence of a record of column_name which has value.
void UpdateRecord (char *where_column, char *where_value, char *column_names, char *column_values)
 A record updater.
char * FindRecord (char *where_column_name, char *where_column_value, char *find_column)
 A record finder.
void FindByIdAndReturnColNamesAndValues (char *id, string &cnames, string &cvalues, char *requested_id=0)
 A record finder.
virtual int getMAXID ()
void BeginTransaction (char *folder, int id)
void EndTransaction ()
void split (char *str, int *numbers_splitted, char ***splitted)

Protected Member Functions

unsigned hash (string const &key)

Protected Attributes

std::string transaction_folder
std::string table_folder
std::string tblname
char ** colls_searchby
int n_cols_sby
int transaction_id

Detailed Description

Definition at line 1 of file hash_table.h.


Constructor & Destructor Documentation

hash_table::hash_table ( char *  table_name,
char *  folder_name,
int  columns_nr,
char *  columns,
char *  columns_searchby,
char *  unique 
)

A constructor.

Parameters:
table_namea string parameter that contains the table name.
folder_namea string parameter that contains the path to the folder of where the files of the hash table are going to be stored ot retrieved.
columns_nra number of the columns.
columnsa ; separated names of the columns of the relation.
columns_searchbya ; separated names of the columns of the relation, which will be use in search, so that indexes for them could be created
uniquethe name of the unique identifier column.

If the relation is already created, it is not created again. Only the class is properly initialized. If you want to create a new hash table in the folder, simply erase its contents and run the program with defined instance of this type and this constructor.

Definition at line 24 of file hash_table.cpp.

hash_table::hash_table ( char *  table_name,
char *  folder_name,
char *  columns,
char *  columns_searchby,
char *  unique 
)

A constructor.

Parameters:
table_namea string parameter that contains the table name.
folder_namea string parameter that contains the path to the folder of where the files of the hash table are going to be stored ot retrieved.
columnsa ; separated names of the columns of the relation.
columns_searchbya ; separated names of the columns of the relation, which will be use in search, so that indexes for them could be created
uniquethe name of the unique identifier column.

If the relation is already created, it is not created again. Only the class is properly initialized. If you want to create a new hash table in the folder, simply erase its contents and run the program with defined instance of this type and this constructor.

Definition at line 18 of file hash_table.cpp.

hash_table::~hash_table ( )

A destructor.

The destructor only destroys the instance of the class, but not the hash table.

Definition at line 153 of file hash_table.cpp.


Member Function Documentation

void hash_table::AddRecord ( char *  column_names,
char *  values 
)

Adds a record to the hash table..

Parameters:
column_namesa string parameter that contains ; separated names of the columns of the record.
valuesa string parameter that contains ; separated values of the columns of the record.

Reimplemented in tr_twin_ht.

Definition at line 182 of file hash_table.cpp.

void hash_table::BeginTransaction ( char *  folder,
int  id 
)
void hash_table::DeleteRecord ( char *  column_name,
char *  value 
)

Deletes the first occurence of a record of column_name which has value.

Parameters:
column_namea string parameter that contains the name of the column.
valuea string parameter that contains the value of the column that the record to be deleted must have

Reimplemented in tr_twin_ht.

Definition at line 417 of file hash_table.cpp.

void hash_table::EndTransaction ( )

Definition at line 939 of file hash_table.cpp.

void hash_table::FindByIdAndReturnColNamesAndValues ( char *  id,
string &  cnames,
string &  cvalues,
char *  requested_id = 0 
)

A record finder.

Parameters:
ida string parameter that contains the id of the record which is to be found
cnamesa string alias which is to be used as a return value of the column names found for the record
cvaluesa string alias which is to be used as a return value of the column values found for the record
requested_ida pointer to a string which if is not NULL changes the id field value with the value pointed by this pointer

Definition at line 897 of file hash_table.cpp.

char * hash_table::FindRecord ( char *  where_column_name,
char *  where_column_value,
char *  find_column 
)

A record finder.

Parameters:
where_column_namea string parameter that contains the name of the column by which the record to be found must be searched.
where_column_valuea string parameter that contains the value which determines the record to be found.
find_columna string parameter that contains the name of the column which value is to be returned

Reimplemented in tr_twin_ht.

Definition at line 606 of file hash_table.cpp.

int hash_table::getMAXID ( ) [virtual]

Reimplemented in tr_twin_ht.

Definition at line 845 of file hash_table.cpp.

unsigned int hash_table::hash ( string const &  key) [protected]

Definition at line 166 of file hash_table.cpp.

void hash_table::split ( char *  str,
int *  numbers_splitted,
char ***  splitted 
)
void hash_table::UpdateRecord ( char *  where_column,
char *  where_value,
char *  column_names,
char *  column_values 
)

A record updater.

Parameters:
where_columna string parameter that contains the name of the column by which the record to be updated must be searched.
where_valuea string parameter that contains the value which determines the record to be updated.
column_namesa string parameter that contains ; separated names of the update fields
column_valuesa string parameter that contains ; separated values of the update fields

Reimplemented in tr_twin_ht.

Definition at line 718 of file hash_table.cpp.


Member Data Documentation

char** hash_table::colls_searchby [protected]

Definition at line 142 of file hash_table.h.

int hash_table::n_cols_sby [protected]

Definition at line 143 of file hash_table.h.

std::string hash_table::table_folder [protected]

Definition at line 140 of file hash_table.h.

std::string hash_table::tblname [protected]

Definition at line 141 of file hash_table.h.

std::string hash_table::transaction_folder [protected]

Definition at line 139 of file hash_table.h.

int hash_table::transaction_id [protected]

Definition at line 145 of file hash_table.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines