gtranslationTable
Loading...
Searching...
No Matches
GTranslationTable Class Reference

Stores and retrieves GElectronic configurations by a vector-based identity. More...

#include <gtranslationTable.h>

Public Member Functions

 GTranslationTable (const std::shared_ptr< GOptions > &gopt)
 Constructs a translation table bound to the provided options/logger configuration.
 
void addGElectronicWithIdentity (const std::vector< int > &identity, const GElectronic &gtron)
 Registers an electronics configuration for a given identity vector.
 
GElectronic getElectronics (const std::vector< int > &identity) const
 Retrieves the electronics configuration associated with a given identity vector.
 
- Public Member Functions inherited from GBase< GTranslationTable >
 GBase (const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
 
 GBase (const std::shared_ptr< GLogger > &logger)
 
 GBase (const GBase &)=default
 
 GBase (GBase &&) noexcept=default
 
virtual ~GBase ()
 
GBaseoperator= (const GBase &)=default
 
GBaseoperator= (GBase &&) noexcept=default
 

Additional Inherited Members

- Protected Attributes inherited from GBase< GTranslationTable >
std::shared_ptr< GLoggerlog
 

Detailed Description

A Translation Table maps an identity expressed as a std::vector<int> to a GElectronic object. Internally, the identity vector is converted into a stable string key (hyphen-separated integers), which is then used as the key in an std::unordered_map.

Design goals:

  • Provide a simple, fast lookup for electronics configurations.
  • Keep identity handling explicit and deterministic (the same vector always yields the same key).
  • Emit useful logs for both normal operation and debugging.

Error handling:

  • If a key already exists when inserting, the module logs a warning and preserves the original value.
  • If a key is not found when retrieving, the module logs an error (EC__TTNOTFOUNDINTT) and returns a default-constructed GElectronic.
Note
This class derives from GBase to obtain consistent module logging behavior and to bind the logger name (TRANSLATIONTABLE_LOGGER).

Definition at line 36 of file gtranslationTable.h.

Constructor & Destructor Documentation

◆ GTranslationTable()

GTranslationTable::GTranslationTable ( const std::shared_ptr< GOptions > & gopt)
inlineexplicit

The options are used to configure logging and any module-level behavior supported by the project options infrastructure.

Parameters
goptShared pointer to the project options object used by this module.

Definition at line 47 of file gtranslationTable.h.

Member Function Documentation

◆ addGElectronicWithIdentity()

void GTranslationTable::addGElectronicWithIdentity ( const std::vector< int > & identity,
const GElectronic & gtron )

This method converts identity into the internal key representation and attempts to insert gtron into the table.

Insertion rules:

  • If the derived key does not exist, the entry is inserted.
  • If the derived key already exists, the entry is not overwritten; a warning is logged.

Logging behavior:

  • Emits informational output at verbosity level 1 after attempting the insertion.
  • May emit debug output with the full table content when debug logging is enabled.
Parameters
identityA vector of integers representing the unique identity.
gtronThe GElectronic configuration to associate with identity.

Definition at line 27 of file gtranslationTable.cc.

◆ getElectronics()

GElectronic GTranslationTable::getElectronics ( const std::vector< int > & identity) const

This method derives the internal key from identity and looks it up in the table.

  • If found, the associated GElectronic is returned.
  • If not found, an error is logged (EC__TTNOTFOUNDINTT) and a default-constructed GElectronic is returned.
Parameters
identityA vector of integers representing the unique identity.
Returns
The GElectronic associated with identity, or a default-constructed GElectronic if not found.

Definition at line 53 of file gtranslationTable.cc.


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