summaryrefslogtreecommitdiff
path: root/graphs/cpp/chain_of_responsibility/handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'graphs/cpp/chain_of_responsibility/handler.cc')
-rw-r--r--graphs/cpp/chain_of_responsibility/handler.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/graphs/cpp/chain_of_responsibility/handler.cc b/graphs/cpp/chain_of_responsibility/handler.cc
new file mode 100644
index 0000000..256933b
--- /dev/null
+++ b/graphs/cpp/chain_of_responsibility/handler.cc
@@ -0,0 +1,19 @@
+#include "handler.hh"
+
+#include <iostream>
+Handler::Handler(Handler* next)
+ : next_{ next }
+{}
+void Handler::set_successor(Handler* h)
+{
+ next_ = h;
+}
+void Handler::forward_request(int level)
+{
+ if (next_ == nullptr)
+ {
+ std::cout << "Nobody can handle this request\n";
+ }
+ else
+ next_->handle_request(level);
+} \ No newline at end of file