#ifndef __AlertSqlProducer_h_ #define __AlertSqlProducer_h_ /* When we get a request for realtime or historical data from the client, we * need to do a lot of one time processing. Originally this was done right * away. But because this uses the database, and it might be slow, we want * the ability to save the request and process it later, possibly in another * thread. * * This code was originally all hiding in UserRequestControl.C. I had to move * it into this object when I reorganized. */ #include "../shared/SocketInfo.h" #include "../shared/CommandDispatcher.h" #include "AlertConfig.h" class AlertSqlProducer { private: SocketInfo *_socket; std::string _longForm; ExternalRequest::MessageId _responseId; bool _allowCustomColumns; bool _allowNonFilterColumns; bool _useEtradeColumns; void clear(); public: AlertSqlProducer() : _socket(NULL), _allowCustomColumns(false), _useEtradeColumns(false) { } void load(std::string const &longForm, SocketInfo *socket, ExternalRequest::MessageId responseId, bool allowCustomColumns, bool useEtradeColumns, bool allowNonFilterColumns); void load(ExternalRequest *request); // This will take care of a number of tasks, including saving the settings to // the MRU list, filling in the generator, and sending a response to the // client. The client is expecting exactly one response, so be careful // how you handle this. It is an error to call init() if we are not // ready(). void init(DatabaseWithRetry &writableDatabase, DatabaseWithRetry &readOnlyDatabase, AlertConfig::CustomSql &generator); // Same as above, but writableDatabase is optional. Set it to NULL if you // don't want to update the MRU list. void init(DatabaseWithRetry *writableDatabase, DatabaseWithRetry &readOnlyDatabase, AlertConfig::CustomSql &generator); // Same as above. Never updates the MRU list. Creates a new CustomSql // object. AlertConfig::CustomSql init(DatabaseWithRetry &readOnlyDatabase); // The cleint is expecting exactly one response. Send something, although // it won't be very interesting. Calling abandon() when not ready() is // a no-op. void abandon(); // This might will say if we've called load() but not init(). bool ready() const { return _socket; } }; #endif