Minsky: 3.17.0
itemT.h
Go to the documentation of this file.
1 /*
2  @copyright Steve Keen 2015
3  @author Russell Standish
4  This file is part of Minsky.
5 
6  Minsky is free software: you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Minsky is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Minsky. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef ITEMT_H
21 #define ITEMT_H
22 
23 #include "item.h"
24 
25 namespace minsky
26 {
28  template <class T, class Base=Item>
29  struct ItemT: public Base
30  {
31  std::string classType() const override {
32  auto s=classdesc::typeName<T>();
33  // remove minsky namespace
34  static const char* ns="::minsky::";
35  static const int eop=strlen(ns);
36  if (s.substr(0,eop)==ns)
37  s=s.substr(eop);
38  return s;
39  }
40  ItemT* clone() const override {
41  auto r=new T(*dynamic_cast<const T*>(this));
42  r->group.reset();
43  return r;
44  }
45  void RESTProcess(classdesc::RESTProcess_t& rp,const std::string& d) override
46  {::RESTProcess(rp,d,dynamic_cast<T&>(*this));}
47  void RESTProcess(classdesc::RESTProcess_t& rp,const std::string& d) const override
48  {::RESTProcess(rp,d,dynamic_cast<const T&>(*this));}
49  void json_pack(classdesc::json_pack_t& j) const override
50  {::json_pack(j,"",dynamic_cast<const T&>(*this));}
51  ItemT()=default;
52  ItemT(const ItemT&)=default;
53  ItemT& operator=(const ItemT&)=default;
54  // delete move operations to avoid the dreaded virtual-move-assign warning
55  ItemT(ItemT&&)=delete;
56  ItemT& operator=(ItemT&&)=delete;
57  };
58 }
59 
60 #include "itemT.cd"
61 #include "itemT.xcd"
62 #endif
63 
std::string classType() const override
Definition: itemT.h:31
ItemT * clone() const override
Definition: itemT.h:40
void RESTProcess(classdesc::RESTProcess_t &rp, const std::string &d) override
Definition: itemT.h:45
ItemT()=default
void RESTProcess(classdesc::RESTProcess_t &rp, const std::string &d) const override
Definition: itemT.h:47
void json_pack(classdesc::json_pack_t &j) const override
Definition: itemT.h:49
ItemT & operator=(const ItemT &)=default