BasicHTTPIOProcessor.h
Go to the documentation of this file.
1 
20 #ifndef BASICHTTPIOPROCESSOR_H_2CUY93KU
21 #define BASICHTTPIOPROCESSOR_H_2CUY93KU
22 
23 #include "uscxml/config.h"
24 
25 extern "C" {
26 #include <event2/http.h>
27 #include <event2/http_struct.h>
28 }
29 
30 #if defined(_WIN32) && !defined(USCXML_STATIC)
31 # if (defined ioprocessor_basichttp_EXPORTS || defined USCXML_EXPORT)
32 # define USCXML_PLUGIN_API __declspec(dllexport)
33 # else
34 # define USCXML_PLUGIN_API __declspec(dllimport)
35 # endif
36 #else
37 # define USCXML_PLUGIN_API
38 #endif
39 
43 
44 #ifndef _WIN32
45 #include <sys/time.h>
46 #endif
47 
48 #ifdef BUILD_AS_PLUGINS
49 #include "uscxml/plugins/Plugins.h"
50 #endif
51 
52 #define USCXML_IOPROC_BASICHTTP_TYPE "http://www.w3.org/TR/scxml/#BasicHTTPEventProcessor"
53 
54 namespace uscxml {
55 
60 class USCXML_PLUGIN_API BasicHTTPIOProcessor : public IOProcessorImpl, public HTTPServlet, public URLMonitor {
61 public:
63  virtual ~BasicHTTPIOProcessor();
64  virtual std::shared_ptr<IOProcessorImpl> create(uscxml::IOProcessorCallbacks* callbacks);
65 
66  virtual std::list<std::string> getNames() {
67  std::list<std::string> names;
68  names.push_back("basichttp");
69  names.push_back(USCXML_IOPROC_BASICHTTP_TYPE);
70  return names;
71  }
72 
73  virtual void eventFromSCXML(const std::string& target, const Event& event);
74  virtual bool isValidTarget(const std::string& target);
75 
76  Data getDataModelVariables();
77 
79  bool requestFromHTTP(const HTTPServer::Request& req);
80  void setURL(const std::string& url) {
81  _url = url;
82  }
83 
84  bool canAdaptPath() {
85  return false;
86  }
87 
88  // URLMonitor
89  void downloadStarted(const URL& url);
90  void downloadCompleted(const URL& url);
91  void downloadFailed(const URL& url, int errorCode);
92 
93 protected:
94  std::string _url;
95  std::map<std::string, std::pair<URL, Event> > _sendRequests;
96 };
97 
98 #ifdef BUILD_AS_PLUGINS
99 PLUMA_INHERIT_PROVIDER(BasicHTTPIOProcessor, IOProcessorImpl)
100 #endif
101 
102 }
103 
104 #endif /* end of include guard: BASICHTTPIOPROCESSOR_H_2CUY93KU */
Definition: URL.h:38
Definition: Breakpoint.cpp:26
virtual std::list< std::string > getNames()
Return a list of names for types we implement.
Definition: BasicHTTPIOProcessor.h:66
The basichttp I/O processor as per standard.
Definition: BasicHTTPIOProcessor.h:60
Definition: HTTPServer.h:47
Definition: URL.h:133
Abstract base class for IOProcessors implementations.
Definition: IOProcessorImpl.h:54
Definition: Event.h:94
Definition: HTTPServer.h:200
bool canAdaptPath()
Called by the server with the actual URL.
Definition: BasicHTTPIOProcessor.h:84
Callbacks available for every IO processor.
Definition: IOProcessorImpl.h:36
Definition: Data.h:44