bitz-server  1.0.0
py.h
1 /*
2  * bitz-server, An ICAP server implementation in C++
3  * Copyright (C) 2012 Uditha Atukorala
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef BITZ_PY_H
21 #define BITZ_PY_H
22 
23 #include <Python.h>
24 
25 #include <bitz/modifier.h>
26 
27 
28 namespace bitz {
29 
30  class Py : public Modifier {
31  public:
32 
33  struct config_t {
34  std::string module_path;
35  std::string module_name;
36  };
37 
38  Py();
39  virtual ~Py();
40 
41  icap::Response * modify( icap::Request * request ) throw();
42  icap::Response * preview( icap::Request * request ) throw();
43 
44  private:
45  config_t _config;
46  PyObject * _pymodule;
47 
48  void load_configs() throw();
49  void init_python() throw();
50  void cleanup_python() throw();
51 
52  icap::Response * python_response( icap::Request * request, const std::string &method ) throw();
53 
54  };
55 
56 } /* end of namespace bitz */
57 
58 
59 /* class factories */
60 
61 extern "C" bitz::Modifier * create() {
62  return new bitz::Py;
63 }
64 
65 extern "C" void destroy( bitz::Modifier * m ) {
66  delete m;
67 }
68 
69 #endif /* !BITZ_PY_H */
70 
Definition: response.h:29
Definition: echo.cpp:23
Definition: py.h:33
icap::Response * preview(icap::Request *request)
Definition: py.cpp:63
Definition: modifier.h:29
Definition: py.h:30
icap::Response * modify(icap::Request *request)
Definition: py.cpp:55
Definition: request.h:29