summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/abstractclass.h38
-rw-r--r--include/class.h14
-rw-r--r--include/classmodifier.h29
-rw-r--r--include/finalclass.h38
-rw-r--r--include/interface.h24
-rw-r--r--phpcpp.h4
-rw-r--r--src/includes.h4
7 files changed, 116 insertions, 35 deletions
diff --git a/include/abstractclass.h b/include/abstractclass.h
new file mode 100644
index 0000000..3f41ff9
--- /dev/null
+++ b/include/abstractclass.h
@@ -0,0 +1,38 @@
+/**
+ * AbstractClass.h
+ *
+ * An abstract class can not be instantiated, it can only be extended
+ *
+ * @copyright 2014 Copernica BV
+ * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
+ */
+
+/**
+ * Set up namespace
+ */
+namespace Php {
+
+/**
+ * Class definition
+ */
+template <typename T>
+class AbstractClass : public Class<T>
+{
+public:
+ /**
+ * Constructor
+ * @param name Name of the class
+ */
+ AbstractClass(const char *name) : Class<T>(name, 0x20) {}
+
+ /**
+ * Destructor
+ */
+ virtual ~AbstractClass() {}
+};
+
+/**
+ * End namespace
+ */
+}
+
diff --git a/include/class.h b/include/class.h
index ae66277..fe9ea2e 100644
--- a/include/class.h
+++ b/include/class.h
@@ -12,7 +12,7 @@
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* changed by Valeriy Dmitriev <ufabiz@gmail.com>
- * @copyright 2013 Copernica BV
+ * @copyright 2013, 2014 Copernica BV
*/
/**
@@ -39,11 +39,10 @@ public:
* flags are set, a regular public class will be formed.
*
* @param name Name of the class
- * @param flags Optional flags (final, abstract)
*
* @todo make sure flags are used
*/
- Class(const char *name, int flags = 0) : ClassBase(name, flags) {}
+ Class(const char *name) : ClassBase(name) {}
/**
* Destructor
@@ -93,6 +92,14 @@ public:
void add(const char *name, bool(T::*method)(), const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_2>(method), 0, args); }
void add(const char *name, bool(T::*method)(Parameters &params), const Arguments &args = {}) { ClassBase::add(name, static_cast<method_callback_3>(method), 0, args); }
+protected:
+ /**
+ * Protected constructor
+ * @param name
+ * @param flags
+ */
+ Class(const char *name, int flags) : ClassBase(name, flags) {}
+
private:
/**
* Construct a new instance of the object
@@ -108,7 +115,6 @@ private:
* Extensions have access to the private base class
*/
friend class Extension;
-
};
/**
diff --git a/include/classmodifier.h b/include/classmodifier.h
deleted file mode 100644
index 2cebb65..0000000
--- a/include/classmodifier.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * ClassModifier.h
- *
- * In this file an enumeration type is defined with
- * the possible class modifiers.
- *
- * @author Martijn Otto
- * @copyright 2014 Copernica BV
- */
-
-/**
- * Set up namespace
- */
-namespace Php {
-
-/**
- * Supported class modifiers
- */
-typedef enum _ClassModifier {
- regular = 0x00,
- abstract = 0x20,
- final = 0x40,
- interface = 0x80
-} ClassModifier;
-
-/**
- * End of namespace
- */
-}
diff --git a/include/finalclass.h b/include/finalclass.h
new file mode 100644
index 0000000..5c5a1b6
--- /dev/null
+++ b/include/finalclass.h
@@ -0,0 +1,38 @@
+/**
+ * FinalClass.h
+ *
+ * An final class can not be extended
+ *
+ * @copyright 2014 Copernica BV
+ * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
+ */
+
+/**
+ * Set up namespace
+ */
+namespace Php {
+
+/**
+ * Class definition
+ */
+template <typename T>
+class FinalClass : public Class<T>
+{
+public:
+ /**
+ * Constructor
+ * @param name Name of the class
+ */
+ FinalClass(const char *name) : Class<T>(name, 0x40) {}
+
+ /**
+ * Destructor
+ */
+ virtual ~FinalClass() {}
+};
+
+/**
+ * End namespace
+ */
+}
+
diff --git a/include/interface.h b/include/interface.h
new file mode 100644
index 0000000..7bdb5d6
--- /dev/null
+++ b/include/interface.h
@@ -0,0 +1,24 @@
+/**
+ * Interface.h
+ *
+ * @copyright 2014 Copernica BV
+ * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
+ */
+
+/**
+ * Set up namespace
+ */
+namespace Php {
+
+/**
+ * @todo implementation, should be somehow an extension of a regular
+ * class, but without methods to define methods
+ *
+ * the flag that should be passed to the base it 0x80
+ */
+
+/**
+ * End namespace
+ */
+}
+
diff --git a/phpcpp.h b/phpcpp.h
index 08918a5..54608ac 100644
--- a/phpcpp.h
+++ b/phpcpp.h
@@ -45,9 +45,11 @@
#include <phpcpp/private.h>
#include <phpcpp/const.h>
#include <phpcpp/members.h>
-#include <phpcpp/classmodifier.h>
#include <phpcpp/classbase.h>
#include <phpcpp/class.h>
+#include <phpcpp/abstractclass.h>
+#include <phpcpp/finalclass.h>
+#include <phpcpp/interface.h>
#include <phpcpp/extension.h>
#include <phpcpp/exception.h>
diff --git a/src/includes.h b/src/includes.h
index 4e6e583..392a380 100644
--- a/src/includes.h
+++ b/src/includes.h
@@ -63,9 +63,11 @@
#include "../include/private.h"
#include "../include/const.h"
#include "../include/members.h"
-#include "../include/classmodifier.h"
#include "../include/classbase.h"
#include "../include/class.h"
+#include "../include/abstractclass.h"
+#include "../include/finalclass.h"
+#include "../include/interface.h"
#include "../include/extension.h"
#include "../include/exception.h"
#include "../include/init.h"