ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
GenericDbTable Class Reference

#include <GenericDbTable.h>

Inheritance diagram for GenericDbTable:
Collaboration diagram for GenericDbTable:

Classes

struct  CondDBColumn
 Definition of the columns. More...
 
struct  CondDBColumnArrayBool
 
struct  CondDBColumnArrayDouble
 
struct  CondDBColumnArrayFloat
 
struct  CondDBColumnArrayInt
 
struct  CondDBColumnArrayLong
 
struct  CondDBColumnArrayString
 
struct  CondDBColumnBool
 
struct  CondDBColumnDouble
 
struct  CondDBColumnFloat
 
struct  CondDBColumnInt
 
struct  CondDBColumnLong
 
struct  CondDBColumnString
 

Public Types

enum  dataTypes {
  kNull =0, kBool, kInt, kFloat,
  kString, kDouble, kLongLong, kArrayBool,
  kArrayFloat, kArrayInt, kArrayString, kArrayDouble,
  kArrayLongLong
}
 
enum  CondDBErrorCode {
  CDB_NOT_INITIALIZED = -1, CDB_RANGE_ERROR = -2, CDB_TYPE_ERROR = -3, CDB_SUCCESS = -4,
  CDB_ALLOC_ERROR = -5, CDB_STRTOARRAY_ERROR = -6
}
 

Public Member Functions

 GenericDbTable ()
 Default constructor. More...
 
 GenericDbTable (unsigned n_columns, int n_rows=0)
 Default constructor. More...
 
 ~GenericDbTable ()
 Object destructor. More...
 
int getNames (std::vector< std::string > &names) const
 This method gets a vector containing the names of all columns in the table. More...
 
int getTypes (std::vector< dataTypes > &types) const
 This method gets a vector containing the data types of all columns in the table. More...
 
int getNull (unsigned n_column, float &null) const
 Get Null value for column. More...
 
int getNull (unsigned n_column, long int &null) const
 
int getNull (unsigned n_column, int64 &null) const
 
int getNull (unsigned n_column, double &null) const
 
int getNull (unsigned n_column, std::string &null) const
 
int setName (unsigned n_column, const std::string &name)
 This method defines the name for a specified column. More...
 
int setType (unsigned n_column, dataTypes type)
 This method defines the data type for a specified column. More...
 
int setNull (unsigned n_column, const float &null)
 Set Null value for column. More...
 
int setNull (unsigned n_column, const long int &null)
 
int setNull (unsigned n_column, const int64 &null)
 
int setNull (unsigned n_column, const double &null)
 
int setNull (unsigned n_column, const std::string &null)
 
void Initialize (unsigned n_columns, int n_rows=0)
 This method initializes a table created by the default constructor If the table had the number of columns already defined this does nothing. More...
 
int getRow (unsigned rowNumber, std::vector< std::string > &values) const
 This method returns a vector of strings with allelements in a row In case the cell has an array the first string has the number of elements (following strings) belonging to the array. More...
 
int getRowID (std::string &pID) const
 This method returns, for a given ID, the row number. More...
 
int getCell (unsigned n_column, unsigned n_row, short int &ndata) const
 This method gets a value from a cell in a column of long ints (int in MySQL) More...
 
int getCell (unsigned n_column, unsigned n_row, long int &ndata) const
 This method gets a value from a cell in a column of long ints (int in MySQL) More...
 
int getCell (unsigned n_column, unsigned n_row, int64 &ndata) const
 This method gets a value from a cell in a column of long long ints (bigint in MySQL) More...
 
int getCell (unsigned n_column, unsigned n_row, float &ndata) const
 This method gets a value from a cell in a column of floats. More...
 
int getCell (unsigned n_column, unsigned n_row, std::string &ndata) const
 This method gets a value from a cell in a column of strings. More...
 
int getCell (unsigned n_column, unsigned n_row, double &ndata) const
 This method gets a value from a cell in a column of doubles. More...
 
int getCell (unsigned n_column, unsigned n_row, std::vector< short int > &ndata) const
 This method gets a value from a cell in a column of vectors of bools. More...
 
int getCell (unsigned n_column, unsigned n_row, std::vector< long int > &ndata) const
 This method gets a value from a cell in a column of vectors of long ints (int in MySQL - 4bytes) More...
 
int getCell (unsigned n_column, unsigned n_row, std::vector< int64 > &ndata) const
 This method gets a value from a cell in a column of vectors of long long ints (bigint in MySQL - 8bytes) More...
 
int getCell (unsigned n_column, unsigned n_row, std::vector< float > &ndata) const
 This method gets a value from a cell in a column of vectors of floats. More...
 
int getCell (unsigned n_column, unsigned n_row, std::vector< std::string > &ndata) const
 This method gets a value from a cell in a column of vector of strings. More...
 
int getCell (unsigned n_column, unsigned n_row, std::vector< double > &ndata) const
 This method gets a value from a cell in a column of vector of doubles. More...
 
int getCell (const std::string &colName, unsigned int n_row, short int &data) const
 This method get's a value from a column of floats by its name instead the column number (. More...
 
int getCell (const std::string &colName, unsigned int n_row, long int &data) const
 
int getCell (const std::string &colName, unsigned int n_row, int64 &data) const
 
int getCell (const std::string &colName, unsigned int n_row, float &data) const
 
int getCell (const std::string &colName, unsigned int n_row, double &data) const
 
int getCell (const std::string &colName, unsigned int n_row, std::string &data) const
 
int getCell (const std::string &colName, unsigned int n_row, std::vector< short int > &data) const
 
int getCell (const std::string &colName, unsigned int n_row, std::vector< long int > &data) const
 
int getCell (const std::string &colName, unsigned int n_row, std::vector< int64 > &data) const
 
int getCell (const std::string &colName, unsigned int n_row, std::vector< float > &data) const
 
int getCell (const std::string &colName, unsigned int n_row, std::vector< double > &data) const
 
int getCell (const std::string &colName, unsigned int n_row, std::vector< std::string > &data) const
 
int setCell (unsigned n_column, unsigned n_row, const short int ndata)
 set data methods More...
 
int setCell (unsigned n_column, unsigned n_row, const long int ndata)
 This method changes a value from a cell in a column of long ints. More...
 
int setCell (unsigned n_column, unsigned n_row, const int64 ndata)
 This method changes a value from a cell in a column of long long ints. More...
 
int setCell (unsigned n_column, unsigned n_row, const float ndata)
 This method changes a value from a cell in a column of floats. More...
 
int setCell (unsigned n_column, unsigned n_row, const std::string &ndata)
 This method changes a value from a cell in a column of strings. More...
 
int setCell (unsigned n_column, unsigned n_row, const double ndata)
 This method changes a value from a cell in a column of doubles. More...
 
int setCell (unsigned n_column, unsigned n_row, const std::vector< short int > &ndata)
 This method changes a value from a cell in a column of vectors of bools. More...
 
int setCell (unsigned n_column, unsigned n_row, const std::vector< long int > &ndata)
 This method changes a value from a cell in a column of vectors of long ints. More...
 
int setCell (unsigned n_column, unsigned n_row, const std::vector< int64 > &ndata)
 This method changes a value from a cell in a column of vectors of long long ints. More...
 
int setCell (unsigned n_column, unsigned n_row, const std::vector< float > &ndata)
 This method changes a value from a cell in a column of vectors of floats. More...
 
int setCell (unsigned n_column, unsigned n_row, const std::vector< std::string > &ndata)
 This method changes a value from a cell in a column of vectors of strings. More...
 
int setCell (unsigned n_column, unsigned n_row, const std::vector< double > &ndata)
 This method changes a value from a cell in a column of vectors of doubles. More...
 
int setColumndata (unsigned n_column, const std::vector< short int > &data)
 The following methods allow to insert in the columns a group of values. More...
 
int setColumndata (unsigned n_column, const std::vector< long int > &data)
 Insert a subset in a column of long ints. More...
 
int setColumndata (unsigned n_column, const std::vector< int64 > &data)
 Insert a subset in a column of long long ints. More...
 
int setColumndata (unsigned n_column, const std::vector< float > &data)
 Insert a subset in a column of floats. More...
 
int setColumndata (unsigned n_column, const std::vector< std::string > &data)
 Insert a subset in a column of strings. More...
 
int setColumndata (unsigned n_column, const std::vector< double > &data)
 Insert a subset in a column of doubles. More...
 
int setColumndata (unsigned n_column, const std::vector< std::vector< short int > > &data)
 Insert a subset in a column of vectors of bools. More...
 
int setColumndata (unsigned n_column, const std::vector< std::vector< long int > > &data)
 Insert a subset in a column of vectors of long ints. More...
 
int setColumndata (unsigned n_column, const std::vector< std::vector< int64 > > &data)
 Insert a subset in a column of vectors of long long ints. More...
 
int setColumndata (unsigned n_column, const std::vector< std::vector< float > > &data)
 Insert a subset in a column of vectors of floats. More...
 
int setColumndata (unsigned n_column, const std::vector< std::vector< std::string > > &data)
 Insert a subset in a column of vectors of strings. More...
 
int setColumndata (unsigned n_column, const std::vector< std::vector< double > > &data)
 Insert a subset in a column of vectors of doubles. More...
 
void resize (int num_rows)
 Reserves more rows on the table. More...
 
unsigned getNumRows () const
 Returns the number of rows RESERVED in the table. More...
 
unsigned getNumColumns () const
 Returns the number of columns in the table. More...
 

Private Member Functions

template<typename T , typename COLUMN >
int __getNull (T &data, COLUMN *tmpColumn) const
 Templated method for handling the null values. More...
 
template<typename T , typename COLUMN >
int __getCell (unsigned n_column, unsigned n_row, T &ndata, dataTypes type, COLUMN *tmpColumn) const
 Templated method that get's the data from a specified cell This is the method that does the real work. More...
 
template<typename T , typename COLUMN >
int __setCell (unsigned n_column, unsigned n_row, const T &ndata, dataTypes type, COLUMN *tmpColumn)
 Templated method that set's the data in a specified cell This is the method that does the real work. More...
 
template<typename T , typename COLUMN >
int __setColumnData (unsigned n_column, T &data, dataTypes type, COLUMN *tmpColumn)
 Templated method that set's portions of data in a specified column This method is deprecated and hence should not be used. More...
 
template<typename T >
int __getCellByName (const std::string &colName, unsigned int n_row, T &data) const
 Templated method that get's column data using the column name This method get's the desired column number and calls getCell(...) More...
 
void verifyInitialization ()
 Verifies if all columns are initialized. More...
 
template<class TYPE >
std::string ToString (const TYPE &t) const
 Auxiliary function to convert any value to string. More...
 

Private Attributes

bool m_isInitialized
 
std::vector< CondDBColumn * > m_conddbtable
 
unsigned m_numRows
 

Detailed Description

Definition at line 20 of file GenericDbTable.h.

Member Enumeration Documentation

◆ CondDBErrorCode

Enumerator
CDB_NOT_INITIALIZED 
CDB_RANGE_ERROR 
CDB_TYPE_ERROR 
CDB_SUCCESS 
CDB_ALLOC_ERROR 
CDB_STRTOARRAY_ERROR 

Definition at line 42 of file GenericDbTable.h.

42  {CDB_NOT_INITIALIZED = -1,
43  CDB_RANGE_ERROR = -2,
44  CDB_TYPE_ERROR = -3,
45  CDB_SUCCESS = -4,
46  CDB_ALLOC_ERROR = -5,

◆ dataTypes

Enumerator
kNull 
kBool 
kInt 
kFloat 
kString 
kDouble 
kLongLong 
kArrayBool 
kArrayFloat 
kArrayInt 
kArrayString 
kArrayDouble 
kArrayLongLong 

Definition at line 25 of file GenericDbTable.h.

25  {kNull=0,
26  kBool,
27  kInt,
28  kFloat,
29  kString,
30  kDouble,
31  kLongLong,
32  kArrayBool,
33  kArrayFloat,
34  kArrayInt,
38  };

Constructor & Destructor Documentation

◆ GenericDbTable() [1/2]

GenericDbTable::GenericDbTable ( )
inline

Default constructor.

Parameters
n_columnsis the number of columns of the table
n_rowsis the number of rows that must be reserved (OPTIONAL)

Definition at line 55 of file GenericDbTable.h.

55 {m_isInitialized = false; m_numRows=0;}

◆ GenericDbTable() [2/2]

GenericDbTable::GenericDbTable ( unsigned  n_columns,
int  n_rows = 0 
)

Default constructor.

Parameters
n_columnsis the number of columns of the table
n_rowsis the number of rows that must be reserved (OPTIONAL)

Definition at line 28 of file GenericDbTable.cxx.

28  :m_numRows(n_rows)
29 {
30 
31  m_numRows=0;
32  m_isInitialized = false;
33  unsigned i;
34 
35  for (i=0;i<n_columns; i++)
36  m_conddbtable.push_back(new CondDBColumn);
37 
38  for (i = 0; i<m_conddbtable.size(); i++ )
39  {
40  m_conddbtable[i]->initialized = false;
41  m_conddbtable[i]->type = kNull;
42  }
43 
44  if (n_rows)
45  {
46  resize(n_rows);
47  // status = vector<CondDBStatus>(n_rows,untouched);
48  }
49 }

◆ ~GenericDbTable()

GenericDbTable::~GenericDbTable ( )

Object destructor.

Definition at line 53 of file GenericDbTable.cxx.

54 {
55  for (unsigned i=0; i< m_conddbtable.size(); i++)
56  {
57  delete m_conddbtable[i];
58  }
59 }

Member Function Documentation

◆ __getCell()

template<typename T , typename COLUMN >
int GenericDbTable::__getCell ( unsigned  n_column,
unsigned  n_row,
T &  ndata,
dataTypes  type,
COLUMN *  tmpColumn 
) const
private

Templated method that get's the data from a specified cell This is the method that does the real work.

See also
getCell(...)

Definition at line 1781 of file GenericDbTable.cxx.

1782 {
1783 
1784  if (!m_isInitialized)
1785  return CDB_NOT_INITIALIZED;
1786 
1787  if ((m_numRows > n_row) && (m_conddbtable.size() > n_column))
1788  {
1789  if (m_conddbtable[n_column]->type == type)
1790  {
1791  if (tmpColumn->column.size() <= n_row)
1792  ndata = tmpColumn->column.back();
1793  else
1794  ndata = tmpColumn->column[n_row+1];
1795  }
1796 
1797  else
1798  return CDB_TYPE_ERROR;
1799  }
1800  else
1801  return CDB_RANGE_ERROR;
1802 
1803  return CDB_SUCCESS;
1804 }

◆ __getCellByName()

template<typename T >
int GenericDbTable::__getCellByName ( const std::string &  colName,
unsigned int  n_row,
T &  data 
) const
private

Templated method that get's column data using the column name This method get's the desired column number and calls getCell(...)

See also
getCell(...)

Definition at line 1870 of file GenericDbTable.cxx.

1871 {
1872  for (unsigned int i=0; i< m_conddbtable.size(); i++) {
1873  if (m_conddbtable[i]->name == colName)
1874  {
1875  return getCell(i,n_row,data);
1876  }
1877  }
1878  //if there's no column with this name return error
1879  return CDB_RANGE_ERROR;
1880 }

◆ __getNull()

template<typename T , typename COLUMN >
int GenericDbTable::__getNull ( T &  data,
COLUMN *  tmpColumn 
) const
inlineprivate

Templated method for handling the null values.

Parameters
datais the variable that will return the NULL value
tmpColumnis an auxiliary variable holding the pointer for the desired column
Returns
an error code

Definition at line 595 of file GenericDbTable.h.

596  {
597  data = tmpColumn->column[0];
598  return CDB_SUCCESS;
599  }

◆ __setCell()

template<typename T , typename COLUMN >
int GenericDbTable::__setCell ( unsigned  n_column,
unsigned  n_row,
const T &  ndata,
dataTypes  type,
COLUMN *  tmpColumn 
)
private

Templated method that set's the data in a specified cell This is the method that does the real work.

See also
setCell(...)

Definition at line 1807 of file GenericDbTable.cxx.

1808  {
1809  if (!m_isInitialized)
1810  return CDB_NOT_INITIALIZED;
1811 
1812  if ((m_numRows > n_row) && (m_conddbtable.size() > n_column))
1813  {
1814  if (m_conddbtable[n_column]->type == type)
1815  {
1816  // static_cast<COLUMN*>(m_conddbtable[n_column])->column[n_row+1] = ndata;
1817  if (tmpColumn->column.size() == (n_row+1))
1818  tmpColumn->column.push_back(ndata);
1819  else
1820  if (tmpColumn->column.size() < (n_row+1))
1821  {
1822  T tmp = tmpColumn->column.back();
1823 
1824  while((n_row)-tmpColumn->column.size())
1825  {
1826  tmpColumn->column.push_back(tmp);
1827  }
1828  tmpColumn->column.push_back(ndata);
1829  }
1830  else
1831  // if the cell already has a value
1832  tmpColumn->column[n_row+1] = ndata;
1833 
1834  return CDB_SUCCESS;
1835  }
1836  else
1837  return CDB_TYPE_ERROR;
1838  }
1839  else
1840  return CDB_RANGE_ERROR;
1841  }

◆ __setColumnData()

template<typename T , typename COLUMN >
int GenericDbTable::__setColumnData ( unsigned  n_column,
T &  data,
dataTypes  type,
COLUMN *  tmpColumn 
)
private

Templated method that set's portions of data in a specified column This method is deprecated and hence should not be used.

See also
setCell(...)

Definition at line 1844 of file GenericDbTable.cxx.

1845 {
1846  if (!m_isInitialized)
1847  return CDB_NOT_INITIALIZED;
1848 
1849  unsigned index = 0;
1850  if (n_column < m_conddbtable.size())
1851  {
1852  if (m_conddbtable[n_column]->type == type)
1853  {
1854  while((tmpColumn->column.size() < m_numRows+1) && (index < data.size()))
1855  {
1856  tmpColumn->column.push_back(data[index]);
1857  index++;
1858  }
1859  return index;
1860 
1861  }
1862  else
1863  return CDB_TYPE_ERROR;
1864  }
1865  else
1866  return CDB_RANGE_ERROR;
1867 }

◆ getCell() [1/24]

int GenericDbTable::getCell ( const std::string &  colName,
unsigned int  n_row,
double &  data 
) const

Definition at line 865 of file GenericDbTable.cxx.

866 {
867  return __getCellByName<double>(colName, n_row, data);
868 }

◆ getCell() [2/24]

int GenericDbTable::getCell ( const std::string &  colName,
unsigned int  n_row,
float &  data 
) const

Definition at line 861 of file GenericDbTable.cxx.

862 {
863  return __getCellByName<float>(colName,n_row,data);
864 }

◆ getCell() [3/24]

int GenericDbTable::getCell ( const std::string &  colName,
unsigned int  n_row,
int64 data 
) const

Definition at line 857 of file GenericDbTable.cxx.

858 {
859  return __getCellByName<int64>(colName, n_row, data);
860 }

◆ getCell() [4/24]

int GenericDbTable::getCell ( const std::string &  colName,
unsigned int  n_row,
long int &  data 
) const

Definition at line 853 of file GenericDbTable.cxx.

854 {
855 return __getCellByName<long int>(colName, n_row, data);
856 }

◆ getCell() [5/24]

int GenericDbTable::getCell ( const std::string &  colName,
unsigned int  n_row,
short int &  data 
) const

This method get's a value from a column of floats by its name instead the column number (.

See also
getCell(unsigned, unsigned,T&))
Parameters
colNameis the column name (
See also
getNames)
Parameters
n_rowis the row number
datais the reference for a variable that will return the value
Returns
an error code

Definition at line 848 of file GenericDbTable.cxx.

849 {
850  return __getCellByName(colName,n_row,data);
851 }

◆ getCell() [6/24]

int GenericDbTable::getCell ( const std::string &  colName,
unsigned int  n_row,
std::string &  data 
) const

Definition at line 869 of file GenericDbTable.cxx.

870 {
871  return __getCellByName<std::string>(colName, n_row, data);
872 }

◆ getCell() [7/24]

int GenericDbTable::getCell ( const std::string &  colName,
unsigned int  n_row,
std::vector< double > &  data 
) const

Definition at line 889 of file GenericDbTable.cxx.

890 {
891  return __getCellByName<std::vector<double> >(colName, n_row, data);
892 }

◆ getCell() [8/24]

int GenericDbTable::getCell ( const std::string &  colName,
unsigned int  n_row,
std::vector< float > &  data 
) const

Definition at line 885 of file GenericDbTable.cxx.

886 {
887  return __getCellByName<std::vector<float> >(colName, n_row, data);
888 }

◆ getCell() [9/24]

int GenericDbTable::getCell ( const std::string &  colName,
unsigned int  n_row,
std::vector< int64 > &  data 
) const

Definition at line 881 of file GenericDbTable.cxx.

882 {
883  return __getCellByName<std::vector<int64> >(colName, n_row, data);
884 }

◆ getCell() [10/24]

int GenericDbTable::getCell ( const std::string &  colName,
unsigned int  n_row,
std::vector< long int > &  data 
) const

Definition at line 877 of file GenericDbTable.cxx.

878 {
879  return __getCellByName<std::vector<long int> >(colName, n_row, data);
880 }

◆ getCell() [11/24]

int GenericDbTable::getCell ( const std::string &  colName,
unsigned int  n_row,
std::vector< short int > &  data 
) const

Definition at line 873 of file GenericDbTable.cxx.

874 {
875  return __getCellByName< std::vector<short int> >(colName, n_row, data);
876 }

◆ getCell() [12/24]

int GenericDbTable::getCell ( const std::string &  colName,
unsigned int  n_row,
std::vector< std::string > &  data 
) const

Definition at line 893 of file GenericDbTable.cxx.

894 {
895  return __getCellByName<std::vector<string> >(colName, n_row, data);
896 }

◆ getCell() [13/24]

int GenericDbTable::getCell ( unsigned  n_column,
unsigned  n_row,
double &  ndata 
) const

This method gets a value from a cell in a column of doubles.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the reference to the valriable where the value will be returned
Returns
an error code

Definition at line 802 of file GenericDbTable.cxx.

803 {
804  CondDBColumnDouble *tmpColumn = static_cast<CondDBColumnDouble*>(m_conddbtable[n_column]);
805  return __getCell(n_column, n_row, ndata, kDouble, tmpColumn);
806 }

◆ getCell() [14/24]

int GenericDbTable::getCell ( unsigned  n_column,
unsigned  n_row,
float &  ndata 
) const

This method gets a value from a cell in a column of floats.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the reference to the valriable where the value will be returned
Returns
an error code

Definition at line 719 of file GenericDbTable.cxx.

720 {
721  CondDBColumnFloat *tmpColumn = static_cast<CondDBColumnFloat*>(m_conddbtable[n_column]);
722  return __getCell(n_column, n_row, ndata, kFloat, tmpColumn);
723 }

◆ getCell() [15/24]

int GenericDbTable::getCell ( unsigned  n_column,
unsigned  n_row,
int64 ndata 
) const

This method gets a value from a cell in a column of long long ints (bigint in MySQL)

Parameters
n_columnis the column number
n_rowis the row number
ndatais the reference to the valriable where the value will be returned
Returns
an error code

Definition at line 712 of file GenericDbTable.cxx.

713 {
714  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
715  return __getCell(n_column, n_row, ndata, kLongLong, tmpColumn);
716 }

◆ getCell() [16/24]

int GenericDbTable::getCell ( unsigned  n_column,
unsigned  n_row,
long int &  ndata 
) const

This method gets a value from a cell in a column of long ints (int in MySQL)

Parameters
n_columnis the column number
n_rowis the row number
ndatais the reference to the valriable where the value will be returned
Returns
an error code

Definition at line 700 of file GenericDbTable.cxx.

701 {
702  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
703  return __getCell(n_column, n_row, ndata, kInt, tmpColumn);
704 }

◆ getCell() [17/24]

int GenericDbTable::getCell ( unsigned  n_column,
unsigned  n_row,
short int &  ndata 
) const

This method gets a value from a cell in a column of long ints (int in MySQL)

Parameters
n_columnis the column number
n_rowis the row number
ndatais the reference to the valriable where the value will be returned
Returns
an error code

Definition at line 706 of file GenericDbTable.cxx.

707 {
708  CondDBColumnBool *tmpColumn = static_cast<CondDBColumnBool*>(m_conddbtable[n_column]);
709  return __getCell(n_column, n_row, ndata, kBool, tmpColumn);
710 }

◆ getCell() [18/24]

int GenericDbTable::getCell ( unsigned  n_column,
unsigned  n_row,
std::string &  ndata 
) const

This method gets a value from a cell in a column of strings.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the reference to the valriable where the value will be returned
Returns
an error code

Definition at line 725 of file GenericDbTable.cxx.

726 {
727 
728  int status;
729 
730  if (!m_isInitialized)
731  return CDB_NOT_INITIALIZED;
732 
733  if ((m_numRows > n_row) && (m_conddbtable.size() > n_column))
734  {
735  if (m_conddbtable[n_column]->type == kString) {
736  CondDBColumnString *tmpColumn = static_cast<CondDBColumnString*>(m_conddbtable[n_column]);
737  return __getCell(n_column, n_row, ndata, kString, tmpColumn);
738  }
739  else {
740  switch(m_conddbtable[n_column]->type)
741  {
742  case kInt:
743  {
744  long int aux;
745  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
746  status = __getCell(n_column, n_row, aux , kInt, tmpColumn);
747  if (status == CDB_SUCCESS)
748  ndata = ToString(aux);
749  break;
750  }
751  case kBool:
752  {
753  short int aux;
754  CondDBColumnBool *tmpColumn = static_cast<CondDBColumnBool*>(m_conddbtable[n_column]);
755  status = __getCell(n_column, n_row, aux, kBool, tmpColumn);
756  if (status == CDB_SUCCESS)
757  ndata = ToString(aux);
758  break;
759  }
760 
761  case kLongLong:
762  {
763  long long aux;
764  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
765  status = __getCell(n_column,n_row, aux, kLongLong, tmpColumn);
766  if (status == CDB_SUCCESS)
767  ndata = ToString(aux);
768  break;
769  }
770  case kFloat:
771  {
772  float aux;
773 
774  CondDBColumnFloat *tmpColumn = static_cast<CondDBColumnFloat*>(m_conddbtable[n_column]);
775  status = __getCell(n_column,n_row, aux, kFloat, tmpColumn);
776  if (status == CDB_SUCCESS)
777  ndata = ToString(aux);
778  break;
779  }
780  case kDouble:
781  {
782  double aux;
783  CondDBColumnDouble *tmpColumn = static_cast<CondDBColumnDouble*>(m_conddbtable[n_column]);
784  status = __getCell(n_column,n_row,aux,kDouble, tmpColumn);
785  if (status == CDB_SUCCESS)
786  ndata = ToString(aux);
787  break;
788  }
789  //if the column is of the type array of *type* one should use the method with vector of strings
790  default:
791  return CDB_STRTOARRAY_ERROR;
792  }
793  }
794  }
795  else
796  return CDB_RANGE_ERROR;
797 
798  return status;
799 
800 }

◆ getCell() [19/24]

int GenericDbTable::getCell ( unsigned  n_column,
unsigned  n_row,
std::vector< double > &  ndata 
) const

This method gets a value from a cell in a column of vector of doubles.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the reference to the valriable where the value will be returned
Returns
an error code

◆ getCell() [20/24]

int GenericDbTable::getCell ( unsigned  n_column,
unsigned  n_row,
std::vector< float > &  ndata 
) const

This method gets a value from a cell in a column of vectors of floats.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the reference to the valriable where the value will be returned
Returns
an error code

◆ getCell() [21/24]

int GenericDbTable::getCell ( unsigned  n_column,
unsigned  n_row,
std::vector< int64 > &  ndata 
) const

This method gets a value from a cell in a column of vectors of long long ints (bigint in MySQL - 8bytes)

Parameters
n_columnis the column number
n_rowis the row number
ndatais the reference to the valriable where the value will be returned
Returns
an error code

Definition at line 820 of file GenericDbTable.cxx.

821 {
822  CondDBColumnArrayLong *tmpColumn = static_cast<CondDBColumnArrayLong*>(m_conddbtable[n_column]);
823  return __getCell(n_column, n_row, ndata, kArrayLongLong, tmpColumn);
824 }

◆ getCell() [22/24]

int GenericDbTable::getCell ( unsigned  n_column,
unsigned  n_row,
std::vector< long int > &  ndata 
) const

This method gets a value from a cell in a column of vectors of long ints (int in MySQL - 4bytes)

Parameters
n_columnis the column number
n_rowis the row number
ndatais the reference to the valriable where the value will be returned
Returns
an error code

Definition at line 808 of file GenericDbTable.cxx.

809 {
810  CondDBColumnArrayInt *tmpColumn = static_cast<CondDBColumnArrayInt*>(m_conddbtable[n_column]);
811  return __getCell(n_column, n_row, ndata, kArrayInt, tmpColumn);
812 }

◆ getCell() [23/24]

int GenericDbTable::getCell ( unsigned  n_column,
unsigned  n_row,
std::vector< short int > &  ndata 
) const

This method gets a value from a cell in a column of vectors of bools.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the reference to the valriable where the value will be returned
Returns
an error code

Definition at line 814 of file GenericDbTable.cxx.

815 {
816  CondDBColumnArrayBool *tmpColumn = static_cast<CondDBColumnArrayBool*>(m_conddbtable[n_column]);
817  return __getCell(n_column, n_row, ndata, kArrayBool, tmpColumn);
818 }

◆ getCell() [24/24]

int GenericDbTable::getCell ( unsigned  n_column,
unsigned  n_row,
std::vector< std::string > &  ndata 
) const

This method gets a value from a cell in a column of vector of strings.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the reference to the valriable where the value will be returned
Returns
an error code

Definition at line 832 of file GenericDbTable.cxx.

833 {
834  CondDBColumnArrayString *tmpColumn = static_cast<CondDBColumnArrayString*>(m_conddbtable[n_column]);
835  return __getCell(n_column, n_row, ndata, kArrayString, tmpColumn);
836 }

◆ getNames()

int GenericDbTable::getNames ( std::vector< std::string > &  names) const

This method gets a vector containing the names of all columns in the table.

Parameters
namesis the reference to the vector returned
Returns
an error code

Definition at line 85 of file GenericDbTable.cxx.

86 {
87  if (!m_isInitialized)
88  return CDB_NOT_INITIALIZED;
89 
90  for (unsigned i = 0; i < m_conddbtable.size(); i++)
91  {
92  names.push_back(m_conddbtable[i]->name);
93  }
94 
95  return 0;
96 }

◆ getNull() [1/5]

int GenericDbTable::getNull ( unsigned  n_column,
double &  null 
) const

Definition at line 286 of file GenericDbTable.cxx.

287 {
288  if (!m_isInitialized)
289  return CDB_NOT_INITIALIZED;
290 
291  if (m_conddbtable.size() > n_column)
292  if (m_conddbtable[n_column]->type == kDouble)
293  {
294  CondDBColumnDouble *tmpColumn = static_cast<CondDBColumnDouble*>(m_conddbtable[n_column]);
295  return __getNull(null, tmpColumn);
296  }
297  else if (m_conddbtable[n_column]->type == kArrayDouble)
298  {
300  CondDBColumnArrayDouble *tmpColumn = static_cast<CondDBColumnArrayDouble*>(m_conddbtable[n_column]);
301  __getNull(tmp, tmpColumn);
302  null = tmp[0];
303  return CDB_SUCCESS;
304  }
305  else
306  return CDB_TYPE_ERROR;
307  else
308  return CDB_RANGE_ERROR;
309 }

◆ getNull() [2/5]

int GenericDbTable::getNull ( unsigned  n_column,
float &  null 
) const

Get Null value for column.

Definition at line 237 of file GenericDbTable.cxx.

238 {
239  if (!m_isInitialized)
240  return CDB_NOT_INITIALIZED;
241 
242  if (m_conddbtable.size() > n_column)
243  if (m_conddbtable[n_column]->type == kFloat)
244  {
245  CondDBColumnFloat *tmpColumn = static_cast<CondDBColumnFloat*>(m_conddbtable[n_column]);
246  return __getNull(null, tmpColumn);
247  }
248  else if ( m_conddbtable[n_column]->type == kArrayFloat)
249  {
251  CondDBColumnArrayFloat *tmpColumn = static_cast<CondDBColumnArrayFloat*>(m_conddbtable[n_column]);
252  __getNull(tmp, tmpColumn);
253  null=tmp[0];
254  return CDB_SUCCESS;
255  }
256  else
257  return CDB_TYPE_ERROR;
258  else
259  return CDB_RANGE_ERROR;
260 }

◆ getNull() [3/5]

int GenericDbTable::getNull ( unsigned  n_column,
int64 null 
) const

Definition at line 311 of file GenericDbTable.cxx.

312 {
313  if (!m_isInitialized)
314  return CDB_NOT_INITIALIZED;
315 
316  if (m_conddbtable.size() > n_column)
317  if (m_conddbtable[n_column]->type == kLongLong)
318  {
319  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
320  return __getNull(null, tmpColumn);
321  }
322  else if ( m_conddbtable[n_column]->type == kArrayLongLong)
323  {
324  vector<int64> tmp;
325  CondDBColumnArrayLong *tmpColumn = static_cast<CondDBColumnArrayLong*>(m_conddbtable[n_column]);
326  __getNull(tmp, tmpColumn);
327  null = tmp[0];
328  return CDB_SUCCESS;
329  }
330  else
331  return CDB_TYPE_ERROR;
332  else
333  return CDB_RANGE_ERROR;
334 }

◆ getNull() [4/5]

int GenericDbTable::getNull ( unsigned  n_column,
long int &  null 
) const

Definition at line 262 of file GenericDbTable.cxx.

263 {
264  if (!m_isInitialized)
265  return CDB_NOT_INITIALIZED;
266 
267  if (m_conddbtable.size() > n_column)
268  if (m_conddbtable[n_column]->type == kInt)
269  {
270  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
271  return __getNull(null, tmpColumn);
272  }
273  else if (m_conddbtable[n_column]->type == kArrayInt)
274  {
275  vector<long int> tmp;
276  CondDBColumnArrayInt *tmpColumn = static_cast<CondDBColumnArrayInt*>(m_conddbtable[n_column]);
277  __getNull(tmp, tmpColumn);
278  return CDB_SUCCESS;
279  }
280  else
281  return CDB_TYPE_ERROR;
282  else
283  return CDB_RANGE_ERROR;
284 }

◆ getNull() [5/5]

int GenericDbTable::getNull ( unsigned  n_column,
std::string &  null 
) const

Definition at line 137 of file GenericDbTable.cxx.

138 {
139  if (!m_isInitialized)
140  return CDB_NOT_INITIALIZED;
141 
142  if (m_conddbtable.size() > n_column)
143  {
144  switch (m_conddbtable[n_column]->type)
145  {
146  case kString:
147  {
148  CondDBColumnString *tmpColumn = static_cast<CondDBColumnString*>(m_conddbtable[n_column]);
149  return __getNull(null, tmpColumn);
150  }
151  case kArrayString:
152  {
154  CondDBColumnArrayString *tmpColumn = static_cast<CondDBColumnArrayString*>(m_conddbtable[n_column]);
155  __getNull(tmp, tmpColumn);
156  null = tmp[0];
157  return CDB_SUCCESS;
158  }
159  case kFloat:
160  {
161  float tmp;
162  CondDBColumnFloat *tmpColumn = static_cast<CondDBColumnFloat*>(m_conddbtable[n_column]);
163  __getNull(tmp, tmpColumn);
164  null = ToString<float>(tmp);
165  return CDB_SUCCESS;
166  }
167  case kArrayFloat:
168  {
170  CondDBColumnArrayFloat *tmpColumn = static_cast<CondDBColumnArrayFloat*>(m_conddbtable[n_column]);
171  __getNull(tmp, tmpColumn);
172  null = ToString<float>(tmp[0]);
173  return CDB_SUCCESS;
174  }
175  case kInt:
176  {
177  long int tmp;
178  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
179  __getNull(tmp, tmpColumn);
180  null = ToString<float>(tmp);
181  return CDB_SUCCESS;
182  }
183  case kArrayInt:
184  {
185  vector<long int> tmp;
186  CondDBColumnArrayInt *tmpColumn = static_cast<CondDBColumnArrayInt*>(m_conddbtable[n_column]);
187  __getNull(tmp, tmpColumn);
188  null = ToString(tmp[0]);
189  return CDB_SUCCESS;
190  }
191  case kDouble:
192  {
193  double tmp;
194  CondDBColumnDouble *tmpColumn = static_cast<CondDBColumnDouble*>(m_conddbtable[n_column]);
195  __getNull(tmp, tmpColumn);
196  null = ToString(tmp);
197  return CDB_SUCCESS;
198  }
199  case kArrayDouble:
200  {
202  CondDBColumnArrayDouble *tmpColumn = static_cast<CondDBColumnArrayDouble*>(m_conddbtable[n_column]);
203  __getNull(tmp, tmpColumn);
204  null = ToString(tmp[0]);
205  return CDB_SUCCESS;
206  }
207  case kLongLong:
208  {
209  int64 tmp;
210  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
211  __getNull(tmp, tmpColumn);
212  null = ToString(tmp);
213  return CDB_SUCCESS;
214  }
215  case kArrayLongLong:
216  {
217  vector<int64> tmp;
218  CondDBColumnArrayLong *tmpColumn = static_cast<CondDBColumnArrayLong*>(m_conddbtable[n_column]);
219  __getNull(tmp, tmpColumn);
220  null = ToString(tmp[0]);
221  return CDB_SUCCESS;
222  }
223  case kBool:
224  case kArrayBool:
225  {
226  null=ToString(-1);
227  return CDB_SUCCESS;
228  }
229  default:
230  return CDB_TYPE_ERROR;
231  }
232  }
233  else
234  return CDB_RANGE_ERROR;
235 }

◆ getNumColumns()

unsigned GenericDbTable::getNumColumns ( ) const
inline

Returns the number of columns in the table.

The user must know if all rows reserved are already assigned with values

Returns
number of rows reserved.

Definition at line 579 of file GenericDbTable.h.

579 {return m_conddbtable.size();}

◆ getNumRows()

unsigned GenericDbTable::getNumRows ( ) const
inline

Returns the number of rows RESERVED in the table.

The user must know if all rows reserved are already assigned with values

Returns
number of rows reserved.

Definition at line 571 of file GenericDbTable.h.

571 {return m_numRows;}

◆ getRow()

int GenericDbTable::getRow ( unsigned  rowNumber,
std::vector< std::string > &  values 
) const

This method returns a vector of strings with allelements in a row In case the cell has an array the first string has the number of elements (following strings) belonging to the array.

Parameters
rowNumberis the number of the row
valuesis the string that will be returned with the row elements
Returns
an error code that is to be defined yet

Definition at line 1616 of file GenericDbTable.cxx.

1617 {
1618  if (n_row < m_numRows)
1619  {
1620  for (unsigned i =0; i<m_conddbtable.size(); i++)
1621  {
1622  switch(m_conddbtable[i]->type)
1623  {
1624  case kInt:
1625  {
1626  long int tmp;
1627  getCell(i,n_row, tmp);
1628  values.push_back(ToString<long int>(tmp));
1629  break;
1630  }
1631  case kBool:
1632  {
1633  short int tmp;
1634  getCell(i,n_row, tmp);
1635  values.push_back(ToString<short int>(tmp));
1636  break;
1637  }
1638  case kLongLong:
1639  {
1640  int64 tmp;
1641  getCell(i,n_row, tmp);
1642  values.push_back(ToString<int64>(tmp));
1643  break;
1644  }
1645  case kFloat:
1646  {
1647  float tmp;
1648  getCell(i,n_row, tmp);
1649  values.push_back(ToString<float>(tmp));
1650  break;
1651 
1652  }
1653  case kString:
1654  {
1655  string tmp;
1656  getCell(i,n_row, tmp);
1657  values.push_back(ToString<string>(tmp));
1658  break;
1659 
1660  }
1661  case kDouble:
1662  {
1663  double tmp;
1664  getCell(i,n_row, tmp);
1665  values.push_back(ToString<double>(tmp));
1666  break;
1667 
1668  }
1669  case kArrayInt:
1670  {
1671  vector<long int> tmp;
1672  getCell(i,n_row, tmp);
1673  int size = tmp.size();
1674  values.push_back(ToString<int>(size));
1675  while(size)
1676  {
1677  values.push_back(ToString<long int>(tmp[size-1]));
1678  size--;
1679  }
1680  break;
1681 
1682  }
1683  case kArrayBool:
1684  {
1685  vector<short int> tmp;
1686  getCell(i,n_row, tmp);
1687  int size = tmp.size();
1688  values.push_back(ToString<int>(size));
1689  while(size)
1690  {
1691  values.push_back(ToString<short int>(tmp[size-1]));
1692  size--;
1693  }
1694  break;
1695 
1696  }
1697  case kArrayLongLong:
1698  {
1699  vector<int64> tmp;
1700  getCell(i,n_row, tmp);
1701  int size = tmp.size();
1702  values.push_back(ToString<int>(size));
1703  while(size)
1704  {
1705  values.push_back(ToString<int64>(tmp[size-1]));
1706  size--;
1707  }
1708  break;
1709 
1710  }
1711  case kArrayFloat:
1712  {
1714  getCell(i,n_row, tmp);
1715  int size = tmp.size();
1716  values.push_back(ToString<int>(size));
1717  while(size)
1718  {
1719  values.push_back(ToString<float>(tmp[size-1]));
1720  size--;
1721  }
1722  break;
1723 
1724  }
1725  case kArrayString:
1726  {
1728  getCell(i,n_row, tmp);
1729  int size = tmp.size();
1730  values.push_back(ToString<int>(size));
1731  while(size)
1732  {
1733  values.push_back(tmp[size-1]);
1734  size--;
1735  }
1736  break;
1737  }
1738  case kArrayDouble:
1739  {
1741  getCell(i,n_row, tmp);
1742  int size = tmp.size();
1743  values.push_back(ToString<int>(size));
1744  while(size)
1745  {
1746  values.push_back(ToString<double>(tmp[size-1]));
1747  size--;
1748  }
1749  break;
1750  }
1751  default: return CDB_TYPE_ERROR;
1752  }
1753  }
1754 
1755  }
1756  else
1757  return CDB_RANGE_ERROR;
1758 // sucess!
1759  return CDB_SUCCESS;
1760 }

◆ getRowID()

int GenericDbTable::getRowID ( std::string &  pID) const

This method returns, for a given ID, the row number.

In case that this table does not have id's returns -1

Parameters
pIDis the ID that must be searched
Returns
the row number for this ID

Definition at line 111 of file GenericDbTable.cxx.

112 {
113  std::vector<std::string> names;
114  unsigned int ncolumn = 0;
115 
116  if (getNames(names) != CDB_NOT_INITIALIZED) { //success
117  ncolumn = std::count_if(names.begin(),names.end(), [](const auto & s){return s != "Id";} );
118 
119  // if the table does not have id's
120  if (ncolumn == names.size())
121  return -1;
122 
123  CondDBColumnString *dcolumn = static_cast<CondDBColumnString*>(m_conddbtable[ncolumn]);
124 
125  for (unsigned int i = 0; i < dcolumn->column.size(); i++) {
126  if (dcolumn->column[i] == pID) {
127  return i;
128  }
129  }
130  }
131  // if the execution is here it means that the id doesn't exist in the column
132  return -1;
133 
134 }

◆ getTypes()

int GenericDbTable::getTypes ( std::vector< dataTypes > &  types) const

This method gets a vector containing the data types of all columns in the table.

Parameters
typesis the reference to the vector returned
Returns
an error code

Definition at line 98 of file GenericDbTable.cxx.

99 {
100  if (!m_isInitialized)
101  return CDB_NOT_INITIALIZED;
102 
103  for (unsigned i = 0; i < m_conddbtable.size(); i++)
104  {
105  types.push_back(m_conddbtable[i]->type);
106  }
107  return 0;
108 }

◆ Initialize()

void GenericDbTable::Initialize ( unsigned  n_columns,
int  n_rows = 0 
)

This method initializes a table created by the default constructor If the table had the number of columns already defined this does nothing.

Parameters
n_columnsis the number of columns of this table
n_rowsis the number of rows to allocate (OPTIONAL)

Definition at line 61 of file GenericDbTable.cxx.

62 {
63  unsigned i;
64 
65  if (m_conddbtable.size() > 0 || m_isInitialized == true)
66  return;
67 
68  for (i=0;i<n_columns; i++)
69  m_conddbtable.push_back(new CondDBColumn);
70 
71  for (i = 0; i<m_conddbtable.size(); i++ )
72  {
73  m_conddbtable[i]->initialized = false;
74  m_conddbtable[i]->type = kNull;
75  }
76 
77  if (n_rows)
78  {
79  resize(n_rows);
80 // status = vector<CondDBStatus>(n_rows,untouched);
81  }
82 }

◆ resize()

void GenericDbTable::resize ( int  num_rows)

Reserves more rows on the table.

This method must be called at each time that one wants to insert new data on the table reserving only the number of rows that will be used!

Parameters
num_rowsis the amount of rows that must be reserved in the table

Definition at line 1606 of file GenericDbTable.cxx.

1607 {
1608  m_numRows += num_rows;
1609 }

◆ setCell() [1/12]

int GenericDbTable::setCell ( unsigned  n_column,
unsigned  n_row,
const double  ndata 
)

This method changes a value from a cell in a column of doubles.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the new value to be assigned
Returns
an error code

Definition at line 1026 of file GenericDbTable.cxx.

1027 {
1028  CondDBColumnDouble *tmpColumn = static_cast<CondDBColumnDouble*>(m_conddbtable[n_column]);
1029  return __setCell(n_column, n_row, ndata, kDouble, tmpColumn);
1030 }

◆ setCell() [2/12]

int GenericDbTable::setCell ( unsigned  n_column,
unsigned  n_row,
const float  ndata 
)

This method changes a value from a cell in a column of floats.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the new value to be assigned
Returns
an error code

Definition at line 921 of file GenericDbTable.cxx.

922 {
923  CondDBColumnFloat *tmpColumn = static_cast<CondDBColumnFloat*>(m_conddbtable[n_column]);
924  return __setCell(n_column, n_row, ndata, kFloat, tmpColumn);
925 }

◆ setCell() [3/12]

int GenericDbTable::setCell ( unsigned  n_column,
unsigned  n_row,
const int64  ndata 
)

This method changes a value from a cell in a column of long long ints.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the new value to be assigned
Returns
an error code

Definition at line 915 of file GenericDbTable.cxx.

916 {
917  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
918  return __setCell(n_column, n_row, ndata, kLongLong, tmpColumn);
919 }

◆ setCell() [4/12]

int GenericDbTable::setCell ( unsigned  n_column,
unsigned  n_row,
const long int  ndata 
)

This method changes a value from a cell in a column of long ints.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the new value to be assigned
Returns
an error code

Definition at line 903 of file GenericDbTable.cxx.

904 {
905  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
906  return __setCell(n_column, n_row, ndata, kInt, tmpColumn);
907 }

◆ setCell() [5/12]

int GenericDbTable::setCell ( unsigned  n_column,
unsigned  n_row,
const short int  ndata 
)

set data methods

These methods allow to chage a value in a specified cell This method changes a value from a cell in a column of long ints

Parameters
n_columnis the column number
n_rowis the row number
ndatais the new value to be assigned
Returns
an error code

Definition at line 909 of file GenericDbTable.cxx.

910 {
911  CondDBColumnBool *tmpColumn = static_cast<CondDBColumnBool*>(m_conddbtable[n_column]);
912  return __setCell(n_column, n_row, ndata, kBool, tmpColumn);
913 }

◆ setCell() [6/12]

int GenericDbTable::setCell ( unsigned  n_column,
unsigned  n_row,
const std::string &  ndata 
)

This method changes a value from a cell in a column of strings.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the new value to be assigned
Returns
an error code

Definition at line 927 of file GenericDbTable.cxx.

928 {
929 
930  if (!m_isInitialized)
931  return CDB_NOT_INITIALIZED;
932 
933  if ((m_numRows > n_row) && (m_conddbtable.size() > n_column))
934  {
935  if (m_conddbtable[n_column]->type == kString)
936  {
937  CondDBColumnString *tmpColumn = static_cast<CondDBColumnString*>(m_conddbtable[n_column]);
938  __setCell(n_column, n_row, ndata, kString, tmpColumn);
939  }
940  else
941  {
942  switch(m_conddbtable[n_column]->type)
943  {
944  case kInt:
945  {
946  if (ndata=="NULL")
947  {
948  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
949  __setCell(n_column, n_row, tmpColumn->column[0], kInt, tmpColumn);
950  }
951  else
952  {
953  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
954  __setCell(n_column, n_row, atol(ndata.c_str()), kInt, tmpColumn);
955  }
956  break;
957  }
958  case kBool:
959  {
960  if (ndata=="NULL")
961  {
962  CondDBColumnBool *tmpColumn = static_cast<CondDBColumnBool*>(m_conddbtable[n_column]);
963  __setCell(n_column,n_row, tmpColumn->column[0], kBool, tmpColumn);
964 
965  }
966  else
967  {
968  CondDBColumnBool *tmpColumn = static_cast<CondDBColumnBool*>(m_conddbtable[n_column]);
969  __setCell(n_column, n_row, atoi(ndata.c_str()), kBool, tmpColumn);
970  }
971  break;
972  }
973  case kLongLong:
974  {
975  if (ndata=="NULL")
976  {
977  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
978  __setCell(n_column,n_row, tmpColumn->column[0], kLongLong, tmpColumn);
979  }
980  else
981  {
982  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
983  __setCell(n_column,n_row, atoi64(ndata.c_str()), kLongLong, tmpColumn);
984  }
985  break;
986  }
987  case kFloat:
988  {
989  if (ndata=="NULL")
990  {
991  CondDBColumnFloat *tmpColumn = static_cast<CondDBColumnFloat*>(m_conddbtable[n_column]);
992  __setCell(n_column,n_row, tmpColumn->column[0], kFloat, tmpColumn);
993  }
994  else
995  {
996  CondDBColumnFloat *tmpColumn = static_cast<CondDBColumnFloat*>(m_conddbtable[n_column]);
997  __setCell(n_column,n_row, strtod(ndata.c_str(), (char **)NULL), kFloat, tmpColumn);
998  }
999  break;
1000  }
1001  case kDouble:
1002  {
1003  if (ndata=="NULL")
1004  {
1005  CondDBColumnDouble *tmpColumn = static_cast<CondDBColumnDouble*>(m_conddbtable[n_column]);
1006  __setCell(n_column,n_row, tmpColumn->column[0],kDouble, tmpColumn);
1007  }
1008  else
1009  {
1010  CondDBColumnDouble *tmpColumn = static_cast<CondDBColumnDouble*>(m_conddbtable[n_column]);
1011  __setCell(n_column,n_row,strtod(ndata.c_str(), (char **)NULL),kDouble, tmpColumn);
1012  }
1013  break;
1014  }
1015  //if the column is of the type array of *type* one should use the method with vector of strings
1016  default:
1017  return CDB_STRTOARRAY_ERROR;
1018  }
1019  }
1020  }
1021  else
1022  return CDB_RANGE_ERROR;
1023  return CDB_SUCCESS;
1024 }

◆ setCell() [7/12]

int GenericDbTable::setCell ( unsigned  n_column,
unsigned  n_row,
const std::vector< double > &  ndata 
)

This method changes a value from a cell in a column of vectors of doubles.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the new array to be assigned
Returns
an error code

◆ setCell() [8/12]

int GenericDbTable::setCell ( unsigned  n_column,
unsigned  n_row,
const std::vector< float > &  ndata 
)

This method changes a value from a cell in a column of vectors of floats.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the new array to be assigned
Returns
an error code

◆ setCell() [9/12]

int GenericDbTable::setCell ( unsigned  n_column,
unsigned  n_row,
const std::vector< int64 > &  ndata 
)

This method changes a value from a cell in a column of vectors of long long ints.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the new array to be assigned
Returns
an error code

Definition at line 1044 of file GenericDbTable.cxx.

1045 {
1046  CondDBColumnArrayLong *tmpColumn = static_cast<CondDBColumnArrayLong*>(m_conddbtable[n_column]);
1047  return __setCell(n_column, n_row, ndata, kArrayLongLong, tmpColumn);
1048 }

◆ setCell() [10/12]

int GenericDbTable::setCell ( unsigned  n_column,
unsigned  n_row,
const std::vector< long int > &  ndata 
)

This method changes a value from a cell in a column of vectors of long ints.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the new array to be assigned
Returns
an error code

Definition at line 1038 of file GenericDbTable.cxx.

1039 {
1040  CondDBColumnArrayInt *tmpColumn = static_cast<CondDBColumnArrayInt*>(m_conddbtable[n_column]);
1041  return __setCell(n_column, n_row, ndata, kArrayInt, tmpColumn);
1042 }

◆ setCell() [11/12]

int GenericDbTable::setCell ( unsigned  n_column,
unsigned  n_row,
const std::vector< short int > &  ndata 
)

This method changes a value from a cell in a column of vectors of bools.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the new array to be assigned
Returns
an error code

Definition at line 1032 of file GenericDbTable.cxx.

1033 {
1034  CondDBColumnArrayBool *tmpColumn = static_cast<CondDBColumnArrayBool*>(m_conddbtable[n_column]);
1035  return __setCell(n_column, n_row, ndata, kArrayBool, tmpColumn);
1036 }

◆ setCell() [12/12]

int GenericDbTable::setCell ( unsigned  n_column,
unsigned  n_row,
const std::vector< std::string > &  ndata 
)

This method changes a value from a cell in a column of vectors of strings.

Parameters
n_columnis the column number
n_rowis the row number
ndatais the new array to be assigned
Returns
an error code

Definition at line 1064 of file GenericDbTable.cxx.

1065 {
1066 
1067  if (!m_isInitialized)
1068  return CDB_NOT_INITIALIZED;
1069 
1070  if ((m_numRows > n_row) && (m_conddbtable.size() > n_column))
1071  {
1072  if (m_conddbtable[n_column]->type == kArrayString)
1073  {
1074  CondDBColumnArrayString *tmpColumn = static_cast<CondDBColumnArrayString*>(m_conddbtable[n_column]);
1075  return __setCell(n_column, n_row, ndata, kArrayString, tmpColumn);
1076 // static_cast<CondDBColumnArrayString*>(m_conddbtable[n_column])->column[n_row+1] = ndata;
1077  }
1078  else
1079  {
1080  switch(m_conddbtable[n_column]->type)
1081  {
1082  case kArrayInt:
1083  {
1084  vector<long int> tmp;
1085  for (unsigned i=0; i<ndata.size(); i++)
1086  {
1087  if (ndata[i]=="NULL")
1088  {
1089  long int null;
1090  getNull(n_column, null);
1091  tmp.push_back(null);
1092  }
1093  else
1094  tmp.push_back(atol(ndata[i].c_str()));
1095  }
1096  CondDBColumnArrayInt *tmpColumn = static_cast<CondDBColumnArrayInt*>(m_conddbtable[n_column]);
1097  return __setCell(n_column, n_row, tmp, kArrayInt, tmpColumn);
1098  break;
1099  }
1100  case kArrayBool:
1101  {
1102  vector<short int> tmp;
1103  for (unsigned i=0; i<ndata.size(); i++)
1104  {
1105  if (ndata[i]=="NULL")
1106  {
1107  tmp.push_back(-1);
1108  }
1109  else
1110  tmp.push_back(atoi(ndata[i].c_str()));
1111  }
1112  CondDBColumnArrayBool *tmpColumn = static_cast<CondDBColumnArrayBool*>(m_conddbtable[n_column]);
1113  return __setCell(n_column, n_row, tmp, kArrayBool, tmpColumn);
1114  break;
1115  }
1116  case kArrayLongLong:
1117  {
1118  vector<int64> tmp;
1119  for (unsigned i=0; i<ndata.size(); i++)
1120  {
1121  if (ndata[i]=="NULL")
1122  {
1123  int64 null;
1124  getNull(n_column, null);
1125  tmp.push_back(null);
1126  }
1127  else
1128 
1129  tmp.push_back(atoi64(ndata[i].c_str()));
1130  }
1131  CondDBColumnArrayLong *tmpColumn = static_cast<CondDBColumnArrayLong*>(m_conddbtable[n_column]);
1132  return __setCell(n_column, n_row, tmp, kArrayLongLong, tmpColumn);
1133  break;
1134  }
1135  case kArrayFloat:
1136  {
1138  for (unsigned i=0; i<ndata.size(); i++)
1139  {
1140  if (ndata[i]=="NULL")
1141  {
1142  float null;
1143  getNull(n_column, null);
1144  tmp.push_back(null);
1145  }
1146  else
1147  tmp.push_back(atof(ndata[i].c_str()));
1148  }
1149  CondDBColumnArrayFloat *tmpColumn = static_cast<CondDBColumnArrayFloat*>(m_conddbtable[n_column]);
1150  return __setCell(n_column, n_row, tmp, kArrayFloat, tmpColumn);
1151  break;
1152  }
1153  case kArrayDouble:
1154  {
1156  for (unsigned i=0; i<ndata.size(); i++)
1157  {
1158  if (ndata[i]=="NULL")
1159  {
1160  double null;
1161  getNull(n_column, null);
1162  tmp.push_back(null);
1163  }
1164  else
1165  tmp.push_back(strtod(ndata[i].c_str(), (char**)NULL));
1166  }
1167  CondDBColumnArrayDouble *tmpColumn = static_cast<CondDBColumnArrayDouble*>(m_conddbtable[n_column]);
1168  return __setCell(n_column, n_row, tmp, kArrayDouble, tmpColumn);
1169  break;
1170  }
1171  //if the column is of the type array of *type* one should use the method with vector of strings
1172  default:
1173  return CDB_STRTOARRAY_ERROR;
1174  }
1175  }
1176  }
1177  else
1178  return CDB_RANGE_ERROR;
1179  return CDB_SUCCESS;
1180 }

◆ setColumndata() [1/12]

int GenericDbTable::setColumndata ( unsigned  n_column,
const std::vector< double > &  data 
)

Insert a subset in a column of doubles.

Parameters
n_columnRefers to the column number
datarefers to the values to be appended in the column
Returns
the number of values inserted
See also
getNames(); getTypes()

◆ setColumndata() [2/12]

int GenericDbTable::setColumndata ( unsigned  n_column,
const std::vector< float > &  data 
)

Insert a subset in a column of floats.

Parameters
n_columnRefers to the column number
datarefers to the values to be appended in the column
Returns
the number of values inserted
See also
getNames(); getTypes()

◆ setColumndata() [3/12]

int GenericDbTable::setColumndata ( unsigned  n_column,
const std::vector< int64 > &  data 
)

Insert a subset in a column of long long ints.

Parameters
n_columnRefers to the column number
datarefers to the values to be appended in the column
Returns
the number of values inserted
See also
getNames(); getTypes()

Definition at line 1197 of file GenericDbTable.cxx.

1198 {
1199  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
1200  return __setColumnData(n_column, data, kLongLong, tmpColumn);
1201 }

◆ setColumndata() [4/12]

int GenericDbTable::setColumndata ( unsigned  n_column,
const std::vector< long int > &  data 
)

Insert a subset in a column of long ints.

Parameters
n_columnRefers to the column number
datarefers to the values to be appended in the column
Returns
the number of values inserted
See also
getNames(); getTypes()

Definition at line 1191 of file GenericDbTable.cxx.

1192 {
1193  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
1194  return __setColumnData(n_column, data, kInt, tmpColumn);
1195 }

◆ setColumndata() [5/12]

int GenericDbTable::setColumndata ( unsigned  n_column,
const std::vector< short int > &  data 
)

The following methods allow to insert in the columns a group of values.

The values are passed in a vector. In case that there are not enougth rows reserved to insert the values there will be only inserted data until all rows are filled and return the number of values from the vector passed. Insert a subset in a column of bools

Parameters
n_columnRefers to the column number
datarefers to the values to be appended in the column
Returns
the number of values inserted
See also
getNames(); getTypes()

Definition at line 1203 of file GenericDbTable.cxx.

1204 {
1205  CondDBColumnBool *tmpColumn = static_cast<CondDBColumnBool*>(m_conddbtable[n_column]);
1206  return __setColumnData(n_column, data, kBool, tmpColumn);
1207 }

◆ setColumndata() [6/12]

int GenericDbTable::setColumndata ( unsigned  n_column,
const std::vector< std::string > &  data 
)

Insert a subset in a column of strings.

Parameters
n_columnRefers to the column number
datarefers to the values to be appended in the column
Returns
the number of values inserted
See also
getNames(); getTypes()

Definition at line 1215 of file GenericDbTable.cxx.

1216 {
1217 
1218  if (!m_isInitialized)
1219  return CDB_NOT_INITIALIZED;
1220 
1221  unsigned index = 0;
1222  if (n_column < m_conddbtable.size())
1223  {
1224  if (m_conddbtable[n_column]->type == kString)
1225  {
1226  CondDBColumnString* tmpColumn = static_cast<CondDBColumnString*>(m_conddbtable[n_column]);
1227  while((tmpColumn->column.size() < m_numRows+1) && (index < data.size()))
1228  {
1229  tmpColumn->column.push_back(data[index]);
1230  index++;
1231  }
1232  return index;
1233  }
1234  else
1235  {
1236 // If the data type is not string we can convert the string to the corresponding type
1237  switch(m_conddbtable[n_column]->type)
1238  {
1239 //if the column data type is some kind of array it will be assumed that all values belong to a single cell thus returning 1(cell)
1240  case kArrayInt:
1241  {
1242  vector<long int> tmp;
1243  for (unsigned i=0; i<data.size(); i++)
1244  {
1245  if (data[i]=="NULL")
1246  {
1247  long int null;
1248  getNull(n_column, null);
1249  tmp.push_back(null);
1250  }
1251  else
1252  tmp.push_back(atol(data[i].c_str()));
1253  }
1254  index= setColumndata(n_column, tmp);
1255  break;
1256  }
1257  case kArrayBool:
1258  {
1259  vector<short int> tmp;
1260  for (unsigned i=0; i<data.size(); i++)
1261  {
1262  if (data[i]=="NULL")
1263  {
1264  short int null = -1;
1265  tmp.push_back(null);
1266  }
1267  else
1268  tmp.push_back(atoi(data[i].c_str()));
1269  }
1270  index = setColumndata(n_column, tmp);
1271  break;
1272  }
1273  case kArrayLongLong:
1274  {
1275  vector<int64> tmp;
1276  for (unsigned i=0; i<data.size(); i++)
1277  {
1278  if (data[i]=="NULL")
1279  {
1280  int64 null;
1281  getNull(n_column, null);
1282  tmp.push_back(null);
1283  }
1284  else
1285  tmp.push_back(atoi64(data[i].c_str()));
1286  }
1287  index = setColumndata(n_column, tmp);
1288  break;
1289  }
1290  case kArrayFloat:
1291  {
1293  for (unsigned i=0; i<data.size(); i++)
1294  {
1295  if (data[i]=="NULL")
1296  {
1297  float null;
1298  getNull(n_column, null);
1299  tmp.push_back(null);
1300  }
1301  else
1302  tmp.push_back(atof(data[i].c_str()));
1303  }
1304  index = setColumndata(n_column, tmp);
1305  break;
1306  }
1307  case kArrayDouble:
1308  {
1310  for (unsigned i=0; i<data.size(); i++)
1311  {
1312  if (data[i]=="NULL")
1313  {
1314  double null;
1315  getNull(n_column, null);
1316  tmp.push_back(null);
1317  }
1318  else
1319  tmp.push_back(strtod(data[i].c_str(), (char**)NULL));
1320  }
1321  index = setColumndata(n_column, tmp);
1322  break;
1323  }
1324 //If the column data type is not any array it will be inserted a value in each row!
1325  case kInt:
1326  {
1327  vector<long int> tmp;
1328  for (unsigned i=0; i<data.size(); i++)
1329  {
1330  if (data[i]=="NULL")
1331  {
1332  long int null;
1333  getNull(n_column, null);
1334  tmp.push_back(null);
1335  }
1336  else
1337  tmp.push_back(atol(data[i].c_str()));
1338  }
1339  index = setColumndata(n_column, tmp);
1340  break;
1341  }
1342  case kBool:
1343  {
1344  vector<short int> tmp;
1345  for (unsigned i=0; i<data.size(); i++)
1346  {
1347  if (data[i]=="NULL")
1348  {
1349  // for bool the null value is -1 (not editable by user)
1350  short int null = -1;
1351  tmp.push_back(null);
1352  }
1353  else
1354  tmp.push_back(atoi(data[i].c_str()));
1355  }
1356  index = setColumndata(n_column, tmp);
1357  break;
1358  }
1359  case kLongLong:
1360  {
1361  vector<int64> tmp;
1362  for (unsigned i=0; i<data.size(); i++)
1363  {
1364  if (data[i]=="NULL")
1365  {
1366  int64 null;
1367  getNull(n_column, null);
1368  tmp.push_back(null);
1369  }
1370  else
1371  tmp.push_back(atoi64(data[i].c_str()));
1372  }
1373  index = setColumndata(n_column, tmp);
1374  break;
1375  }
1376  case kFloat:
1377  {
1379  for (unsigned i=0; i<data.size(); i++)
1380  {
1381  if (data[i]=="NULL")
1382  {
1383  float null;
1384  getNull(n_column, null);
1385  tmp.push_back(null);
1386  }
1387  else
1388  tmp.push_back(atof(data[i].c_str()));
1389  }
1390  index = setColumndata(n_column, tmp);
1391  break;
1392  }
1393  case kDouble:
1394  {
1396  for (unsigned i=0; i<data.size(); i++)
1397  {
1398  if (data[i]=="NULL")
1399  {
1400  double null;
1401  getNull(n_column, null);
1402  tmp.push_back(null);
1403  }
1404  else
1405  tmp.push_back(strtod(data[i].c_str(), (char**)NULL));
1406  }
1407  index = setColumndata(n_column, tmp);
1408  break;
1409  }
1410  default:
1411  return CDB_STRTOARRAY_ERROR;
1412  }
1413 
1414  return index;
1415  }
1416  }
1417  else
1418  return CDB_RANGE_ERROR;
1419 }

◆ setColumndata() [7/12]

int GenericDbTable::setColumndata ( unsigned  n_column,
const std::vector< std::vector< double > > &  data 
)

Insert a subset in a column of vectors of doubles.

Parameters
n_columnRefers to the column number
datarefers to the values to be appended in the column
Returns
the number of values inserted
See also
getNames(); getTypes()

◆ setColumndata() [8/12]

int GenericDbTable::setColumndata ( unsigned  n_column,
const std::vector< std::vector< float > > &  data 
)

Insert a subset in a column of vectors of floats.

Parameters
n_columnRefers to the column number
datarefers to the values to be appended in the column
Returns
the number of values inserted
See also
getNames(); getTypes()

◆ setColumndata() [9/12]

int GenericDbTable::setColumndata ( unsigned  n_column,
const std::vector< std::vector< int64 > > &  data 
)

Insert a subset in a column of vectors of long long ints.

Parameters
n_columnRefers to the column number
datarefers to the values to be appended in the column
Returns
the number of values inserted
See also
getNames(); getTypes()

Definition at line 1433 of file GenericDbTable.cxx.

1434 {
1435  CondDBColumnArrayLong *tmpColumn = static_cast<CondDBColumnArrayLong*>(m_conddbtable[n_column]);
1436  return __setColumnData(n_column, data, kArrayLongLong, tmpColumn);
1437 }

◆ setColumndata() [10/12]

int GenericDbTable::setColumndata ( unsigned  n_column,
const std::vector< std::vector< long int > > &  data 
)

Insert a subset in a column of vectors of long ints.

Parameters
n_columnRefers to the column number
datarefers to the values to be appended in the column
Returns
the number of values inserted
See also
getNames(); getTypes()

Definition at line 1427 of file GenericDbTable.cxx.

1428 {
1429  CondDBColumnArrayInt *tmpColumn = static_cast<CondDBColumnArrayInt*>(m_conddbtable[n_column]);
1430  return __setColumnData(n_column, data, kArrayInt, tmpColumn);
1431 }

◆ setColumndata() [11/12]

int GenericDbTable::setColumndata ( unsigned  n_column,
const std::vector< std::vector< short int > > &  data 
)

Insert a subset in a column of vectors of bools.

Parameters
n_columnRefers to the column number
datarefers to the values to be appended in the column
Returns
the number of values inserted
See also
getNames(); getTypes()

Definition at line 1439 of file GenericDbTable.cxx.

1440 {
1441  CondDBColumnArrayBool *tmpColumn = static_cast<CondDBColumnArrayBool*>(m_conddbtable[n_column]);
1442  return __setColumnData(n_column, data, kArrayBool, tmpColumn);
1443 }

◆ setColumndata() [12/12]

int GenericDbTable::setColumndata ( unsigned  n_column,
const std::vector< std::vector< std::string > > &  data 
)

Insert a subset in a column of vectors of strings.

Parameters
n_columnRefers to the column number
datarefers to the values to be appended in the column
Returns
the number of values inserted
See also
getNames(); getTypes()

Definition at line 1457 of file GenericDbTable.cxx.

1458 {
1459  if (!m_isInitialized)
1460  return CDB_NOT_INITIALIZED;
1461 
1462  unsigned index = 0;
1463  if (n_column < m_conddbtable.size())
1464  {
1465  if (m_conddbtable[n_column]->type == kArrayString)
1466  {
1467  CondDBColumnArrayString* tmpColumn = static_cast<CondDBColumnArrayString*>(m_conddbtable[n_column]);
1468  while((tmpColumn->column.size() < m_numRows+1) && (index < data.size()))
1469  {
1470  tmpColumn->column.push_back(data[index]);
1471  index++;
1472  }
1473  return index;
1474  }
1475  else
1476  {
1477 // If the data type is not string we can convert the string to the corresponding type
1478  switch(m_conddbtable[n_column]->type)
1479  {
1480 //if the column data type is an array of any type each inner vector refers to a vector on a cell
1481  case kArrayInt:
1482  {
1483  vector<vector<long int> > aux;
1484  for (unsigned j=0; j<data.size(); j++)
1485  {
1486  vector<long int> tmp;
1487  for (unsigned i=0; i<data[j].size(); i++)
1488  {
1489  if (data[j][i]=="NULL")
1490  {
1491  long int null;
1492  getNull(n_column, null);
1493  tmp.push_back(null);
1494  }
1495  else
1496  tmp.push_back(atol(data[j][i].c_str()));
1497  }
1498  aux.push_back(tmp);
1499  }
1500  index = setColumndata(n_column, aux);
1501  break;
1502  }
1503  case kArrayLongLong:
1504  {
1505  vector<vector<int64> > aux;
1506  for (unsigned j=0; j<data.size(); j++)
1507  {
1508  vector<int64> tmp;
1509  for (unsigned i=0; i<data[j].size(); i++)
1510  {
1511  if (data[j][i]=="NULL")
1512  {
1513  int64 null;
1514  getNull(n_column, null);
1515  tmp.push_back(null);
1516  }
1517  else
1518  tmp.push_back(atoi64(data[j][i].c_str()));
1519  }
1520  aux.push_back(tmp);
1521  }
1522  index = setColumndata(n_column, aux);
1523  break;
1524  }
1525  case kArrayBool:
1526  {
1527  vector<vector<short int> > aux;
1528  for (unsigned j=0; j<data.size(); j++)
1529  {
1530  vector<short int> tmp;
1531  for (unsigned i=0; i<data[j].size(); i++)
1532  {
1533  if (data[j][i]=="NULL")
1534  {
1535  tmp.push_back(-1);
1536  }
1537  else
1538  tmp.push_back(atoi(data[j][i].c_str()));
1539  }
1540  aux.push_back(tmp);
1541  }
1542  index = setColumndata(n_column, aux);
1543  break;
1544  }
1545  case kArrayFloat:
1546  {
1547  vector<vector<float> > aux;
1548  for (unsigned j=0; j<data.size(); j++)
1549  {
1551  for (unsigned i=0; i<data[j].size(); i++)
1552  {
1553  if (data[j][i]=="NULL")
1554  {
1555  float null;
1556  getNull(n_column, null);
1557  tmp.push_back(null);
1558  }
1559  else
1560  tmp.push_back(atof(data[j][i].c_str()));
1561  }
1562  aux.push_back(tmp);
1563  }
1564  index = setColumndata(n_column, aux);
1565  break;
1566  }
1567  case kArrayDouble:
1568  {
1569  vector<vector<double> > aux;
1570  for (unsigned j=0; j<data.size(); j++)
1571  {
1573  for (unsigned i=0; i<data[j].size(); i++)
1574  {
1575  if (data[j][i]=="NULL")
1576  {
1577  double null;
1578  getNull(n_column, null);
1579  tmp.push_back(null);
1580  }
1581  else
1582  tmp.push_back(strtod(data[j][i].c_str(), (char**)NULL));
1583  }
1584  aux.push_back(tmp);
1585  }
1586  index = setColumndata(n_column, aux);
1587  break;
1588  }
1589  default:
1590  return CDB_STRTOARRAY_ERROR;
1591  }
1592  return index;
1593  }
1594  }
1595  else
1596  return CDB_RANGE_ERROR;
1597 
1598 }

◆ setName()

int GenericDbTable::setName ( unsigned  n_column,
const std::string &  name 
)

This method defines the name for a specified column.

Parameters
n_columnis the column number
nameis a string with the name
Returns
an error code

Definition at line 337 of file GenericDbTable.cxx.

338 {
339  if (m_conddbtable.size() > n_column)
340  if (m_conddbtable[n_column]->name.size() == 0)
341  {
342  m_conddbtable[n_column]->name = name;
343  if (m_conddbtable[n_column]->type != kNull)
344  {
345  m_conddbtable[n_column]->initialized = true;
347  }
348  }
349  else
350  return CDB_TYPE_ERROR;
351  else
352  return CDB_RANGE_ERROR;
353  return CDB_SUCCESS;
354 }

◆ setNull() [1/5]

int GenericDbTable::setNull ( unsigned  n_column,
const double &  null 
)

Definition at line 674 of file GenericDbTable.cxx.

675 {
676  if (!m_isInitialized)
677  return CDB_NOT_INITIALIZED;
678 
679  if (m_conddbtable.size() > n_column)
680  if (m_conddbtable[n_column]->type == kDouble || m_conddbtable[n_column]->type == kArrayDouble)
681  {
682  static_cast<CondDBColumnDouble*>(m_conddbtable[n_column])->column[0] = null;
683  return CDB_SUCCESS;
684  }
685  else if (m_conddbtable[n_column]->type == kArrayDouble)
686  {
687  vector<double> tmp(1, null);
688  static_cast<CondDBColumnArrayDouble*>(m_conddbtable[n_column])->column[0] = tmp;
689  return CDB_SUCCESS;
690  }
691  else
692  return CDB_TYPE_ERROR;
693  else
694  return CDB_RANGE_ERROR;
695 }

◆ setNull() [2/5]

int GenericDbTable::setNull ( unsigned  n_column,
const float &  null 
)

Set Null value for column.

Definition at line 651 of file GenericDbTable.cxx.

652 {
653  if (!m_isInitialized)
654  return CDB_NOT_INITIALIZED;
655 
656  if (m_conddbtable.size() > n_column)
657  if (m_conddbtable[n_column]->type == kFloat )
658  {
659  static_cast<CondDBColumnFloat*>(m_conddbtable[n_column])->column[0] = null;
660  return CDB_SUCCESS;
661  }
662  else if (m_conddbtable[n_column]->type == kArrayFloat)
663  {
664  vector<float> tmp(1,null);
665  static_cast<CondDBColumnArrayFloat*>(m_conddbtable[n_column])->column[0] = tmp;
666  return CDB_SUCCESS;
667  }
668  else
669  return CDB_TYPE_ERROR;
670  else
671  return CDB_RANGE_ERROR;
672 }

◆ setNull() [3/5]

int GenericDbTable::setNull ( unsigned  n_column,
const int64 null 
)

Definition at line 628 of file GenericDbTable.cxx.

629 {
630  if (!m_isInitialized)
631  return CDB_NOT_INITIALIZED;
632 
633  if (m_conddbtable.size() > n_column)
634  if (m_conddbtable[n_column]->type == kLongLong )
635  {
636  static_cast<CondDBColumnLong*>(m_conddbtable[n_column])->column[0] = null;
637  return CDB_SUCCESS;
638  }
639  else if (m_conddbtable[n_column]->type == kArrayLongLong)
640  {
641  vector<int64> tmp(1,null);
642  static_cast<CondDBColumnArrayLong*>(m_conddbtable[n_column])->column[0] = tmp;
643  return CDB_SUCCESS;
644  }
645  else
646  return CDB_TYPE_ERROR;
647  else
648  return CDB_RANGE_ERROR;
649 }

◆ setNull() [4/5]

int GenericDbTable::setNull ( unsigned  n_column,
const long int &  null 
)

Definition at line 605 of file GenericDbTable.cxx.

606 {
607  if (!m_isInitialized)
608  return CDB_NOT_INITIALIZED;
609 
610  if (m_conddbtable.size() > n_column)
611  if (m_conddbtable[n_column]->type == kInt)
612  {
613  static_cast<CondDBColumnInt*>(m_conddbtable[n_column])->column[0] = null;
614  return CDB_SUCCESS;
615  }
616  else if (m_conddbtable[n_column]->type == kArrayInt)
617  {
618  vector<long int> tmp(1,null);
619  static_cast<CondDBColumnArrayInt*>(m_conddbtable[n_column])->column[0] = tmp;
620  return CDB_SUCCESS;
621  }
622  else
623  return CDB_TYPE_ERROR;
624  else
625  return CDB_RANGE_ERROR;
626 }

◆ setNull() [5/5]

int GenericDbTable::setNull ( unsigned  n_column,
const std::string &  null 
)

Definition at line 530 of file GenericDbTable.cxx.

531 {
532  if (!m_isInitialized)
533  return CDB_NOT_INITIALIZED;
534 
535  if (m_conddbtable.size() > n_column)
536  switch (m_conddbtable[n_column]->type)
537  {
538  case kString:
539  {
540  static_cast<CondDBColumnString*>(m_conddbtable[n_column])->column[0] = null;
541  return CDB_SUCCESS;
542  }
543  case kArrayString:
544  {
545  vector<string> tmp(1,null);
546  static_cast<CondDBColumnArrayString*>(m_conddbtable[n_column])->column[0] = tmp;
547  return CDB_SUCCESS;
548  }
549  case kFloat:
550  {
551  static_cast<CondDBColumnFloat*>(m_conddbtable[n_column])->column[0] = atof(null.c_str());
552  return CDB_SUCCESS;
553  }
554  case kArrayFloat:
555  {
556  vector<float> tmp(1,atof(null.c_str()));
557  static_cast<CondDBColumnArrayFloat*>(m_conddbtable[n_column])->column[0] = tmp;
558  return CDB_SUCCESS;
559  }
560  case kInt:
561  {
562  static_cast<CondDBColumnInt*>(m_conddbtable[n_column])->column[0] = atol(null.c_str());
563  return CDB_SUCCESS;
564  }
565  case kArrayInt:
566  {
567  vector<long int> tmp(1,atol(null.c_str()));
568  static_cast<CondDBColumnArrayInt*>(m_conddbtable[n_column])->column[0] = tmp;
569  return CDB_SUCCESS;
570  }
571  case kBool:
572  case kArrayBool:
573  {
574  return CDB_SUCCESS;
575  }
576  case kLongLong:
577  {
578  static_cast<CondDBColumnString*>(m_conddbtable[n_column])->column[0] = atoi64(null.c_str());
579  return CDB_SUCCESS;
580  }
581  case kArrayLongLong:
582  {
583  vector<int64> tmp(1,atoi64(null.c_str()));
584  static_cast<CondDBColumnArrayLong*>(m_conddbtable[n_column])->column[0] = tmp;
585  return CDB_SUCCESS;
586  }
587  case kDouble:
588  {
589  static_cast<CondDBColumnDouble*>(m_conddbtable[n_column])->column[0] = atof(null.c_str());
590  return CDB_SUCCESS;
591  }
592  case kArrayDouble:
593  {
594  vector<double> tmp(1,atof(null.c_str()));
595  static_cast<CondDBColumnArrayDouble*>(m_conddbtable[n_column])->column[0] = tmp;
596  return CDB_SUCCESS;
597  }
598  default:
599  return CDB_TYPE_ERROR;
600  }
601  else
602  return CDB_RANGE_ERROR;
603 }

◆ setType()

int GenericDbTable::setType ( unsigned  n_column,
dataTypes  type 
)

This method defines the data type for a specified column.

Parameters
n_columnis the column number
typeis a the type
Returns
an error code

Definition at line 356 of file GenericDbTable.cxx.

357 {
358  if (m_conddbtable.size() > n_column)
359  if (m_conddbtable[n_column]->type == kNull)
360  {
361  m_conddbtable[n_column]->type = type;
362 
363  switch (type)
364  {
365  case kBool:
366  {
367  CondDBColumnBool * tmpColumn = new CondDBColumnBool;
368  tmpColumn->type = m_conddbtable[n_column]->type;
369  tmpColumn->column.push_back(-1);
370  if ((m_conddbtable[n_column]->name.size()))
371  tmpColumn->name = m_conddbtable[n_column]->name;
372 
373  delete(m_conddbtable[n_column]);
374  m_conddbtable[n_column] = tmpColumn;
375  break;
376  }
377  case kInt:
378  {
379  CondDBColumnInt * tmpColumn = new CondDBColumnInt;
380  tmpColumn->type = m_conddbtable[n_column]->type;
381  tmpColumn->column.push_back(NULLINT);
382  if ((m_conddbtable[n_column]->name.size()))
383  tmpColumn->name = m_conddbtable[n_column]->name;
384  delete(m_conddbtable[n_column]);
385  m_conddbtable[n_column] = tmpColumn;
386  break;
387  }
388  case kLongLong:
389  {
390  CondDBColumnLong * tmpColumn = new CondDBColumnLong;
391  tmpColumn->type = m_conddbtable[n_column]->type;
392  tmpColumn->column.push_back(NULLLONG);
393  if ((m_conddbtable[n_column]->name.size()))
394  tmpColumn->name = m_conddbtable[n_column]->name;
395  delete(m_conddbtable[n_column]);
396  m_conddbtable[n_column] = tmpColumn;
397  break;
398  }
399 
400  case kFloat:
401  {
402  CondDBColumnFloat * tmpColumn = new CondDBColumnFloat;
403  tmpColumn->type = m_conddbtable[n_column]->type;
404  tmpColumn->column.push_back(NULLFLOAT);
405  if ((m_conddbtable[n_column]->name.size()))
406  tmpColumn->name = m_conddbtable[n_column]->name;
407  delete(m_conddbtable[n_column]);
408  m_conddbtable[n_column] = tmpColumn;
409  break;
410  }
411  case kString:
412  {
413  CondDBColumnString * tmpColumn = new CondDBColumnString;
414  tmpColumn->type = m_conddbtable[n_column]->type;
415  tmpColumn->column.push_back("NULL");
416  if ((m_conddbtable[n_column]->name.size()))
417  tmpColumn->name = m_conddbtable[n_column]->name;
418 
419  delete(m_conddbtable[n_column]);
420  m_conddbtable[n_column] = tmpColumn;
421  break;
422  }
423  case kDouble:
424  {
425  CondDBColumnDouble * tmpColumn = new CondDBColumnDouble;
426  tmpColumn->type = m_conddbtable[n_column]->type;
427  tmpColumn->column.push_back(NULLDOUBLE);
428  if ((m_conddbtable[n_column]->name.size()))
429  tmpColumn->name = m_conddbtable[n_column]->name;
430 
431  delete(m_conddbtable[n_column]);
432  m_conddbtable[n_column] = tmpColumn;
433  break;
434  }
435  case kArrayInt:
436  {
437  CondDBColumnArrayInt * tmpColumn = new CondDBColumnArrayInt;
438  tmpColumn->type = m_conddbtable[n_column]->type;
439  vector<long int> tmp;
440  tmp.push_back(NULLINT);
441  tmpColumn->column.push_back(tmp);
442  if ((m_conddbtable[n_column]->name.size()))
443  tmpColumn->name = m_conddbtable[n_column]->name;
444  delete(m_conddbtable[n_column]);
445  m_conddbtable[n_column] = tmpColumn;
446  break;
447  }
448  case kArrayLongLong:
449  {
450  CondDBColumnArrayLong * tmpColumn = new CondDBColumnArrayLong;
451  tmpColumn->type = m_conddbtable[n_column]->type;
452  vector<int64> tmp;
453  tmp.push_back(NULLLONG);
454  tmpColumn->column.push_back(tmp);
455  if ((m_conddbtable[n_column]->name.size()))
456  tmpColumn->name = m_conddbtable[n_column]->name;
457  delete(m_conddbtable[n_column]);
458  m_conddbtable[n_column] = tmpColumn;
459  break;
460  }
461  case kArrayBool:
462  {
463  CondDBColumnArrayBool * tmpColumn = new CondDBColumnArrayBool;
464  tmpColumn->type = m_conddbtable[n_column]->type;
465  vector<short int> tmp;
466  tmp.push_back(-1);
467  tmpColumn->column.push_back(tmp);
468  if ((m_conddbtable[n_column]->name.size()))
469  tmpColumn->name = m_conddbtable[n_column]->name;
470  delete(m_conddbtable[n_column]);
471  m_conddbtable[n_column] = tmpColumn;
472  break;
473  }
474  case kArrayFloat:
475  {
476  CondDBColumnArrayFloat * tmpColumn = new CondDBColumnArrayFloat;
477  tmpColumn->type = m_conddbtable[n_column]->type;
479  tmp.push_back(NULLFLOAT);
480  tmpColumn->column.push_back(tmp);
481  if ((m_conddbtable[n_column]->name.size()))
482  tmpColumn->name = m_conddbtable[n_column]->name;
483  delete(m_conddbtable[n_column]);
484  m_conddbtable[n_column] = tmpColumn;
485  break;
486  }
487  case kArrayString:
488  {
489  CondDBColumnArrayString * tmpColumn = new CondDBColumnArrayString;
490  tmpColumn->type = m_conddbtable[n_column]->type;
492  tmp.push_back("NULL");
493  tmpColumn->column.push_back(tmp);
494  if ((m_conddbtable[n_column]->name.size()))
495  tmpColumn->name = m_conddbtable[n_column]->name;
496  delete(m_conddbtable[n_column]);
497  m_conddbtable[n_column] = tmpColumn;
498  break;
499  }
500  case kArrayDouble:
501  {
502  CondDBColumnArrayDouble * tmpColumn = new CondDBColumnArrayDouble;
503  tmpColumn->type = m_conddbtable[n_column]->type;
505  tmp.push_back(NULLDOUBLE);
506  tmpColumn->column.push_back(tmp);
507  if ((m_conddbtable[n_column]->name.size()))
508  tmpColumn->name = m_conddbtable[n_column]->name;
509  delete(m_conddbtable[n_column]);
510  m_conddbtable[n_column] = tmpColumn;
511  break;
512  }
513  default : break;
514  }
515 
516  if (m_conddbtable[n_column]->name.size() != 0)
517  {
518  m_conddbtable[n_column]->initialized = true;
520  }
521  }
522  else
523  return CDB_TYPE_ERROR;
524  else
525  return CDB_RANGE_ERROR;
526  return CDB_SUCCESS;
527 
528 }

◆ ToString()

template<class TYPE >
std::string GenericDbTable::ToString ( const TYPE t) const
inlineprivate

Auxiliary function to convert any value to string.

Parameters
tis the value to be converted
Returns
a string with the value passed.

Definition at line 651 of file GenericDbTable.h.

651  {
652  //CONDDBTABLESTREAM os;
653  std::ostringstream os;
654  os << t;
655  return os.str();
656 }

◆ verifyInitialization()

void GenericDbTable::verifyInitialization ( )
private

Verifies if all columns are initialized.

Definition at line 1763 of file GenericDbTable.cxx.

1764 {
1765  bool aux = true;
1766 
1767  for (unsigned i=0; i< m_conddbtable.size(); i++)
1768  {
1769  if (!(m_conddbtable[i]->initialized))
1770  {
1771  aux = false;
1772  break;
1773  }
1774  }
1775 
1776  if (aux)
1777  m_isInitialized = true;
1778 }

Member Data Documentation

◆ m_conddbtable

std::vector<CondDBColumn*> GenericDbTable::m_conddbtable
private

Definition at line 734 of file GenericDbTable.h.

◆ m_isInitialized

bool GenericDbTable::m_isInitialized
private

Definition at line 733 of file GenericDbTable.h.

◆ m_numRows

unsigned GenericDbTable::m_numRows
private

Definition at line 735 of file GenericDbTable.h.


The documentation for this class was generated from the following files:
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
GenericDbTable::__getCell
int __getCell(unsigned n_column, unsigned n_row, T &ndata, dataTypes type, COLUMN *tmpColumn) const
Templated method that get's the data from a specified cell This is the method that does the real work...
Definition: GenericDbTable.cxx:1781
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
NULLLONG
#define NULLLONG
Definition: GenericDbTable.cxx:18
GenericDbTable::__setCell
int __setCell(unsigned n_column, unsigned n_row, const T &ndata, dataTypes type, COLUMN *tmpColumn)
Templated method that set's the data in a specified cell This is the method that does the real work.
Definition: GenericDbTable.cxx:1807
GenericDbTable::__getCellByName
int __getCellByName(const std::string &colName, unsigned int n_row, T &data) const
Templated method that get's column data using the column name This method get's the desired column nu...
Definition: GenericDbTable.cxx:1870
GenericDbTable::CDB_ALLOC_ERROR
@ CDB_ALLOC_ERROR
Definition: GenericDbTable.h:46
GenericDbTable::kArrayBool
@ kArrayBool
Definition: GenericDbTable.h:32
index
Definition: index.py:1
GenericDbTable::__getNull
int __getNull(T &data, COLUMN *tmpColumn) const
Templated method for handling the null values.
Definition: GenericDbTable.h:595
int64
long long int64
Definition: GenericDbTable.h:17
NULLINT
#define NULLINT
Definition: GenericDbTable.cxx:11
DeMoUpdate.column
dictionary column
Definition: DeMoUpdate.py:1110
atoi64
#define atoi64(x)
Definition: GenericDbTable.cxx:20
GenericDbTable::ToString
std::string ToString(const TYPE &t) const
Auxiliary function to convert any value to string.
Definition: GenericDbTable.h:651
GenericDbTable::kLongLong
@ kLongLong
Definition: GenericDbTable.h:31
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
NULLFLOAT
#define NULLFLOAT
Definition: GenericDbTable.cxx:12
GenericDbTable::kArrayInt
@ kArrayInt
Definition: GenericDbTable.h:34
GenericDbTable::m_conddbtable
std::vector< CondDBColumn * > m_conddbtable
Definition: GenericDbTable.h:734
GenericDbTable::getNames
int getNames(std::vector< std::string > &names) const
This method gets a vector containing the names of all columns in the table.
Definition: GenericDbTable.cxx:85
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:797
GenericDbTable::kArrayLongLong
@ kArrayLongLong
Definition: GenericDbTable.h:37
GenericDbTable::kArrayFloat
@ kArrayFloat
Definition: GenericDbTable.h:33
GenericDbTable::resize
void resize(int num_rows)
Reserves more rows on the table.
Definition: GenericDbTable.cxx:1606
GenericDbTable::m_numRows
unsigned m_numRows
Definition: GenericDbTable.h:735
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
NULLDOUBLE
#define NULLDOUBLE
Definition: GenericDbTable.cxx:13
lumiFormat.i
int i
Definition: lumiFormat.py:92
vector< double >
python.subdetectors.mmg.names
names
Definition: mmg.py:8
GenericDbTable::CDB_SUCCESS
@ CDB_SUCCESS
Definition: GenericDbTable.h:45
GenericDbTable::kString
@ kString
Definition: GenericDbTable.h:29
GenericDbTable::__setColumnData
int __setColumnData(unsigned n_column, T &data, dataTypes type, COLUMN *tmpColumn)
Templated method that set's portions of data in a specified column This method is deprecated and henc...
Definition: GenericDbTable.cxx:1844
GenericDbTable::kArrayDouble
@ kArrayDouble
Definition: GenericDbTable.h:36
GenericDbTable::m_isInitialized
bool m_isInitialized
Definition: GenericDbTable.h:733
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
CxxUtils::atof
double atof(std::string_view str)
Converts a string into a double / float.
Definition: Control/CxxUtils/Root/StringUtils.cxx:91
GenericDbTable::kFloat
@ kFloat
Definition: GenericDbTable.h:28
python.root_lsr_rank.types
types
Definition: root_lsr_rank.py:35
GenericDbTable::getCell
int getCell(unsigned n_column, unsigned n_row, short int &ndata) const
This method gets a value from a cell in a column of long ints (int in MySQL)
Definition: GenericDbTable.cxx:706
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
GenericDbTable::kInt
@ kInt
Definition: GenericDbTable.h:27
GenericDbTable::CDB_RANGE_ERROR
@ CDB_RANGE_ERROR
Definition: GenericDbTable.h:43
GenericDbTable::CDB_TYPE_ERROR
@ CDB_TYPE_ERROR
Definition: GenericDbTable.h:44
GenericDbTable::kDouble
@ kDouble
Definition: GenericDbTable.h:30
DeMoScan.index
string index
Definition: DeMoScan.py:362
GenericDbTable::verifyInitialization
void verifyInitialization()
Verifies if all columns are initialized.
Definition: GenericDbTable.cxx:1763
GenericDbTable::getNull
int getNull(unsigned n_column, float &null) const
Get Null value for column.
Definition: GenericDbTable.cxx:237
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
GenericDbTable::CDB_NOT_INITIALIZED
@ CDB_NOT_INITIALIZED
Definition: GenericDbTable.h:42
GenericDbTable::setColumndata
int setColumndata(unsigned n_column, const std::vector< short int > &data)
The following methods allow to insert in the columns a group of values.
Definition: GenericDbTable.cxx:1203
GenericDbTable::kArrayString
@ kArrayString
Definition: GenericDbTable.h:35
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
merge.status
status
Definition: merge.py:17
GenericDbTable::kBool
@ kBool
Definition: GenericDbTable.h:26
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
GenericDbTable::kNull
@ kNull
Definition: GenericDbTable.h:25
GenericDbTable::CDB_STRTOARRAY_ERROR
@ CDB_STRTOARRAY_ERROR
Definition: GenericDbTable.h:47
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35