summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/environment.h (renamed from include/request.h)50
-rw-r--r--include/extension.h55
-rw-r--r--include/function.h4
3 files changed, 62 insertions, 47 deletions
diff --git a/include/request.h b/include/environment.h
index d204e85..b8b4f74 100644
--- a/include/request.h
+++ b/include/environment.h
@@ -1,14 +1,14 @@
/**
- * Request.h
+ * Environment.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.
+ * by it. For every request that is handled, an environment 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
+ * The base class for the environment is defined in this file. If you'd like
+ * to add state variables to the environment 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.
+ * also override Extension::createEnvironment() to return an instance of a
+ * different class.
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2013 Copernica BV
@@ -27,19 +27,25 @@ class Extension;
/**
* Class definition
*/
-class Request
+class Environment
{
public:
/**
* Constructor
* @param extension
*/
- Request(Extension *extension) : _extension(extension) {}
+ Environment(Extension *extension) : _extension(extension) {}
+
+ /**
+ * Disable copy and move operations
+ */
+ Environment(const Environment &environment) = delete;
+ Environment(Environment &&environment) = delete;
/**
* Destructor
*/
- virtual ~Request() {}
+ virtual ~Environment() {}
/**
* Initialize the request
@@ -67,19 +73,37 @@ public:
{
return true;
}
+
+ /**
+ * Get access to the user supplied data
+ * @return void*
+ */
+ virtual void *data()
+ {
+ return _data;
+ }
+
+ /**
+ * Change the user supplied data
+ * @param data
+ */
+ virtual void setData(void *data)
+ {
+ _data = data;
+ }
protected:
/**
- * The extension that this request belongs to
+ * The extension that this environment belongs to
* @var Extension*
*/
Extension *_extension;
/**
- * Optional extra data
- * @var Type
+ * Pointer to user supplied data
+ * @var void*
*/
- Type _data;
+ void *_data = NULL;
};
/**
diff --git a/include/extension.h b/include/extension.h
index f5987e2..b322533 100644
--- a/include/extension.h
+++ b/include/extension.h
@@ -35,12 +35,12 @@ namespace Php {
*/
typedef void (*native_callback_0)();
typedef void (*native_callback_1)(Parameters &);
-typedef void (*native_callback_2)(Request &);
-typedef void (*native_callback_3)(Request &, Parameters &);
+typedef void (*native_callback_2)(Environment &);
+typedef void (*native_callback_3)(Environment &, Parameters &);
typedef Value (*native_callback_4)();
typedef Value (*native_callback_5)(Parameters &);
-typedef Value (*native_callback_6)(Request &);
-typedef Value (*native_callback_7)(Request &, Parameters &);
+typedef Value (*native_callback_6)(Environment &);
+typedef Value (*native_callback_7)(Environment &, Parameters &);
/**
* Class definition
@@ -99,17 +99,29 @@ public:
}
/**
- * Create a new request
+ * Create a new environment
*
- * You can override this method if you've created your own request class,
+ * You can override this method if you've created your own environment class,
* and you'd like to use an instance of that class instead. The returned
* object must have been created on the heap.
*
- * @return Request*
+ * @return Environment*
*/
- virtual Request *request()
+ virtual Environment *createEnvironment()
{
- return new Request(this);
+ return new Environment(this);
+ }
+
+ /**
+ * Destruct an environment
+ *
+ * This is the counterpart of the createEnvironment method.
+ *
+ * @param Environment
+ */
+ virtual void deleteEnvironment(Environment *environment)
+ {
+ delete environment;
}
/**
@@ -121,17 +133,8 @@ public:
*
* @return boolean
*/
- bool startRequest()
+ bool startRequest(Environment &environment)
{
-// // failure if we already have a request
-// if (_request) return false;
-//
-// // create the request
-// _request = request();
-//
-// // and initialize it
-// return _request->initialize();
-
return true;
}
@@ -143,20 +146,8 @@ public:
*
* @return boolean
*/
- bool endRequest()
+ bool endRequest(Environment &environment)
{
-// // request must exist
-// if (!_request) return false;
-//
-// // finalize the request
-// bool result = _request->finalize();
-//
-// // destruct the request object
-// delete _request;
-//
-// // done
-// return result;
-
return true;
}
diff --git a/include/function.h b/include/function.h
index ff4396c..c78fdd6 100644
--- a/include/function.h
+++ b/include/function.h
@@ -94,11 +94,11 @@ public:
/**
* Method that gets called every time the function is executed
- * @param request Request object
+ * @param environment Environment object
* @param params The parameters that were passed
* @return Variable Return value
*/
- virtual Value invoke(Request &request, Parameters &params)
+ virtual Value invoke(Environment &environment, Parameters &params)
{
return nullptr;
}