Skip to content
Snippets Groups Projects
Base_Provider.h 2.86 KiB
Newer Older
Valerio Pastore's avatar
Valerio Pastore committed
/*
**************************************************************************
* 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
****************************************************************************
*/
Valerio Pastore's avatar
Valerio Pastore committed
#pragma once
Valerio Pastore's avatar
Valerio Pastore committed
#include <string>
#include <Base_Packet.h>
Valerio Pastore's avatar
Valerio Pastore committed

namespace inaf::oasbo::Providers {
Valerio Pastore's avatar
Valerio Pastore committed
/**
 * @brief The BaseProvider class is an abstract base class for providers in the DAQ system.
 * 
 * This class defines the common interface for providers that write packets to a destination.
 * Derived classes must implement the pure virtual functions defined in this class.
 */
Valerio Pastore's avatar
.  
Valerio Pastore committed
class BaseProvider {
Valerio Pastore's avatar
Valerio Pastore committed
protected:
Valerio Pastore's avatar
Valerio Pastore committed
	std::string dest; /**< The destination where packets are written to. */

Valerio Pastore's avatar
Valerio Pastore committed
public:
Valerio Pastore's avatar
Valerio Pastore committed
	/**
	 * @brief Writes a packet to the destination.
	 * 
	 * @param packet The packet to be written.
	 * @return int Returns an integer indicating the success or failure of the write operation.
	 */
Valerio Pastore's avatar
.  
Valerio Pastore committed
	virtual int write(Packets::BasePacket &packet) = 0;
Valerio Pastore's avatar
Valerio Pastore committed

	/**
	 * @brief Writes a packet to a specified destination.
	 * 
	 * @param packet The packet to be written.
	 * @param dest The destination where the packet should be written to.
	 * @return int Returns an integer indicating the success or failure of the write operation.
	 */
Valerio Pastore's avatar
.  
Valerio Pastore committed
	virtual int write(Packets::BasePacket &packet, std::string dest) = 0;
Valerio Pastore's avatar
Valerio Pastore committed
	/**
	 * @brief Opens the provider.
	 * 
	 * @return int Returns an integer indicating the success or failure of the open operation.
	 */
	virtual int open() = 0;

	/**
	 * @brief Closes the provider.
	 * 
	 * @return int Returns an integer indicating the success or failure of the close operation.
	 */
	virtual int close() = 0;

	/**
	 * @brief Checks if the provider is open.
	 * 
	 * @return bool Returns true if the provider is open, false otherwise.
	 */
astri's avatar
astri committed
	virtual bool isOpen() = 0;
Valerio Pastore's avatar
Valerio Pastore committed

	/**
	 * @brief Sets the destination where packets should be written to.
	 * 
	 * @param dest The destination to be set.
	 */
Valerio Pastore's avatar
Valerio Pastore committed
	virtual void setDest(std::string dest) = 0;
Valerio Pastore's avatar
Valerio Pastore committed

	/**
	 * @brief Gets the current destination where packets are written to.
	 * 
	 * @return std::string Returns the current destination.
	 */
Valerio Pastore's avatar
Valerio Pastore committed
	virtual std::string getDest() = 0;
Valerio Pastore's avatar
Valerio Pastore committed

	/**
	 * @brief Default destructor.
	 */
Valerio Pastore's avatar
Valerio Pastore committed
	virtual ~BaseProvider() = default;
};
Valerio Pastore's avatar
.  
Valerio Pastore committed
}