DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
tpglibs::ProcessorInternalStateNameRegistry< T > Class Template Reference

Registry of internal state names. More...

#include <ProcessorInternalStateNameRegistry.hpp>

Public Types

using signal_t = T
 Signal type to use. Generally __m256i or std::array<int16_t, 16>;.
 

Public Member Functions

 ProcessorInternalStateNameRegistry ()=default
 Constructor.
 
 ~ProcessorInternalStateNameRegistry ()
 Destructor.
 
 ProcessorInternalStateNameRegistry (const ProcessorInternalStateNameRegistry &)=delete
 
ProcessorInternalStateNameRegistryoperator= (const ProcessorInternalStateNameRegistry &)=delete
 
 ProcessorInternalStateNameRegistry (ProcessorInternalStateNameRegistry &&)=default
 
ProcessorInternalStateNameRegistryoperator= (ProcessorInternalStateNameRegistry &&)=default
 
size_t get_number_of_requested_internal_states ()
 Get the number of requested internal states.
 
std::vector< std::string > get_names_of_requested_internal_states () const
 Get the names of the requested internal states.
 
void parse_requested_internal_state_items (std::string config_string)
 Parse the requested internal state items from a configuration string.
 
void register_internal_state (std::string name, std::shared_ptr< signal_t > pointer_to_state)
 Register an internal state.
 
std::shared_ptr< signal_tget_internal_state_item_ptr (std::string name)
 Get a pointer to an internal state item.
 
std::vector< std::shared_ptr< signal_t > > get_all_requested_internal_state_item_ptrs ()
 Get a vector of pointers to all internal state items.
 
bool is_registered (const std::string &name) const
 Check if an internal state name is registered.
 
bool is_requested (const std::string &name) const
 Check if an internal state name is requested.
 

Protected Member Functions

std::vector< std::string > get_all_registered_internal_state_names ()
 Get all registered internal state names.
 
void clear ()
 Clear the registry.
 

Private Attributes

std::unordered_map< std::string, std::shared_ptr< signal_t > > m_internal_state_map
 Map of internal state names to pointers.
 
std::vector< std::string > m_requested_internal_state_names
 Vector of all requested internal state names.
 

Detailed Description

template<typename T>
class tpglibs::ProcessorInternalStateNameRegistry< T >

Registry of internal state names.

Definition at line 27 of file ProcessorInternalStateNameRegistry.hpp.

Member Typedef Documentation

◆ signal_t

template<typename T >
using tpglibs::ProcessorInternalStateNameRegistry< T >::signal_t = T

Signal type to use. Generally __m256i or std::array<int16_t, 16>;.

Definition at line 30 of file ProcessorInternalStateNameRegistry.hpp.

Constructor & Destructor Documentation

◆ ProcessorInternalStateNameRegistry() [1/3]

template<typename T >
tpglibs::ProcessorInternalStateNameRegistry< T >::ProcessorInternalStateNameRegistry ( )
default

Constructor.

◆ ~ProcessorInternalStateNameRegistry()

◆ ProcessorInternalStateNameRegistry() [2/3]

template<typename T >
tpglibs::ProcessorInternalStateNameRegistry< T >::ProcessorInternalStateNameRegistry ( const ProcessorInternalStateNameRegistry< T > & )
delete

◆ ProcessorInternalStateNameRegistry() [3/3]

template<typename T >
tpglibs::ProcessorInternalStateNameRegistry< T >::ProcessorInternalStateNameRegistry ( ProcessorInternalStateNameRegistry< T > && )
default

Member Function Documentation

◆ clear()

template<typename T >
void tpglibs::ProcessorInternalStateNameRegistry< T >::clear ( )
protected

Clear the registry.

Definition at line 210 of file ProcessorInternalStateNameRegistry.hpp.

210 {
211 // reinitialize member variables
212 m_internal_state_map.clear();
214 }
std::unordered_map< std::string, std::shared_ptr< signal_t > > m_internal_state_map
Map of internal state names to pointers.
std::vector< std::string > m_requested_internal_state_names
Vector of all requested internal state names.

◆ get_all_registered_internal_state_names()

template<typename T >
std::vector< std::string > tpglibs::ProcessorInternalStateNameRegistry< T >::get_all_registered_internal_state_names ( )
protected

Get all registered internal state names.

Returns
A vector of all registered internal state names.

Definition at line 156 of file ProcessorInternalStateNameRegistry.hpp.

156 {
157 std::vector<std::string> names;
158 for (const auto& item : m_internal_state_map) {
159 names.push_back(item.first);
160 }
161 return names;
162 }

◆ get_all_requested_internal_state_item_ptrs()

template<typename T >
std::vector< std::shared_ptr< typename ProcessorInternalStateNameRegistry< T >::signal_t > > tpglibs::ProcessorInternalStateNameRegistry< T >::get_all_requested_internal_state_item_ptrs ( )

Get a vector of pointers to all internal state items.

Returns
A vector of pointers to all internal state items.

Definition at line 218 of file ProcessorInternalStateNameRegistry.hpp.

218 {
219 std::vector<std::shared_ptr<typename ProcessorInternalStateNameRegistry<T>::signal_t>> item_ptrs;
220 for (const auto& item : m_requested_internal_state_names) {
221 item_ptrs.push_back(m_internal_state_map[item]);
222 }
223 return item_ptrs;
224 }

◆ get_internal_state_item_ptr()

template<typename T >
std::shared_ptr< typename ProcessorInternalStateNameRegistry< T >::signal_t > tpglibs::ProcessorInternalStateNameRegistry< T >::get_internal_state_item_ptr ( std::string name)

Get a pointer to an internal state item.

Parameters
nameThe name of the internal state.
Returns
A pointer to the internal state item.

Definition at line 151 of file ProcessorInternalStateNameRegistry.hpp.

151 {
152 return m_internal_state_map[name];
153 }

◆ get_names_of_requested_internal_states()

template<typename T >
std::vector< std::string > tpglibs::ProcessorInternalStateNameRegistry< T >::get_names_of_requested_internal_states ( ) const

Get the names of the requested internal states.

Returns
The names of the requested internal states.

Definition at line 140 of file ProcessorInternalStateNameRegistry.hpp.

140 {
142 }

◆ get_number_of_requested_internal_states()

template<typename T >
size_t tpglibs::ProcessorInternalStateNameRegistry< T >::get_number_of_requested_internal_states ( )

Get the number of requested internal states.

Returns
The number of requested internal states.

Definition at line 135 of file ProcessorInternalStateNameRegistry.hpp.

135 {
137 }

◆ is_registered()

template<typename T >
bool tpglibs::ProcessorInternalStateNameRegistry< T >::is_registered ( const std::string & name) const

Check if an internal state name is registered.

Parameters
nameThe name to check.
Returns
True if the name is registered, false otherwise.

Definition at line 227 of file ProcessorInternalStateNameRegistry.hpp.

227 {
228 return m_internal_state_map.find(name) != m_internal_state_map.end();
229 }

◆ is_requested()

template<typename T >
bool tpglibs::ProcessorInternalStateNameRegistry< T >::is_requested ( const std::string & name) const

Check if an internal state name is requested.

Parameters
nameThe name to check.
Returns
True if the name is in the requested list, false otherwise.

Definition at line 232 of file ProcessorInternalStateNameRegistry.hpp.

232 {
233 for (const auto& requested_name : m_requested_internal_state_names) {
234 if (requested_name == name) {
235 return true;
236 }
237 }
238 return false;
239 }

◆ operator=() [1/2]

◆ operator=() [2/2]

◆ parse_requested_internal_state_items()

template<typename T >
void tpglibs::ProcessorInternalStateNameRegistry< T >::parse_requested_internal_state_items ( std::string config_string)

Parse the requested internal state items from a configuration string.

Parameters
config_stringThe configuration string.

Definition at line 165 of file ProcessorInternalStateNameRegistry.hpp.

165 {
166 // Clear existing requested names first
168
169 if (config_string.empty()) {
170 return;
171 }
172
173 // Parse comma-separated items
174 std::string::size_type start = 0;
175 std::string::size_type end = config_string.find(',');
176
177 while (end != std::string::npos) {
178 // Extract item name and trim whitespace
179 std::string item_name = config_string.substr(start, end - start);
180
181 // Trim leading and trailing whitespace
182 item_name.erase(0, item_name.find_first_not_of(" \t\r\n"));
183 item_name.erase(item_name.find_last_not_of(" \t\r\n") + 1);
184
185 // Only add non-empty item names
186 if (!item_name.empty()) {
187 m_requested_internal_state_names.push_back(item_name);
188 }
189
190 start = end + 1;
191 end = config_string.find(',', start);
192 }
193
194 // Handle the last item (after the final comma or if there are no commas)
195 if (start < config_string.length()) {
196 std::string last_item = config_string.substr(start);
197
198 // Trim leading and trailing whitespace
199 last_item.erase(0, last_item.find_first_not_of(" \t\r\n"));
200 last_item.erase(last_item.find_last_not_of(" \t\r\n") + 1);
201
202 // Only add non-empty item names
203 if (!last_item.empty()) {
204 m_requested_internal_state_names.push_back(last_item);
205 }
206 }
207 }

◆ register_internal_state()

template<typename T >
void tpglibs::ProcessorInternalStateNameRegistry< T >::register_internal_state ( std::string name,
std::shared_ptr< signal_t > pointer_to_state )

Register an internal state.

Parameters
nameThe name of the internal state.
pointer_to_stateA pointer to the internal state item.

Definition at line 145 of file ProcessorInternalStateNameRegistry.hpp.

145 {
146 m_internal_state_map[name] = pointer_to_state;
147 }

Member Data Documentation

◆ m_internal_state_map

template<typename T >
std::unordered_map<std::string, std::shared_ptr<signal_t> > tpglibs::ProcessorInternalStateNameRegistry< T >::m_internal_state_map
private

Map of internal state names to pointers.

Definition at line 121 of file ProcessorInternalStateNameRegistry.hpp.

◆ m_requested_internal_state_names

template<typename T >
std::vector<std::string> tpglibs::ProcessorInternalStateNameRegistry< T >::m_requested_internal_state_names
private

Vector of all requested internal state names.

Definition at line 124 of file ProcessorInternalStateNameRegistry.hpp.


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