#ifndef BASEDAQ_H_ #define BASEDAQ_H_ #include #include #include #include #include #include // FORWARD DECLARE namespace inaf::oasbo::DAQ_observers { class BaseDAQ_Observer; } namespace inaf::oasbo::DAQ { class BaseDAQ { public: enum Status { STOP = -1, READY = 0, IDLE = 1, RUN = 2 }; protected: Status currentState; Status nextState; bool changeStateFlag = false; ConnectionProtocols::BaseProtocol *protocol = nullptr; Archivers::BaseArchiver *archiver = nullptr; Providers::BaseProvider *provider = nullptr; PacketMonitors::BasePacketMonitor *monitor = nullptr; PacketLib::BasePacket *packet = nullptr; std::vector observers; std::vector configurations; public: void setProtocol(ConnectionProtocols::BaseProtocol &socket) { this->protocol = &socket; } void setArchiver(Archivers::BaseArchiver &archiver) { this->archiver = &archiver; } void setProvider(Providers::BaseProvider &provider) { this->provider = &provider; } void setMonitor(PacketMonitors::BasePacketMonitor &monitor) { this->monitor = &monitor; } void setPacket(PacketLib::BasePacket &packet) { this->packet = &packet; } void setCurrentState(Status currentState) { this->currentState = currentState; } void setNextState(Status nextState) { this->nextState = nextState; } void setChangeStateFlag(bool flag) { this->changeStateFlag = flag; } void registerObserver(inaf::oasbo::DAQ_observers::BaseDAQ_Observer *observer) { observers.push_back(observer); } void removeObserver(inaf::oasbo::DAQ_observers::BaseDAQ_Observer *observer) { observers.erase( std::remove(observers.begin(), observers.end(), observer), observers.end()); } ConnectionProtocols::BaseProtocol* getSocketPtr() { return this->protocol; } Archivers::BaseArchiver* getArchiverPtr() { return this->archiver; } Providers::BaseProvider* getProviderPtr() { return this->provider; } PacketMonitors::BasePacketMonitor* getMonitorPtr() { return this->monitor; } PacketLib::BasePacket* getPacketPrt() { return this->packet; } Status getCurrentState() { return this->currentState; } Status getNextState() { return this->nextState; } int getChangeStateFlag() { return this->changeStateFlag; } virtual void start() = 0; virtual void stop() = 0; virtual void switchState(const Status) = 0; virtual int deliverPacket() = 0; virtual ~BaseDAQ() { delete protocol; delete provider; delete archiver; delete monitor; delete packet; } }; } #endif /* BASEDAQ_H_ */