Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
Euclid::Configuration::CatalogConfig Class Reference

Configuration class for enabling catalog input. More...

#include <CatalogConfig.h>

Inheritance diagram for Euclid::Configuration::CatalogConfig:
Inheritance graph
[legend]
Collaboration diagram for Euclid::Configuration::CatalogConfig:
Collaboration graph
[legend]

Public Types

using TableToCatalogConverter = std::function< SourceCatalog::Catalog(const Table::Table &)>
 
- Public Types inherited from Euclid::Configuration::Configuration
enum class  State { CONSTRUCTED , PRE_INITIALIZED , INITIALIZED , FINAL }
 Defines the different states the configuration object can be in. More...
 
using OptionDescriptionList = std::vector< boost::program_options::option_description >
 
using UserValues = std::map< std::string, boost::program_options::variable_value >
 

Public Member Functions

 CatalogConfig (long manager_id)
 Constructs a new CatalogConfig object.
 
virtual ~CatalogConfig ()=default
 Destructor.
 
std::map< std::string, OptionDescriptionListgetProgramOptions () override
 Returns the program options defined by the CatalogConfig.
 
void preInitialize (const UserValues &args) override
 Checks that all the options are valid. See the exceptions thrown for a detailed list of the checks.
 
void initialize (const UserValues &args) override
 Initializes the CatalogConfig instance.
 
void setBaseDir (const boost::filesystem::path &base_dir)
 Sets the directory used when resolving relative paths.
 
void addAttributeHandler (std::shared_ptr< SourceCatalog::AttributeFromRow > handler)
 Adds an attribute handler which will be used for adding attributes at the catalog objects.
 
std::unique_ptr< Table::TableReadergetTableReader () const
 
std::shared_ptr< Table::ColumnInfogetColumnInfo () const
 
std::string getIdColumn () const
 
TableToCatalogConverter getTableToCatalogConverter () const
 
Table::Table readAsTable () const
 Returns the catalog as a Table::Table object.
 
SourceCatalog::Catalog readAsCatalog () const
 Returns the Catalog object.
 
const boost::filesystem::path & getFilename () const
 Returns the filename of the input catalog.
 
- Public Member Functions inherited from Euclid::Configuration::Configuration
 Configuration (long manager_id)
 Constructs a new Configuration instance.
 
virtual ~Configuration ()=default
 Destructor.
 
virtual void postInitialize (const UserValues &args)
 Method which is called after the initialization phase.
 
const std::set< std::type_index > & getDependencies ()
 Returns the dependencies of the configuration.
 
StategetCurrentState ()
 Returns the current state of the configuration.
 
State getCurrentState () const
 Returns the current state of the configuration.
 

Private Attributes

boost::filesystem::path m_base_dir
 
boost::filesystem::path m_filename
 
bool m_fits_format = true
 
std::string m_id_column_name
 
std::vector< std::shared_ptr< SourceCatalog::AttributeFromRow > > m_attribute_handlers
 
std::shared_ptr< Table::ColumnInfom_column_info
 

Additional Inherited Members

- Protected Member Functions inherited from Euclid::Configuration::Configuration
template<typename T >
void declareDependency ()
 Declares a Configuration as dependency.
 
template<typename T >
T & getDependency ()
 Returns a dependency.
 
template<typename T >
const T & getDependency () const
 

Detailed Description

Configuration class for enabling catalog input.

The CatalogConfiguration class provides the basis for reading input catalogs. It provides all the functionality for reading an input catalog as an object of type Table::Table (using the method readAsTable() ) or of type SourceCatalog::Catalog (using the method readAsCatalog() ). For performing partial reading of the catalog the methods getTableReader() and getTableToCatalogConverter() can be used instead.

Any other configurations (like catalog specific configurations) can use the getColumnInfo() method to retrieve the table column information, after the CatalogConfig has been initialized.

Because this is a generic class, it has no knowledge of the specific catalog attributes. By default it does not use any attribute handlers and it only parses the ID of the catalog entries. The more specific catalog configurations (for example coordinates catalog), should declare the CatalogConfig as a dependency and they should add an attribute handler during the initialize phase. The more specific catalog configuration classes can use the getColumnInfo() method to get the catalog columns information (if needed).

Definition at line 66 of file CatalogConfig.h.

Member Typedef Documentation

◆ TableToCatalogConverter

A function that converts objects of type Table::Table to objects of type SourceCatalog::Catalog

Definition at line 71 of file CatalogConfig.h.

Constructor & Destructor Documentation

◆ CatalogConfig()

Euclid::Configuration::CatalogConfig::CatalogConfig ( long  manager_id)
explicit

Constructs a new CatalogConfig object.

Definition at line 46 of file CatalogConfig.cpp.

◆ ~CatalogConfig()

virtual Euclid::Configuration::CatalogConfig::~CatalogConfig ( )
virtualdefault

Destructor.

Member Function Documentation

◆ addAttributeHandler()

void Euclid::Configuration::CatalogConfig::addAttributeHandler ( std::shared_ptr< SourceCatalog::AttributeFromRow handler)

Adds an attribute handler which will be used for adding attributes at the catalog objects.

This method can be called by other configuration classes before the post- initialization phase, to add extra attributes to the catalog.

Parameters
handlerThe AttributeHandler to add
Exceptions
Elements::ExceptionIf the CatalogConfig instance has already been finalized

Definition at line 171 of file CatalogConfig.cpp.

References Euclid::Configuration::Configuration::FINAL, Euclid::Configuration::Configuration::getCurrentState(), and m_attribute_handlers.

Here is the call graph for this function:

◆ getColumnInfo()

std::shared_ptr< Table::ColumnInfo > Euclid::Configuration::CatalogConfig::getColumnInfo ( ) const
Returns
Column information about the catalog

Definition at line 185 of file CatalogConfig.cpp.

References Euclid::Configuration::Configuration::getCurrentState(), Euclid::Configuration::Configuration::INITIALIZED, and m_column_info.

Here is the call graph for this function:

◆ getFilename()

const boost::filesystem::path & Euclid::Configuration::CatalogConfig::getFilename ( ) const

Returns the filename of the input catalog.

This method can be called only on instances of CatalogConfig which are finalized.

Returns
The filename of the input catalog
Exceptions
Elements::ExceptionIf the instance is not yet final

Definition at line 239 of file CatalogConfig.cpp.

References Euclid::Configuration::Configuration::getCurrentState(), Euclid::Configuration::Configuration::INITIALIZED, and m_filename.

Here is the call graph for this function:

◆ getIdColumn()

std::string Euclid::Configuration::CatalogConfig::getIdColumn ( ) const
Returns
The name of the column that stores the object ID

Definition at line 192 of file CatalogConfig.cpp.

References m_id_column_name.

◆ getProgramOptions()

auto Euclid::Configuration::CatalogConfig::getProgramOptions ( )
overridevirtual

Returns the program options defined by the CatalogConfig.

These options are:

  • input-catalog-file : The file containing the input catalog
  • input-catalog-format : The format of the input catalog (one of AUTO, FITS or ASCII)
  • source-id-column-name : The name of the column representing the source ID
  • source-id-column-index : The index (1-based) of the column representing the source ID

All options are in a group called "Input catalog options".

Returns
The map with the option descriptions

Reimplemented from Euclid::Configuration::Configuration.

Definition at line 48 of file CatalogConfig.cpp.

References std::string::c_str(), Euclid::Configuration::INPUT_CATALOG_FILE, Euclid::Configuration::INPUT_CATALOG_FORMAT, Euclid::Configuration::SOURCE_ID_COLUMN_INDEX, and Euclid::Configuration::SOURCE_ID_COLUMN_NAME.

Here is the call graph for this function:

◆ getTableReader()

std::unique_ptr< Table::TableReader > Euclid::Configuration::CatalogConfig::getTableReader ( ) const
Returns
A TableReader object that can be used to read the configured catalog

Definition at line 178 of file CatalogConfig.cpp.

References Euclid::Configuration::Configuration::FINAL, Euclid::Configuration::Configuration::getCurrentState(), m_filename, and m_fits_format.

Referenced by readAsTable().

Here is the call graph for this function:

◆ getTableToCatalogConverter()

CatalogConfig::TableToCatalogConverter Euclid::Configuration::CatalogConfig::getTableToCatalogConverter ( ) const
Returns
A callable that converts the table to a SourceCatalog

Definition at line 215 of file CatalogConfig.cpp.

References Euclid::Configuration::Configuration::FINAL, Euclid::Configuration::Configuration::getCurrentState(), m_attribute_handlers, m_column_info, and m_id_column_name.

Referenced by readAsCatalog().

Here is the call graph for this function:

◆ initialize()

void Euclid::Configuration::CatalogConfig::initialize ( const UserValues args)
overridevirtual

Initializes the CatalogConfig instance.

Parameters
argsThe user parameters
Exceptions
Elements::ExceptionIf there is any I/O error with reading the input-catalog-file
Elements::ExceptionIf the file has wrong format type
Elements::ExceptionIf the given file has no ID column, as described by the source-id-column-name and source-id-column-index parameters
Elements::ExceptionIf there is any I/O error with reading the input-catalog-file

Reimplemented from Euclid::Configuration::Configuration.

Definition at line 157 of file CatalogConfig.cpp.

References m_base_dir, m_column_info, m_filename, m_fits_format, and m_id_column_name.

◆ preInitialize()

void Euclid::Configuration::CatalogConfig::preInitialize ( const UserValues args)
overridevirtual

Checks that all the options are valid. See the exceptions thrown for a detailed list of the checks.

Parameters
argsThe user parameters
Exceptions
Elements::ExceptionIf both the source-id-column-name and source-id-column-index are given
Elements::ExceptionIf the source-id-column-index is an invalid one-based index (less than 1)
Elements::ExceptionIf the input-catalog-format is not one of AUTO, FITS or ASCII

Reimplemented from Euclid::Configuration::Configuration.

Definition at line 58 of file CatalogConfig.cpp.

References std::map< K, T >::at(), std::map< K, T >::end(), std::map< K, T >::find(), Euclid::Configuration::INPUT_CATALOG_FORMAT, Euclid::Configuration::SOURCE_ID_COLUMN_INDEX, and Euclid::Configuration::SOURCE_ID_COLUMN_NAME.

Here is the call graph for this function:

◆ readAsCatalog()

SourceCatalog::Catalog Euclid::Configuration::CatalogConfig::readAsCatalog ( ) const

Returns the Catalog object.

This method can be called to read and retrieve the catalog as a Catalog object. It is a convenience method alternative from using the getTableReader() and getTableToCatalogConverter() methods Note that this method is going to read the full catalog each time it is called.

Returns
The source catalog
Exceptions
Elements::ExceptionIf the instance is not yet final
Elements::ExceptionIf there is any I/O error with reading the input-catalog-file
Elements::ExceptionIf the file has wrong format type
Elements::ExceptionIf any of the registered attribute handlers fails

Definition at line 230 of file CatalogConfig.cpp.

References Euclid::Configuration::Configuration::FINAL, Euclid::Configuration::Configuration::getCurrentState(), getTableToCatalogConverter(), and readAsTable().

Here is the call graph for this function:

◆ readAsTable()

Table::Table Euclid::Configuration::CatalogConfig::readAsTable ( ) const

Returns the catalog as a Table::Table object.

This method can be called to read and retrieve the catalog as a Table::Table object. When this method is called the information from the attribute handlers is ignored and each row contains all the columns from the file. Note that this method is going to read the full catalog each time it is called.

Returns
The catalog as a Table::Table
Exceptions
Elements::ExceptionIf the instance is not yet final
Elements::ExceptionIf there is any I/O error with reading the input-catalog-file
Elements::ExceptionIf the file has wrong format type
Elements::ExceptionIf any of the registered attribute handlers fails

Definition at line 222 of file CatalogConfig.cpp.

References Euclid::Configuration::Configuration::FINAL, Euclid::Configuration::Configuration::getCurrentState(), getTableReader(), Elements::Logging::info(), Euclid::Configuration::logger, and m_filename.

Referenced by readAsCatalog().

Here is the call graph for this function:

◆ setBaseDir()

void Euclid::Configuration::CatalogConfig::setBaseDir ( const boost::filesystem::path &  base_dir)

Sets the directory used when resolving relative paths.

This method can be called by other Configuration classes during the pre- initialization phase. By default the current working directory is used.

Parameters
base_dirThe directory to use for resolving relative paths
Exceptions
Elements::ExceptionIf the CatalogConfig instance has already been initialized

Definition at line 164 of file CatalogConfig.cpp.

References Euclid::Configuration::Configuration::getCurrentState(), Euclid::Configuration::Configuration::INITIALIZED, and m_base_dir.

Here is the call graph for this function:

Member Data Documentation

◆ m_attribute_handlers

std::vector<std::shared_ptr<SourceCatalog::AttributeFromRow> > Euclid::Configuration::CatalogConfig::m_attribute_handlers
private

Definition at line 251 of file CatalogConfig.h.

Referenced by addAttributeHandler(), and getTableToCatalogConverter().

◆ m_base_dir

boost::filesystem::path Euclid::Configuration::CatalogConfig::m_base_dir
private

Definition at line 247 of file CatalogConfig.h.

Referenced by initialize(), and setBaseDir().

◆ m_column_info

std::shared_ptr<Table::ColumnInfo> Euclid::Configuration::CatalogConfig::m_column_info
private

Definition at line 252 of file CatalogConfig.h.

Referenced by getColumnInfo(), getTableToCatalogConverter(), and initialize().

◆ m_filename

boost::filesystem::path Euclid::Configuration::CatalogConfig::m_filename
private

Definition at line 248 of file CatalogConfig.h.

Referenced by getFilename(), getTableReader(), initialize(), and readAsTable().

◆ m_fits_format

bool Euclid::Configuration::CatalogConfig::m_fits_format = true
private

Definition at line 249 of file CatalogConfig.h.

Referenced by getTableReader(), and initialize().

◆ m_id_column_name

std::string Euclid::Configuration::CatalogConfig::m_id_column_name
private

Definition at line 250 of file CatalogConfig.h.

Referenced by getIdColumn(), getTableToCatalogConverter(), and initialize().


The documentation for this class was generated from the following files: