ATLAS Offline Software
Classes | Public Member Functions | Private Attributes | List of all members
columnar::ToolColumnVectorMap Class Referencefinal

a class that interfaces an IColumnarTool to a ColumnVectorHeader More...

#include <ToolColumnVectorMap.h>

Collaboration diagram for columnar::ToolColumnVectorMap:

Classes

struct  MyColumnInfo
 my cached information for the various columns needed More...
 

Public Member Functions

 ToolColumnVectorMap (ColumnVectorHeader &val_columnHeader, IColumnarTool &val_tool)
 standard constructor More...
 
const IColumnarToolgetTool () const
 get the wrapped tool More...
 
const ColumnVectorHeadergetColumnHeader () const
 get the header information for the various columns needed More...
 
std::vector< std::string > getColumnNames () const
 get the list of all defined columns More...
 
std::size_t getColumnIndex (const std::string &name) const
 get the index for the column with the given name More...
 
template<typename CT >
void setColumn (ColumnVectorData &columnData, const std::string &name, std::size_t size, CT *dataPtr) const
 set the data for the given column picking up the type via a template More...
 
void setColumnVoid (ColumnVectorData &columnData, const std::string &name, std::size_t size, const void *dataPtr, const std::type_info &type, bool isConst) const
 set the data for the given column with the user passing in the type More...
 
template<typename CT >
std::pair< std::size_t, CT * > getColumn (ColumnVectorData &columnData, const std::string &name) const
 get the data for the given column picking up the type via a template More...
 
std::pair< std::size_t, const void * > getColumnVoid (ColumnVectorData &columnData, const std::string &name, const std::type_info *type, bool isConst) const
 get the data for the given column in a type-erased manner More...
 

Private Attributes

const IColumnarToolm_tool = nullptr
 the wrapped tool More...
 
ColumnVectorHeaderm_columnHeader = nullptr
 the header information for the various columns needed More...
 
std::unordered_map< std::string, MyColumnInfom_columns
 

Detailed Description

a class that interfaces an IColumnarTool to a ColumnVectorHeader

This takes care of registering all the columns needed by the tool, storing the name-index map, and setting the column indices in the tool.

This class does not try to take care of any tool management, or working with the ColumnVectorData. It does provide some helpers implemented using its own public interface, but this is just for convenience.

Definition at line 29 of file ToolColumnVectorMap.h.

Constructor & Destructor Documentation

◆ ToolColumnVectorMap()

columnar::ToolColumnVectorMap::ToolColumnVectorMap ( ColumnVectorHeader val_columnHeader,
IColumnarTool val_tool 
)
explicit

standard constructor

Public Members

configure all the columns for it, and set the proper column indices in the tool.

Definition at line 25 of file ToolColumnVectorMap.cxx.

27  : m_tool (&val_tool), m_columnHeader (&val_columnHeader)
28  {
29  auto toolColumns = m_tool->getColumnInfo();
30  for (auto& column : toolColumns)
31  {
32  const std::size_t columnIndex = m_columnHeader->addColumn (column);
33 
34  MyColumnInfo myinfo;
35  myinfo.index = columnIndex;
36  val_tool.setColumnIndex (column.name, myinfo.index);
37 
38  auto [iter, success] = m_columns.emplace (column.name, std::move (myinfo));
39  if (!success)
40  throw std::runtime_error ("column name already registered: " + column.name);
41  }
42 
43  for (auto& column : toolColumns)
44  {
45  if (!column.offsetName.empty())
46  {
47  auto offsetIter = m_columns.find (column.offsetName);
48  if (offsetIter == m_columns.end())
49  throw std::runtime_error ("offset column name not found: " + column.offsetName);
50  m_columnHeader->setOffsetColumn (m_columns.at (column.name).index, offsetIter->second.index);
51  }
52  }
53 
54  // final consistency check
56  }

Member Function Documentation

◆ getColumn()

template<typename CT >
std::pair<std::size_t,CT*> columnar::ToolColumnVectorMap::getColumn ( ColumnVectorData columnData,
const std::string &  name 
) const
inline

get the data for the given column picking up the type via a template

Definition at line 94 of file ToolColumnVectorMap.h.

94  {
95  return columnData.getColumn<CT> (getColumnIndex(name));
96  }

◆ getColumnHeader()

const ColumnVectorHeader& columnar::ToolColumnVectorMap::getColumnHeader ( ) const
inline

get the header information for the various columns needed

Definition at line 49 of file ToolColumnVectorMap.h.

49  {
50  return *m_columnHeader; }

◆ getColumnIndex()

std::size_t columnar::ToolColumnVectorMap::getColumnIndex ( const std::string &  name) const

get the index for the column with the given name

This is mostly to share the lookup code, as well as the proper error handling.

Definition at line 72 of file ToolColumnVectorMap.cxx.

74  {
75  auto column = m_columns.find (name);
76  if (column == m_columns.end())
77  throw std::runtime_error ("trying to access unknown column " + name + " on tool");
78  return column->second.index;
79  }

◆ getColumnNames()

std::vector< std::string > columnar::ToolColumnVectorMap::getColumnNames ( ) const

get the list of all defined columns

This is mostly to make it easy for the caller to know which columns are defined. For more complete information ask the tool directly for the vector of ColumnInfo.

Definition at line 60 of file ToolColumnVectorMap.cxx.

62  {
63  std::vector<std::string> result;
64  for (auto& column : m_columns)
65  result.push_back (column.first);
66  std::sort (result.begin(), result.end());
67  return result;
68  }

◆ getColumnVoid()

std::pair<std::size_t,const void*> columnar::ToolColumnVectorMap::getColumnVoid ( ColumnVectorData columnData,
const std::string &  name,
const std::type_info *  type,
bool  isConst 
) const
inline

get the data for the given column in a type-erased manner

Definition at line 100 of file ToolColumnVectorMap.h.

100  {
101  return columnData.getColumnVoid (getColumnIndex(name), type, isConst);
102  }

◆ getTool()

const IColumnarTool& columnar::ToolColumnVectorMap::getTool ( ) const
inline

get the wrapped tool

Definition at line 45 of file ToolColumnVectorMap.h.

45  {
46  return *m_tool; }

◆ setColumn()

template<typename CT >
void columnar::ToolColumnVectorMap::setColumn ( ColumnVectorData columnData,
const std::string &  name,
std::size_t  size,
CT dataPtr 
) const
inline

set the data for the given column picking up the type via a template

Forwarding MemberFunctions

These function are just forwarding to ColumnVectorHeader and ColumnVectorData. These are just here to make use easier and insulate the user from changes (Law of Demeter).

Definition at line 79 of file ToolColumnVectorMap.h.

79  {
80  columnData.setColumn (getColumnIndex(name), size, dataPtr);
81  }

◆ setColumnVoid()

void columnar::ToolColumnVectorMap::setColumnVoid ( ColumnVectorData columnData,
const std::string &  name,
std::size_t  size,
const void *  dataPtr,
const std::type_info &  type,
bool  isConst 
) const
inline

set the data for the given column with the user passing in the type

Definition at line 85 of file ToolColumnVectorMap.h.

85  {
86  columnData.setColumnVoid (getColumnIndex(name), size, dataPtr, type, isConst);
87  }

Member Data Documentation

◆ m_columnHeader

ColumnVectorHeader* columnar::ToolColumnVectorMap::m_columnHeader = nullptr
private

the header information for the various columns needed

Definition at line 115 of file ToolColumnVectorMap.h.

◆ m_columns

std::unordered_map<std::string,MyColumnInfo> columnar::ToolColumnVectorMap::m_columns
private

Definition at line 122 of file ToolColumnVectorMap.h.

◆ m_tool

const IColumnarTool* columnar::ToolColumnVectorMap::m_tool = nullptr
private

the wrapped tool

Private Members

Definition at line 112 of file ToolColumnVectorMap.h.


The documentation for this class was generated from the following files:
createLinkingScheme.iter
iter
Definition: createLinkingScheme.py:62
get_generator_info.result
result
Definition: get_generator_info.py:21
columnar::ColumnVectorHeader::checkSelf
void checkSelf() const
check the self-consistency of the header
Definition: ColumnVectorWrapper.cxx:98
columnar::ToolColumnVectorMap::m_tool
const IColumnarTool * m_tool
the wrapped tool
Definition: ToolColumnVectorMap.h:112
columnar::ToolColumnVectorMap::m_columns
std::unordered_map< std::string, MyColumnInfo > m_columns
Definition: ToolColumnVectorMap.h:122
DeMoUpdate.column
dictionary column
Definition: DeMoUpdate.py:1110
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
columnar::ColumnVectorHeader::addColumn
std::size_t addColumn(const ColumnInfo &columnInfo)
add a column for the given ColumnInfo, returning its index
Definition: ColumnVectorWrapper.cxx:47
columnar::IColumnarTool::getColumnInfo
virtual std::vector< ColumnInfo > getColumnInfo() const =0
the meta-information for the columns
columnar::size
std::size_t size() const noexcept
Definition: ObjectRange.h:166
columnar::ToolColumnVectorMap::m_columnHeader
ColumnVectorHeader * m_columnHeader
the header information for the various columns needed
Definition: ToolColumnVectorMap.h:115
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
columnar::CT
CT
Definition: ColumnAccessor.h:160
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
columnar::ToolColumnVectorMap::getColumnIndex
std::size_t getColumnIndex(const std::string &name) const
get the index for the column with the given name
Definition: ToolColumnVectorMap.cxx:73
columnar::ColumnVectorHeader::setOffsetColumn
void setOffsetColumn(std::size_t columnIndex, std::size_t offsetIndex)
set the index of the offset column for the given column
Definition: ColumnVectorWrapper.cxx:80