filter.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. namespace nanxing_extend
  2. {
  3. //这是个意外,本来是想工厂类和不同的过滤器划分到不同文件的,但是由于贯彻head_only,还没想出来怎么组织文件,只能丢在一起了
  4. //但是但是相信我不会有God class
  5. class FilterPolicy
  6. {
  7. private:
  8. FilterPolicy& operator=(FilterPolicy const&)=delete;
  9. FilterPolicy(FilterPolicy const&)=delete;
  10. public:
  11. //限制当主动生成一个工厂类后,不管怎么赋值,最后只有一个工厂
  12. //move-only
  13. FilterPolicy(){};
  14. FilterPolicy(FilterPolicy&&){};
  15. //两个工厂函数用于生成不同的过滤器
  16. FilterPolicy* creat_Bloomfilter();
  17. FilterPolicy* creat_Cuckoofilter();
  18. };
  19. class bloomfilter:public FilterPolicy
  20. {
  21. };
  22. class Cuckoofilter:public FilterPolicy
  23. {
  24. };
  25. FilterPolicy* FilterPolicy::creat_Bloomfilter()
  26. {
  27. return new bloomfilter;
  28. }
  29. FilterPolicy* FilterPolicy::creat_Cuckoofilter()
  30. {
  31. return new Cuckoofilter;
  32. }
  33. }