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 1762 of file GenericDbTable.cxx.

1763 {
1764 
1765  if (!m_isInitialized)
1766  return CDB_NOT_INITIALIZED;
1767 
1768  if ((m_numRows > n_row) && (m_conddbtable.size() > n_column))
1769  {
1770  if (m_conddbtable[n_column]->type == type)
1771  {
1772  if (tmpColumn->column.size() <= n_row)
1773  ndata = tmpColumn->column.back();
1774  else
1775  ndata = tmpColumn->column[n_row+1];
1776  }
1777 
1778  else
1779  return CDB_TYPE_ERROR;
1780  }
1781  else
1782  return CDB_RANGE_ERROR;
1783 
1784  return CDB_SUCCESS;
1785 }

◆ __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 1851 of file GenericDbTable.cxx.

1852 {
1853  for (unsigned int i=0; i< m_conddbtable.size(); i++) {
1854  if (m_conddbtable[i]->name == colName)
1855  {
1856  return getCell(i,n_row,data);
1857  }
1858  }
1859  //if there's no column with this name return error
1860  return CDB_RANGE_ERROR;
1861 }

◆ __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 1788 of file GenericDbTable.cxx.

1789  {
1790  if (!m_isInitialized)
1791  return CDB_NOT_INITIALIZED;
1792 
1793  if ((m_numRows > n_row) && (m_conddbtable.size() > n_column))
1794  {
1795  if (m_conddbtable[n_column]->type == type)
1796  {
1797  // static_cast<COLUMN*>(m_conddbtable[n_column])->column[n_row+1] = ndata;
1798  if (tmpColumn->column.size() == (n_row+1))
1799  tmpColumn->column.push_back(ndata);
1800  else
1801  if (tmpColumn->column.size() < (n_row+1))
1802  {
1803  T tmp = tmpColumn->column.back();
1804 
1805  while((n_row)-tmpColumn->column.size())
1806  {
1807  tmpColumn->column.push_back(tmp);
1808  }
1809  tmpColumn->column.push_back(ndata);
1810  }
1811  else
1812  // if the cell already has a value
1813  tmpColumn->column[n_row+1] = ndata;
1814 
1815  return CDB_SUCCESS;
1816  }
1817  else
1818  return CDB_TYPE_ERROR;
1819  }
1820  else
1821  return CDB_RANGE_ERROR;
1822  }

◆ __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 1825 of file GenericDbTable.cxx.

1826 {
1827  if (!m_isInitialized)
1828  return CDB_NOT_INITIALIZED;
1829 
1830  unsigned index = 0;
1831  if (n_column < m_conddbtable.size())
1832  {
1833  if (m_conddbtable[n_column]->type == type)
1834  {
1835  while((tmpColumn->column.size() < m_numRows+1) && (index < data.size()))
1836  {
1837  tmpColumn->column.push_back(data[index]);
1838  index++;
1839  }
1840  return index;
1841 
1842  }
1843  else
1844  return CDB_TYPE_ERROR;
1845  }
1846  else
1847  return CDB_RANGE_ERROR;
1848 }

◆ getCell() [1/24]

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

Definition at line 846 of file GenericDbTable.cxx.

847 {
848  return __getCellByName<double>(colName, n_row, data);
849 }

◆ getCell() [2/24]

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

Definition at line 842 of file GenericDbTable.cxx.

843 {
844  return __getCellByName<float>(colName,n_row,data);
845 }

◆ getCell() [3/24]

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

Definition at line 838 of file GenericDbTable.cxx.

839 {
840  return __getCellByName<int64>(colName, n_row, data);
841 }

◆ getCell() [4/24]

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

Definition at line 834 of file GenericDbTable.cxx.

835 {
836 return __getCellByName<long int>(colName, n_row, data);
837 }

◆ 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 829 of file GenericDbTable.cxx.

830 {
831  return __getCellByName(colName,n_row,data);
832 }

◆ getCell() [6/24]

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

Definition at line 850 of file GenericDbTable.cxx.

851 {
852  return __getCellByName<std::string>(colName, n_row, data);
853 }

◆ getCell() [7/24]

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

Definition at line 870 of file GenericDbTable.cxx.

871 {
872  return __getCellByName<std::vector<double> >(colName, n_row, data);
873 }

◆ getCell() [8/24]

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

Definition at line 866 of file GenericDbTable.cxx.

867 {
868  return __getCellByName<std::vector<float> >(colName, n_row, data);
869 }

◆ getCell() [9/24]

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

Definition at line 862 of file GenericDbTable.cxx.

863 {
864  return __getCellByName<std::vector<int64> >(colName, n_row, data);
865 }

◆ getCell() [10/24]

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

Definition at line 858 of file GenericDbTable.cxx.

859 {
860  return __getCellByName<std::vector<long int> >(colName, n_row, data);
861 }

◆ getCell() [11/24]

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

Definition at line 854 of file GenericDbTable.cxx.

855 {
856  return __getCellByName< std::vector<short int> >(colName, n_row, data);
857 }

◆ getCell() [12/24]

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

Definition at line 874 of file GenericDbTable.cxx.

875 {
876  return __getCellByName<std::vector<string> >(colName, n_row, data);
877 }

◆ 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 783 of file GenericDbTable.cxx.

784 {
785  CondDBColumnDouble *tmpColumn = static_cast<CondDBColumnDouble*>(m_conddbtable[n_column]);
786  return __getCell(n_column, n_row, ndata, kDouble, tmpColumn);
787 }

◆ 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 700 of file GenericDbTable.cxx.

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

◆ 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 693 of file GenericDbTable.cxx.

694 {
695  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
696  return __getCell(n_column, n_row, ndata, kLongLong, tmpColumn);
697 }

◆ 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 681 of file GenericDbTable.cxx.

682 {
683  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
684  return __getCell(n_column, n_row, ndata, kInt, tmpColumn);
685 }

◆ 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 687 of file GenericDbTable.cxx.

688 {
689  CondDBColumnBool *tmpColumn = static_cast<CondDBColumnBool*>(m_conddbtable[n_column]);
690  return __getCell(n_column, n_row, ndata, kBool, tmpColumn);
691 }

◆ 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 706 of file GenericDbTable.cxx.

707 {
708 
709  int status;
710 
711  if (!m_isInitialized)
712  return CDB_NOT_INITIALIZED;
713 
714  if ((m_numRows > n_row) && (m_conddbtable.size() > n_column))
715  {
716  if (m_conddbtable[n_column]->type == kString) {
717  CondDBColumnString *tmpColumn = static_cast<CondDBColumnString*>(m_conddbtable[n_column]);
718  return __getCell(n_column, n_row, ndata, kString, tmpColumn);
719  }
720  else {
721  switch(m_conddbtable[n_column]->type)
722  {
723  case kInt:
724  {
725  long int aux;
726  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
727  status = __getCell(n_column, n_row, aux , kInt, tmpColumn);
728  if (status == CDB_SUCCESS)
729  ndata = ToString(aux);
730  break;
731  }
732  case kBool:
733  {
734  short int aux;
735  CondDBColumnBool *tmpColumn = static_cast<CondDBColumnBool*>(m_conddbtable[n_column]);
736  status = __getCell(n_column, n_row, aux, kBool, tmpColumn);
737  if (status == CDB_SUCCESS)
738  ndata = ToString(aux);
739  break;
740  }
741 
742  case kLongLong:
743  {
744  long long aux;
745  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
746  status = __getCell(n_column,n_row, aux, kLongLong, tmpColumn);
747  if (status == CDB_SUCCESS)
748  ndata = ToString(aux);
749  break;
750  }
751  case kFloat:
752  {
753  float aux;
754 
755  CondDBColumnFloat *tmpColumn = static_cast<CondDBColumnFloat*>(m_conddbtable[n_column]);
756  status = __getCell(n_column,n_row, aux, kFloat, tmpColumn);
757  if (status == CDB_SUCCESS)
758  ndata = ToString(aux);
759  break;
760  }
761  case kDouble:
762  {
763  double aux;
764  CondDBColumnDouble *tmpColumn = static_cast<CondDBColumnDouble*>(m_conddbtable[n_column]);
765  status = __getCell(n_column,n_row,aux,kDouble, tmpColumn);
766  if (status == CDB_SUCCESS)
767  ndata = ToString(aux);
768  break;
769  }
770  //if the column is of the type array of *type* one should use the method with vector of strings
771  default:
772  return CDB_STRTOARRAY_ERROR;
773  }
774  }
775  }
776  else
777  return CDB_RANGE_ERROR;
778 
779  return status;
780 
781 }

◆ 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 801 of file GenericDbTable.cxx.

802 {
803  CondDBColumnArrayLong *tmpColumn = static_cast<CondDBColumnArrayLong*>(m_conddbtable[n_column]);
804  return __getCell(n_column, n_row, ndata, kArrayLongLong, tmpColumn);
805 }

◆ 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 789 of file GenericDbTable.cxx.

790 {
791  CondDBColumnArrayInt *tmpColumn = static_cast<CondDBColumnArrayInt*>(m_conddbtable[n_column]);
792  return __getCell(n_column, n_row, ndata, kArrayInt, tmpColumn);
793 }

◆ 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 795 of file GenericDbTable.cxx.

796 {
797  CondDBColumnArrayBool *tmpColumn = static_cast<CondDBColumnArrayBool*>(m_conddbtable[n_column]);
798  return __getCell(n_column, n_row, ndata, kArrayBool, tmpColumn);
799 }

◆ 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 813 of file GenericDbTable.cxx.

814 {
815  CondDBColumnArrayString *tmpColumn = static_cast<CondDBColumnArrayString*>(m_conddbtable[n_column]);
816  return __getCell(n_column, n_row, ndata, kArrayString, tmpColumn);
817 }

◆ 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 1597 of file GenericDbTable.cxx.

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

◆ 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 1587 of file GenericDbTable.cxx.

1588 {
1589  m_numRows += num_rows;
1590 }

◆ 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 1007 of file GenericDbTable.cxx.

1008 {
1009  CondDBColumnDouble *tmpColumn = static_cast<CondDBColumnDouble*>(m_conddbtable[n_column]);
1010  return __setCell(n_column, n_row, ndata, kDouble, tmpColumn);
1011 }

◆ 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 902 of file GenericDbTable.cxx.

903 {
904  CondDBColumnFloat *tmpColumn = static_cast<CondDBColumnFloat*>(m_conddbtable[n_column]);
905  return __setCell(n_column, n_row, ndata, kFloat, tmpColumn);
906 }

◆ 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 896 of file GenericDbTable.cxx.

897 {
898  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
899  return __setCell(n_column, n_row, ndata, kLongLong, tmpColumn);
900 }

◆ 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 884 of file GenericDbTable.cxx.

885 {
886  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
887  return __setCell(n_column, n_row, ndata, kInt, tmpColumn);
888 }

◆ 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 890 of file GenericDbTable.cxx.

891 {
892  CondDBColumnBool *tmpColumn = static_cast<CondDBColumnBool*>(m_conddbtable[n_column]);
893  return __setCell(n_column, n_row, ndata, kBool, tmpColumn);
894 }

◆ 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 908 of file GenericDbTable.cxx.

909 {
910 
911  if (!m_isInitialized)
912  return CDB_NOT_INITIALIZED;
913 
914  if ((m_numRows > n_row) && (m_conddbtable.size() > n_column))
915  {
916  if (m_conddbtable[n_column]->type == kString)
917  {
918  CondDBColumnString *tmpColumn = static_cast<CondDBColumnString*>(m_conddbtable[n_column]);
919  __setCell(n_column, n_row, ndata, kString, tmpColumn);
920  }
921  else
922  {
923  switch(m_conddbtable[n_column]->type)
924  {
925  case kInt:
926  {
927  if (ndata=="NULL")
928  {
929  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
930  __setCell(n_column, n_row, tmpColumn->column[0], kInt, tmpColumn);
931  }
932  else
933  {
934  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
935  __setCell(n_column, n_row, atol(ndata.c_str()), kInt, tmpColumn);
936  }
937  break;
938  }
939  case kBool:
940  {
941  if (ndata=="NULL")
942  {
943  CondDBColumnBool *tmpColumn = static_cast<CondDBColumnBool*>(m_conddbtable[n_column]);
944  __setCell(n_column,n_row, tmpColumn->column[0], kBool, tmpColumn);
945 
946  }
947  else
948  {
949  CondDBColumnBool *tmpColumn = static_cast<CondDBColumnBool*>(m_conddbtable[n_column]);
950  __setCell(n_column, n_row, atoi(ndata.c_str()), kBool, tmpColumn);
951  }
952  break;
953  }
954  case kLongLong:
955  {
956  if (ndata=="NULL")
957  {
958  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
959  __setCell(n_column,n_row, tmpColumn->column[0], kLongLong, tmpColumn);
960  }
961  else
962  {
963  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
964  __setCell(n_column,n_row, atoi64(ndata.c_str()), kLongLong, tmpColumn);
965  }
966  break;
967  }
968  case kFloat:
969  {
970  if (ndata=="NULL")
971  {
972  CondDBColumnFloat *tmpColumn = static_cast<CondDBColumnFloat*>(m_conddbtable[n_column]);
973  __setCell(n_column,n_row, tmpColumn->column[0], kFloat, tmpColumn);
974  }
975  else
976  {
977  CondDBColumnFloat *tmpColumn = static_cast<CondDBColumnFloat*>(m_conddbtable[n_column]);
978  __setCell(n_column,n_row, strtod(ndata.c_str(), (char **)NULL), kFloat, tmpColumn);
979  }
980  break;
981  }
982  case kDouble:
983  {
984  if (ndata=="NULL")
985  {
986  CondDBColumnDouble *tmpColumn = static_cast<CondDBColumnDouble*>(m_conddbtable[n_column]);
987  __setCell(n_column,n_row, tmpColumn->column[0],kDouble, tmpColumn);
988  }
989  else
990  {
991  CondDBColumnDouble *tmpColumn = static_cast<CondDBColumnDouble*>(m_conddbtable[n_column]);
992  __setCell(n_column,n_row,strtod(ndata.c_str(), (char **)NULL),kDouble, tmpColumn);
993  }
994  break;
995  }
996  //if the column is of the type array of *type* one should use the method with vector of strings
997  default:
998  return CDB_STRTOARRAY_ERROR;
999  }
1000  }
1001  }
1002  else
1003  return CDB_RANGE_ERROR;
1004  return CDB_SUCCESS;
1005 }

◆ 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 1025 of file GenericDbTable.cxx.

1026 {
1027  CondDBColumnArrayLong *tmpColumn = static_cast<CondDBColumnArrayLong*>(m_conddbtable[n_column]);
1028  return __setCell(n_column, n_row, ndata, kArrayLongLong, tmpColumn);
1029 }

◆ 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 1019 of file GenericDbTable.cxx.

1020 {
1021  CondDBColumnArrayInt *tmpColumn = static_cast<CondDBColumnArrayInt*>(m_conddbtable[n_column]);
1022  return __setCell(n_column, n_row, ndata, kArrayInt, tmpColumn);
1023 }

◆ 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 1013 of file GenericDbTable.cxx.

1014 {
1015  CondDBColumnArrayBool *tmpColumn = static_cast<CondDBColumnArrayBool*>(m_conddbtable[n_column]);
1016  return __setCell(n_column, n_row, ndata, kArrayBool, tmpColumn);
1017 }

◆ 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 1045 of file GenericDbTable.cxx.

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

◆ 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 1178 of file GenericDbTable.cxx.

1179 {
1180  CondDBColumnLong *tmpColumn = static_cast<CondDBColumnLong*>(m_conddbtable[n_column]);
1181  return __setColumnData(n_column, data, kLongLong, tmpColumn);
1182 }

◆ 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 1172 of file GenericDbTable.cxx.

1173 {
1174  CondDBColumnInt *tmpColumn = static_cast<CondDBColumnInt*>(m_conddbtable[n_column]);
1175  return __setColumnData(n_column, data, kInt, tmpColumn);
1176 }

◆ 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 1184 of file GenericDbTable.cxx.

1185 {
1186  CondDBColumnBool *tmpColumn = static_cast<CondDBColumnBool*>(m_conddbtable[n_column]);
1187  return __setColumnData(n_column, data, kBool, tmpColumn);
1188 }

◆ 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 1196 of file GenericDbTable.cxx.

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

◆ 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 1414 of file GenericDbTable.cxx.

1415 {
1416  CondDBColumnArrayLong *tmpColumn = static_cast<CondDBColumnArrayLong*>(m_conddbtable[n_column]);
1417  return __setColumnData(n_column, data, kArrayLongLong, tmpColumn);
1418 }

◆ 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 1408 of file GenericDbTable.cxx.

1409 {
1410  CondDBColumnArrayInt *tmpColumn = static_cast<CondDBColumnArrayInt*>(m_conddbtable[n_column]);
1411  return __setColumnData(n_column, data, kArrayInt, tmpColumn);
1412 }

◆ 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 1420 of file GenericDbTable.cxx.

1421 {
1422  CondDBColumnArrayBool *tmpColumn = static_cast<CondDBColumnArrayBool*>(m_conddbtable[n_column]);
1423  return __setColumnData(n_column, data, kArrayBool, tmpColumn);
1424 }

◆ 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 1438 of file GenericDbTable.cxx.

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

◆ 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 656 of file GenericDbTable.cxx.

657 {
658  if (!m_isInitialized)
659  return CDB_NOT_INITIALIZED;
660 
661  if (m_conddbtable.size() > n_column)
662  if (m_conddbtable[n_column]->type == kDouble || m_conddbtable[n_column]->type == kArrayDouble)
663  {
664  static_cast<CondDBColumnDouble*>(m_conddbtable[n_column])->column[0] = null;
665  return CDB_SUCCESS;
666  }
667  else if (m_conddbtable[n_column]->type == kArrayDouble)
668  {
669  static_cast<CondDBColumnArrayDouble*>(m_conddbtable[n_column])->column[0] = vector<double> (1, null);
670  return CDB_SUCCESS;
671  }
672  else
673  return CDB_TYPE_ERROR;
674  else
675  return CDB_RANGE_ERROR;
676 }

◆ setNull() [2/5]

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

Set Null value for column.

Definition at line 634 of file GenericDbTable.cxx.

635 {
636  if (!m_isInitialized)
637  return CDB_NOT_INITIALIZED;
638 
639  if (m_conddbtable.size() > n_column)
640  if (m_conddbtable[n_column]->type == kFloat )
641  {
642  static_cast<CondDBColumnFloat*>(m_conddbtable[n_column])->column[0] = null;
643  return CDB_SUCCESS;
644  }
645  else if (m_conddbtable[n_column]->type == kArrayFloat)
646  {
647  static_cast<CondDBColumnArrayFloat*>(m_conddbtable[n_column])->column[0] = vector<float> (1,null);
648  return CDB_SUCCESS;
649  }
650  else
651  return CDB_TYPE_ERROR;
652  else
653  return CDB_RANGE_ERROR;
654 }

◆ setNull() [3/5]

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

Definition at line 612 of file GenericDbTable.cxx.

613 {
614  if (!m_isInitialized)
615  return CDB_NOT_INITIALIZED;
616 
617  if (m_conddbtable.size() > n_column)
618  if (m_conddbtable[n_column]->type == kLongLong )
619  {
620  static_cast<CondDBColumnLong*>(m_conddbtable[n_column])->column[0] = null;
621  return CDB_SUCCESS;
622  }
623  else if (m_conddbtable[n_column]->type == kArrayLongLong)
624  {
625  static_cast<CondDBColumnArrayLong*>(m_conddbtable[n_column])->column[0] = vector<int64> (1,null);
626  return CDB_SUCCESS;
627  }
628  else
629  return CDB_TYPE_ERROR;
630  else
631  return CDB_RANGE_ERROR;
632 }

◆ setNull() [4/5]

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

Definition at line 590 of file GenericDbTable.cxx.

591 {
592  if (!m_isInitialized)
593  return CDB_NOT_INITIALIZED;
594 
595  if (m_conddbtable.size() > n_column)
596  if (m_conddbtable[n_column]->type == kInt)
597  {
598  static_cast<CondDBColumnInt*>(m_conddbtable[n_column])->column[0] = null;
599  return CDB_SUCCESS;
600  }
601  else if (m_conddbtable[n_column]->type == kArrayInt)
602  {
603  static_cast<CondDBColumnArrayInt*>(m_conddbtable[n_column])->column[0] = vector<long int> (1,null);
604  return CDB_SUCCESS;
605  }
606  else
607  return CDB_TYPE_ERROR;
608  else
609  return CDB_RANGE_ERROR;
610 }

◆ setNull() [5/5]

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

Definition at line 520 of file GenericDbTable.cxx.

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

◆ 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  tmpColumn->column.push_back({NULLINT});
440  if ((m_conddbtable[n_column]->name.size()))
441  tmpColumn->name = m_conddbtable[n_column]->name;
442  delete(m_conddbtable[n_column]);
443  m_conddbtable[n_column] = tmpColumn;
444  break;
445  }
446  case kArrayLongLong:
447  {
448  CondDBColumnArrayLong * tmpColumn = new CondDBColumnArrayLong;
449  tmpColumn->type = m_conddbtable[n_column]->type;
450  tmpColumn->column.push_back({NULLLONG});
451  if ((m_conddbtable[n_column]->name.size()))
452  tmpColumn->name = m_conddbtable[n_column]->name;
453  delete(m_conddbtable[n_column]);
454  m_conddbtable[n_column] = tmpColumn;
455  break;
456  }
457  case kArrayBool:
458  {
459  CondDBColumnArrayBool * tmpColumn = new CondDBColumnArrayBool;
460  tmpColumn->type = m_conddbtable[n_column]->type;
461  tmpColumn->column.push_back({-1});
462  if ((m_conddbtable[n_column]->name.size()))
463  tmpColumn->name = m_conddbtable[n_column]->name;
464  delete(m_conddbtable[n_column]);
465  m_conddbtable[n_column] = tmpColumn;
466  break;
467  }
468  case kArrayFloat:
469  {
470  CondDBColumnArrayFloat * tmpColumn = new CondDBColumnArrayFloat;
471  tmpColumn->type = m_conddbtable[n_column]->type;
472  tmpColumn->column.push_back({NULLFLOAT});
473  if ((m_conddbtable[n_column]->name.size()))
474  tmpColumn->name = m_conddbtable[n_column]->name;
475  delete(m_conddbtable[n_column]);
476  m_conddbtable[n_column] = tmpColumn;
477  break;
478  }
479  case kArrayString:
480  {
481  CondDBColumnArrayString * tmpColumn = new CondDBColumnArrayString;
482  tmpColumn->type = m_conddbtable[n_column]->type;
484  tmp.push_back("NULL");
485  tmpColumn->column.push_back({"NULL"});
486  if ((m_conddbtable[n_column]->name.size()))
487  tmpColumn->name = m_conddbtable[n_column]->name;
488  delete(m_conddbtable[n_column]);
489  m_conddbtable[n_column] = tmpColumn;
490  break;
491  }
492  case kArrayDouble:
493  {
494  CondDBColumnArrayDouble * tmpColumn = new CondDBColumnArrayDouble;
495  tmpColumn->type = m_conddbtable[n_column]->type;
496  tmpColumn->column.push_back({NULLDOUBLE});
497  if ((m_conddbtable[n_column]->name.size()))
498  tmpColumn->name = m_conddbtable[n_column]->name;
499  delete(m_conddbtable[n_column]);
500  m_conddbtable[n_column] = tmpColumn;
501  break;
502  }
503  default : break;
504  }
505 
506  if (m_conddbtable[n_column]->name.size() != 0)
507  {
508  m_conddbtable[n_column]->initialized = true;
510  }
511  }
512  else
513  return CDB_TYPE_ERROR;
514  else
515  return CDB_RANGE_ERROR;
516  return CDB_SUCCESS;
517 
518 }

◆ 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 1744 of file GenericDbTable.cxx.

1745 {
1746  bool aux = true;
1747 
1748  for (unsigned i=0; i< m_conddbtable.size(); i++)
1749  {
1750  if (!(m_conddbtable[i]->initialized))
1751  {
1752  aux = false;
1753  break;
1754  }
1755  }
1756 
1757  if (aux)
1758  m_isInitialized = true;
1759 }

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:1762
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:1788
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:1851
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
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
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:808
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:1587
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:85
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:1825
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:687
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
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
python.CaloAddPedShiftConfig.default
default
Definition: CaloAddPedShiftConfig.py:43
GenericDbTable::verifyInitialization
void verifyInitialization()
Verifies if all columns are initialized.
Definition: GenericDbTable.cxx:1744
GenericDbTable::getNull
int getNull(unsigned n_column, float &null) const
Get Null value for column.
Definition: GenericDbTable.cxx:237
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:1184
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
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:16
GenericDbTable::kBool
@ kBool
Definition: GenericDbTable.h:26
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