summaryrefslogtreecommitdiff
path: root/include/interface.h
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-01 22:39:31 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-01 22:39:31 +0100
commit6abc8b4c062c7333a98830004da894ff81613d5b (patch)
tree7b11179ef6775130fce0c4ef537fb3656f716852 /include/interface.h
parentabc3b4fbf996a647bcefb02e4ecf643b659577c9 (diff)
added possibility to define interfaces, the class::add() method has been renamed to class::method() and class::property() to prevent ambiguity in defining properties and methods
Diffstat (limited to 'include/interface.h')
-rw-r--r--include/interface.h46
1 files changed, 42 insertions, 4 deletions
diff --git a/include/interface.h b/include/interface.h
index 7bdb5d6..38f85f3 100644
--- a/include/interface.h
+++ b/include/interface.h
@@ -11,11 +11,49 @@
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
+ * Class definition
*/
+class Interface : private ClassBase
+{
+public:
+ /**
+ * Constructor
+ * @param name
+ */
+ Interface(const char *name) : ClassBase(name, 0x80) {}
+
+ /**
+ * Destructor
+ */
+ virtual ~Interface() {}
+
+ /**
+ * Add a - of course abstract - method to the interface
+ * @param name Name of the method
+ * @param arguments Optional description of the arguments
+ */
+ void method(const char *name, const Arguments &arguments = {})
+ {
+ // call base
+ ClassBase::method(name, Abstract | Public, arguments);
+ }
+
+private:
+ /**
+ * Construct a new instance of the object
+ * @return Base
+ */
+ virtual Base* construct() override
+ {
+ // this does not occur for interfaces
+ return nullptr;
+ }
+
+ /**
+ * Namespaces have access to the private base class
+ */
+ friend class Namespace;
+};
/**
* End namespace