-
Notifications
You must be signed in to change notification settings - Fork 2
/
polyRESTProcess.h
61 lines (50 loc) · 1.59 KB
/
polyRESTProcess.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
@copyright Russell Standish 2019
@author Russell Standish
This file is part of Classdesc
Open source licensed under the MIT license. See LICENSE for details.
*/
#ifndef CLASSDESC_POLYRESTPROCESS_H
#define CLASSDESC_POLYRESTPROCESS_H
#include "RESTProcess_base.h"
#include "polyRESTProcessBase.h"
namespace classdesc
{
template <class T, class Base=PolyRESTProcessBase>
struct PolyRESTProcess: public Base
{
void RESTProcess(RESTProcess_t& rp, const string& d) const override
{::RESTProcess(rp,d,dynamic_cast<const T&>(*this));}
void RESTProcess(RESTProcess_t& rp, const string& d) override
{::RESTProcess(rp,d,dynamic_cast<T&>(*this));}
};
template <> struct tn<classdesc::PolyRESTProcessBase>
{
static std::string name()
{return "classdesc::PolyRESTProcessBase";}
};
template <class T> struct tn<classdesc::PolyRESTProcess<T> >
{
static std::string name()
{return "classdesc::PolyRESTProcess<"+typeName<T>()+">";}
};
template <class T>
typename enable_if<is_base_of<PolyRESTProcessBase, T>, RPPtr>::T
rProcess(T& a, const string& remainder, const REST_PROCESS_BUFFER& arguments)
{
RESTProcess_t r;
a.RESTProcess(r,"");
auto i=r.find("");
if (i!=r.end())
return i->second->process(remainder,arguments);
else
return std::make_shared<RESTProcessVoid>();
}
template <class T>
typename enable_if<Not<is_base_of<PolyRESTProcessBase, T>>, RPPtr>::T
rProcess(T& a, const string& remainder, const REST_PROCESS_BUFFER& arguments)
{
return RESTProcessObject<T>(a).process(remainder, arguments);
}
}
#endif