Browse Source

Merge pull request #185 from trapexit/policy_template

change to using template for policy class
pull/190/head
Antonio SJ Musumeci 9 years ago
parent
commit
47dc59bff2
  1. 46
      src/policy.hpp

46
src/policy.hpp

@ -76,57 +76,41 @@ namespace mergerfs
typedef int (*Ptr)(CType,cstrvec&,cstring&,csize_t,strvec&);
class Action
template <CType T>
class Base
{
public:
Action(const Policy *p)
Base(const Policy *p)
: func(p->_func)
{}
int
operator()(cstrvec& b,cstring& c,csize_t d,strvec& e)
{
return func(Category::Enum::action,b,c,d,e);
return func(T,b,c,d,e);
}
private:
const Ptr func;
};
class Create
{
public:
Create(const Policy *p)
: func(p->_func)
{}
int
operator()(cstrvec& b,cstring& c,csize_t d,strvec& e)
operator()(cstrvec& b,cstring& c,csize_t d,string& e)
{
return func(Category::Enum::create,b,c,d,e);
}
int rv;
strvec vec;
private:
const Ptr func;
};
rv = func(T,b,c,d,vec);
if(!vec.empty())
e = vec[0];
class Search
{
public:
Search(const Policy *p)
: func(p->_func)
{}
int
operator()(cstrvec& b,cstring& c,csize_t d,strvec& e)
{
return func(Category::Enum::search,b,c,d,e);
return rv;
}
private:
const Ptr func;
};
typedef Base<Category::Enum::action> Action;
typedef Base<Category::Enum::create> Create;
typedef Base<Category::Enum::search> Search;
static int all(CType,cstrvec&,cstring&,csize_t,strvec&);
static int einval(CType,cstrvec&,cstring&,csize_t,strvec&);
static int enosys(CType,cstrvec&,cstring&,csize_t,strvec&);

Loading…
Cancel
Save