Minsky
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 TCL_obj(classdesc::TCL_obj_t& t, const std::string& d) override
46  {::TCL_obj(t,d,*dynamic_cast<T*>(this));}
47  void RESTProcess(classdesc::RESTProcess_t& rp,const std::string& d) override
48  {::RESTProcess(rp,d,dynamic_cast<T&>(*this));}
49  void RESTProcess(classdesc::RESTProcess_t& rp,const std::string& d) const override
50  {::RESTProcess(rp,d,dynamic_cast<const T&>(*this));}
51  void json_pack(classdesc::json_pack_t& j) const override
52  {::json_pack(j,"",dynamic_cast<const T&>(*this));}
53  ItemT()=default;
54  ItemT(const ItemT&)=default;
55  ItemT& operator=(const ItemT&)=default;
56  // delete move operations to avoid the dreaded virtual-move-assign warning
57  ItemT(ItemT&&)=delete;
58  ItemT& operator=(ItemT&&)=delete;
59  };
60 }
61 
62 #include "itemT.cd"
63 #include "itemT.xcd"
64 #endif
65 
std::string classType() const override
Definition: itemT.h:31
ItemT * clone() const override
Definition: itemT.h:40
ItemT()=default
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky&#39;s state cha...
Definition: constMap.h:22
void json_pack(classdesc::json_pack_t &j) const override
Definition: itemT.h:51
void RESTProcess(classdesc::RESTProcess_t &rp, const std::string &d) const override
Definition: itemT.h:49
void TCL_obj(classdesc::TCL_obj_t &t, const std::string &d) override
Definition: itemT.h:45
ItemT & operator=(const ItemT &)=default
void RESTProcess(classdesc::RESTProcess_t &rp, const std::string &d) override
dummy template definition for use with gui executable
Definition: itemT.h:47