@@ -59,29 +59,6 @@ class bad_caching_attempt: public std::exception
5959 }
6060};
6161
62-
63- class closure_action
64- {
65- public:
66- closure_action (bool deletable = true ):
67- deletable (deletable)
68- {
69- }
70- closure_action (const closure_action& b):
71- deletable (b.deletable)
72- {
73- }
74- virtual ~closure_action ()
75- {
76- }
77- virtual void do_action ()
78- {
79- }
80- bool deletable;
81- private:
82- friend class http_response ;
83- };
84-
8562/* *
8663 * Class representing an abstraction for an Http Response. It is used from classes using these apis to send information through http protocol.
8764**/
@@ -141,6 +118,7 @@ class http_response
141118 keepalive_msg (keepalive_msg),
142119 send_topic (send_topic),
143120 ca (0x0 ),
121+ closure_data (0x0 ),
144122 ce (ce)
145123 {
146124 set_header (http_utils::http_header_content_type, content_type);
@@ -167,6 +145,7 @@ class http_response
167145 keepalive_msg (b.keepalive_msg),
168146 send_topic (b.send_topic),
169147 ca (0x0 ),
148+ closure_data (0x0 ),
170149 ce (b.ce)
171150 {
172151 }
@@ -188,22 +167,13 @@ class http_response
188167 keepalive_secs = b.keepalive_secs ;
189168 keepalive_msg = b.keepalive_msg ;
190169 send_topic = b.send_topic ;
191- if (ca != 0x0 && ca->deletable )
192- {
193- delete ca;
194- ca = 0x0 ;
195- }
196170 ca = b.ca ;
171+ closure_data = b.closure_data ;
197172 ce = b.ce ;
198173 return *this ;
199174 }
200175 virtual ~http_response ()
201176 {
202- if (ca != 0x0 && ca->deletable )
203- {
204- delete ca;
205- ca = 0x0 ;
206- }
207177 }
208178 /* *
209179 * Method used to get the content from the response.
@@ -408,9 +378,10 @@ class http_response
408378 topics.push_back (*it);
409379 return topics.size ();
410380 }
411- void set_closure_action (closure_action* ca )
381+ void set_closure_action (void (*ca)( void *), void* closure_data )
412382 {
413383 this ->ca = ca;
384+ this ->closure_data = closure_data;
414385 }
415386 protected:
416387 response_type_T response_type;
@@ -430,7 +401,8 @@ class http_response
430401 std::string keepalive_msg;
431402 std::string send_topic;
432403 struct MHD_Connection * underlying_connection;
433- closure_action* ca;
404+ void (*ca)(void *);
405+ void * closure_data;
434406 cache_entry* ce;
435407
436408 virtual void get_raw_response (MHD_Response** res, webserver* ws = 0x0 );
0 commit comments