Newer
Older
/*
**************************************************************************
* Copyright (C) 2023 INAF
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License
* or (at your option) any later version. This program is distributed
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Authors:
*
* <>Valerio Pastore INAF-OAS Bologna valerio.pastore@inaf.it
****************************************************************************
*/
/**
* @brief The BasePacketMonitor class is an abstract base class for packet monitors in the DAQ system.
*
* This class provides a common interface for packet monitoring functionality.
* Derived classes must implement the monit(), printStats(), and reset() methods.
* The class also provides methods to access and retrieve statistics related to the monitored packets.
*/
std::map<std::string, std::string> stats; /**< A map to store statistics related to the monitored packets. */
/**
* @brief Monitors a packet.
*
* This pure virtual method is used to monitor a packet.
* Derived classes must implement this method to define the monitoring behavior.
*
* @param packet The packet to be monitored.
*/
/**
* @brief Prints the statistics related to the monitored packets.
*
* This pure virtual method is used to print the statistics related to the monitored packets.
* Derived classes must implement this method to define the printing behavior.
*/
virtual void printStats() = 0;
/**
* @brief Resets the statistics related to the monitored packets.
*
* This pure virtual method is used to reset the statistics related to the monitored packets.
* Derived classes must implement this method to define the resetting behavior.
*/
/**
* @brief Retrieves the statistics map.
*
* This method returns the map containing the statistics related to the monitored packets.
*
* @return The map containing the statistics related to the monitored packets.
*/
virtual std::map<std::string, std::string> getStatsMap() const {
return stats;
}
/**
* @brief Retrieves a specific statistic.
*
* This method retrieves a specific statistic from the statistics map.
* If the statistic is not found, it returns std::nullopt.
*
* @param stat The name of the statistic to retrieve.
* @return An optional string containing the value of the statistic, or std::nullopt if the statistic is not found.
*/
std::optional<std::string> getStat(std::string stat) const {