Classdesc 3.44
polyRESTProcess.h
1/*
2 @copyright Russell Standish 2019
3 @author Russell Standish
4 This file is part of Classdesc
5
6 Open source licensed under the MIT license. See LICENSE for details.
7*/
8
9#ifndef CLASSDESC_POLYRESTPROCESS_H
10#define CLASSDESC_POLYRESTPROCESS_H
11#include "RESTProcess_base.h"
12#include "polyRESTProcessBase.h"
13
14namespace classdesc
15{
16 template <class T, class Base=PolyRESTProcessBase>
17 struct PolyRESTProcess: public Base
18 {
19 void RESTProcess(RESTProcess_t& rp, const string& d) const override
20 {::RESTProcess(rp,d,dynamic_cast<const T&>(*this));}
21 void RESTProcess(RESTProcess_t& rp, const string& d) override
22 {::RESTProcess(rp,d,dynamic_cast<T&>(*this));}
23 };
24
25 template <> struct tn<classdesc::PolyRESTProcessBase>
26 {
27 static std::string name()
28 {return "classdesc::PolyRESTProcessBase";}
29 };
30 template <class T> struct tn<classdesc::PolyRESTProcess<T> >
31 {
32 static std::string name()
33 {return "classdesc::PolyRESTProcess<"+typeName<T>()+">";}
34 };
35
36 template <class T>
38 rProcess(T& a, const string& remainder, const REST_PROCESS_BUFFER& arguments)
39 {
41 a.RESTProcess(r,"");
42 auto i=r.find("");
43 if (i!=r.end())
44 return i->second->process(remainder,arguments);
45 else
46 return std::make_shared<RESTProcessVoid>();
47 }
48
49 template <class T>
50 typename enable_if<Not<is_base_of<PolyRESTProcessBase, T>>, RPPtr>::T
51 rProcess(T& a, const string& remainder, const REST_PROCESS_BUFFER& arguments)
52 {
53 return RESTProcessObject<T>(a).process(remainder, arguments);
54 }
55
56
57
58}
59
60#endif
61
Contains definitions related to classdesc functionality.
Definition polyRESTProcessBase.h:15
Definition polyRESTProcess.h:18
REST processor registry.
Definition RESTProcess_base.h:351
controlled template specialisation: stolen from boost::enable_if.
Definition classdesc.h:282
Definition classdesc.h:571