summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-04-02 23:12:31 +0200
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-04-02 23:12:31 +0200
commita3bd6dc04d5210ddeffdda5884f51c0e5b37ec27 (patch)
tree41ec4059d1c713e117126e1e131564946e0b27ad /include
parentbbdcdae98979e002476fc1e8296effd0b270928b (diff)
added Class::implements() method to allow classes that implement interfaces (request from issue #52)
Diffstat (limited to 'include')
-rw-r--r--include/class.h2
-rw-r--r--include/classbase.h3
-rw-r--r--include/interface.h12
3 files changed, 11 insertions, 6 deletions
diff --git a/include/class.h b/include/class.h
index 8bc034c..8c78069 100644
--- a/include/class.h
+++ b/include/class.h
@@ -186,7 +186,7 @@ public:
* @param interface Interface object
* @return Class Same object to allow chaining
*/
-// Class<T> &implements(const Interface &interface) { ClassBase::implements(interface); return *this; }
+ Class<T> &implements(const Interface &interface) { ClassBase::implements(interface); return *this; }
/**
* Add a base class
diff --git a/include/classbase.h b/include/classbase.h
index e399efe..c2a9022 100644
--- a/include/classbase.h
+++ b/include/classbase.h
@@ -259,7 +259,7 @@ protected:
* Add an interface
* @param interface Interface object
*/
-// void implements(const ClassBase &interface) { _interfaces.push_back(&interface); }
+ void implements(const ClassBase &interface);
/**
* Set the base class
@@ -268,7 +268,6 @@ protected:
// void extends(const std::string &name) { _base = name; }
private:
-
/**
* Pointer to the actual implementation
* @var std::shared_ptr<ClassImpl>
diff --git a/include/interface.h b/include/interface.h
index 36f4d50..32462c8 100644
--- a/include/interface.h
+++ b/include/interface.h
@@ -41,12 +41,18 @@ public:
// return self
return *this;
}
-
-private:
+
/**
- * Namespaces have access to the private base class
+ * The namespace needs to have access to the private ClassBase base
+ * class, to actually register the interface.
*/
friend class Namespace;
+
+ /**
+ * All Php::Class<AnyThing> also need access to the base class to
+ * register an interface.
+ */
+ template<typename ANYTHING> friend class Class;
};
/**