-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathChainHandlers.h
37 lines (32 loc) · 907 Bytes
/
ChainHandlers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <inttypes.h>
#include <cinttypes>
#include <cmath>
#include <vector>
#include <algorithm>
#include <chrono>
#include <sys/time.h>
#include <ctime>
typedef double TDBL ;
class Handler {
public:
virtual Handler *SetNext(Handler *handler) = 0;
virtual std::vector< double > Handle(std::string request, double (*f)(double), TDBL a, TDBL b, std::vector< double > mins) = 0;
};
class AbstractHandler : public Handler {
private:
Handler *next_handler_;
public:
AbstractHandler() : next_handler_(nullptr) {
}
Handler *SetNext(Handler *handler) override {
this->next_handler_ = handler;
return handler;
}
std::vector< double > Handle(std::string request, double (*f)(double), TDBL a, TDBL b, std::vector< double > mins) override {
if (this->next_handler_) {
return this->next_handler_->Handle(request, f, a, b, mins);
}
return {};
}
};