1234567891011121314151617181920212223242526272829303132333435363738394041 |
- namespace nanxing_extend
- {
- //这是个意外,本来是想工厂类和不同的过滤器划分到不同文件的,但是由于贯彻head_only,还没想出来怎么组织文件,只能丢在一起了
- //但是但是相信我不会有God class
- class FilterPolicy
- {
- private:
- FilterPolicy& operator=(FilterPolicy const&)=delete;
- FilterPolicy(FilterPolicy const&)=delete;
- public:
- //限制当主动生成一个工厂类后,不管怎么赋值,最后只有一个工厂
- //move-only
- FilterPolicy(){};
- FilterPolicy(FilterPolicy&&){};
- //两个工厂函数用于生成不同的过滤器
- FilterPolicy* creat_Bloomfilter();
- FilterPolicy* creat_Cuckoofilter();
- };
- class bloomfilter:public FilterPolicy
- {
- };
- class Cuckoofilter:public FilterPolicy
- {
- };
- FilterPolicy* FilterPolicy::creat_Bloomfilter()
- {
- return new bloomfilter;
- }
- FilterPolicy* FilterPolicy::creat_Cuckoofilter()
- {
- return new Cuckoofilter;
- }
- }
|