Skip to content
Base_Provider.h 1.97 KiB
Newer Older
Valerio Pastore's avatar
Valerio Pastore committed
#pragma once
Valerio Pastore's avatar
Valerio Pastore committed
#include <string>
Valerio Pastore's avatar
Valerio Pastore committed
#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{
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.
	 */
	virtual int write(PacketLib::BasePacket &packet) = 0;

	/**
	 * @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.
	 */
	virtual int write(PacketLib::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
}