summaryrefslogtreecommitdiff
path: root/include/request.h
blob: f37a449d1e676ff26e01181a4884a813b2e4e215 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
 *  Request.h
 *
 *  During the lifetime of the extension, multiple requests can be handled
 *  by it. For every request that is handled, a request object is created.
 *
 *  The base class for the request is implemented in this file. If you'd like
 *  to add state variables to the request you can override this class and
 *  add the extra features you'd like. If you override this method, you should
 *  also override Extension::request() to return an instance of a different 
 *  class.
 *
 *  @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
 *  @copyright 2013 Copernica BV
 */
 
/**
 *  Set up namespace
 */
namespace PhpCpp {

/**
 *  Forward definitions
 */
class Extension;

/**
 *  Class definition
 */
class Request
{
public:
    /**
     *  Constructor
     *  @param  extension
     */
    Request(Extension *extension) : _extension(extension) {}
    
    /**
     *  Destructor
     */
    virtual ~Request() {}
    
    /**
     *  Initialize the request
     * 
     *  This method is called directly after the object was destructed. You can
     *  override this method to add your own initialization code.
     * 
     *  @return bool
     */
    virtual bool initialize()
    {
        return true;
    }
    
    /**
     *  Finalize the request
     * 
     *  This method is called right before the object is destructed. Note that
     *  the object is going to be destructed anyway, even if this method returns
     *  false
     * 
     *  @return bool
     */
    virtual bool finalize()
    {
        return true;
    }

protected:
    /**
     *  The extension that this request belongs to
     *  @var Extension*
     */
    Extension *_extension;
    
    /**
     *  Optional extra data
     *	@var Type
     */
    Type _data;
};

/**
 *  End of namespace
 */
}