AbstractCoupledModel.hpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. /**
  2. * @file artis/kernel/AbstractCoupledModel.hpp
  3. * @author See the AUTHORS file
  4. */
  5. /*
  6. * Copyright (C) 2012-2017 ULCO http://www.univ-littoral.fr
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef __ARTIS_KERNEL_ABSTRACT_COUPLED_MODEL_HPP
  22. #define __ARTIS_KERNEL_ABSTRACT_COUPLED_MODEL_HPP
  23. #include <artis/kernel/AbstractModel.hpp>
  24. #include <artis/kernel/Externals.hpp>
  25. #include <artis/kernel/Internals.hpp>
  26. #include <artis/kernel/States.hpp>
  27. #include <artis/utils/DateTime.hpp>
  28. #include <artis/utils/Trace.hpp>
  29. #include <functional>
  30. #include <vector>
  31. namespace artis { namespace kernel {
  32. template < typename T, typename U, typename V, typename W >
  33. class AbstractCoupledModel : public AbstractModel < U, V >,
  34. public States < T, U, V >,
  35. public Internals < T, U, V >,
  36. public Externals < T, U, V >
  37. {
  38. typedef AbstractModel < U, V > type;
  39. typedef std::map < int, type* > Submodels;
  40. typedef std::map < int,
  41. std::vector < type* > > Setsubmodels;
  42. typedef std::map < int, std::pair < type*,
  43. int > > SubModelInternals;
  44. public:
  45. struct Var
  46. {
  47. unsigned int index;
  48. type* model;
  49. int sub_index;
  50. Var (unsigned int index, type* model, int sub_index) :
  51. index(index), model(model), sub_index(sub_index)
  52. { }
  53. };
  54. AbstractCoupledModel(const type* parent = 0) : type(parent)
  55. { }
  56. virtual ~AbstractCoupledModel()
  57. { }
  58. virtual void after(typename U::type t)
  59. {
  60. #ifdef WITH_TRACE
  61. utils::Trace < utils::DoubleTime >::trace()
  62. << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
  63. utils::KERNEL)
  64. << "AFTER - "
  65. << AbstractCoupledModel < T, U, V, W >::path(this);
  66. utils::Trace < utils::DoubleTime >::trace().flush();
  67. for (size_t i = 0; i < Internals < T, U, V >::size(); ++i) {
  68. if (not Internals < T, U, V >::get(i).is_null()) {
  69. utils::Trace < utils::DoubleTime >::trace()
  70. << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
  71. utils::KERNEL)
  72. << Internals < T, U, V >::name(i) << " = "
  73. << Internals < T, U, V >::get(i).to_string(
  74. dynamic_cast < const T* >(this));
  75. utils::Trace < utils::DoubleTime >::trace().flush();
  76. }
  77. }
  78. #else
  79. (void) t;
  80. #endif
  81. }
  82. virtual const Node < U >* atomic(unsigned int index) const
  83. {
  84. typename AbstractCoupledModel::SubModelInternals::const_iterator it =
  85. submodel_internals.find(index);
  86. if (it == submodel_internals.end()) {
  87. return this;
  88. } else {
  89. return it->second.first->atomic(it->second.second);
  90. }
  91. }
  92. virtual void before(typename U::type t)
  93. {
  94. #ifdef WITH_TRACE
  95. utils::Trace < utils::DoubleTime >::trace()
  96. << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
  97. utils::KERNEL)
  98. << "BEFORE - "
  99. << AbstractCoupledModel < T, U, V, W >::path(this);
  100. utils::Trace < utils::DoubleTime >::trace().flush();
  101. for (size_t i = 0; i < Internals < T, U, V >::size(); ++i) {
  102. if (not Internals < T, U, V >::get(i).is_null()) {
  103. utils::Trace < utils::DoubleTime >::trace()
  104. << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
  105. utils::KERNEL)
  106. << Internals < T, U, V >::name(i) << " = "
  107. << Internals < T, U, V >::get(i).to_string(
  108. dynamic_cast < const T* >(this));
  109. utils::Trace < utils::DoubleTime >::trace().flush();
  110. }
  111. }
  112. #else
  113. (void) t;
  114. #endif
  115. }
  116. virtual void build(W& /* parameters */)
  117. { }
  118. virtual void build(W& /* parameters */, const std::string& /* json */)
  119. { }
  120. virtual bool check(typename U::type t) const
  121. { return Externals < T, U, V >::check(t); }
  122. virtual void compute(typename U::type t, bool update) = 0;
  123. virtual const Any& get(typename U::type t, unsigned int index) const
  124. {
  125. typename AbstractCoupledModel::SubModelInternals::const_iterator it =
  126. submodel_internals.find(index);
  127. if (it == submodel_internals.end()) {
  128. if (type::last_time != t) {
  129. throw utils::InvalidGet("Variable not computed");
  130. }
  131. return Internals < T, U, V >::get(index);
  132. } else {
  133. return it->second.first->get(t, it->second.second);
  134. }
  135. }
  136. template < typename Z, typename K >
  137. Z get(typename U::type t, unsigned int index) const
  138. {
  139. typename AbstractCoupledModel::SubModelInternals::const_iterator it =
  140. submodel_internals.find(index);
  141. if (it == submodel_internals.end()) {
  142. if (type::last_time != t) {
  143. throw utils::InvalidGet("Variable not computed");
  144. }
  145. const Any& value = Internals < T, U, V >::get(index);
  146. return static_cast < const T* >(this)->*(value.get < T, Z >());
  147. } else {
  148. const Any& value = it->second.first->get(t, it->second.second);
  149. const Node < U >* object = it->second.first->atomic(
  150. it->second.second);
  151. return static_cast < const K* >(object)->*(value.get < K, Z >());
  152. }
  153. }
  154. virtual std::string get(const ValueType& value_type, typename U::type t,
  155. unsigned int index) const
  156. {
  157. typename AbstractCoupledModel::SubModelInternals::const_iterator it =
  158. submodel_internals.find(index);
  159. if (it == submodel_internals.end()) {
  160. Any value = Internals < T, U, V >::get(index);
  161. switch (value_type) {
  162. case DOUBLE:
  163. return std::to_string(
  164. static_cast < const T* >(this)->*(value.get < T,
  165. double >()));
  166. case INT:
  167. return std::to_string(
  168. static_cast < const T* >(this)->*(value.get < T, int >()));
  169. case BOOL:
  170. return std::to_string(
  171. static_cast < const T* >(this)->*(value.get < T, bool >()));
  172. default: return "NA";
  173. }
  174. } else {
  175. return it->second.first->get(value_type, t, it->second.second);
  176. }
  177. }
  178. virtual void init(typename U::type t, const V& parameters) = 0;
  179. virtual bool is_atomic() const
  180. { return false; }
  181. bool is_computed(typename U::type t, unsigned int index) const
  182. {
  183. typename AbstractCoupledModel::SubModelInternals::const_iterator it =
  184. submodel_internals.find(index);
  185. if (it == submodel_internals.end()) {
  186. return false;
  187. } else {
  188. return it->second.first->is_computed(t, it->second.second);
  189. }
  190. }
  191. bool is_stable(typename U::type t) const
  192. {
  193. typename AbstractCoupledModel::SubModelInternals::const_iterator it =
  194. submodel_internals.begin();
  195. bool stable = true;
  196. while (it != submodel_internals.end() and stable) {
  197. stable = it->second.first->is_stable(t);
  198. ++it;
  199. }
  200. return stable;
  201. }
  202. virtual bool is_updated() const
  203. { return Externals < T, U, V >::updated; }
  204. virtual const Node < U >* get_submodel(unsigned int index) const
  205. {
  206. typename AbstractCoupledModel::Submodels::const_iterator it =
  207. submodels.find(index);
  208. if (it != submodels.end()) {
  209. return it->second;
  210. } else {
  211. return 0;
  212. }
  213. }
  214. virtual const Node < U >* get_submodel(unsigned int index,
  215. unsigned int rank) const
  216. {
  217. typename AbstractCoupledModel::Setsubmodels::const_iterator it =
  218. setsubmodels.find(index);
  219. if (it != setsubmodels.end() and it->second.size() > rank) {
  220. return it->second.at(rank);
  221. } else {
  222. return 0;
  223. }
  224. }
  225. virtual std::string path_index(const AbstractModel < U, V >* child,
  226. int& index) const
  227. {
  228. typename Setsubmodels::const_iterator it = setsubmodels.begin();
  229. bool found = false;
  230. index = -1;
  231. while (not found and it != setsubmodels.end()) {
  232. typename std::vector < type* >::const_iterator itm =
  233. it->second.begin();
  234. index = 0;
  235. while (not found and itm != it->second.end()) {
  236. found = *itm == child;
  237. if (not found) {
  238. ++index;
  239. ++itm;
  240. }
  241. }
  242. index = found ? index : -1;
  243. ++it;
  244. }
  245. if (type::parent) {
  246. int i;
  247. std::string p = type::parent->path_index(this, i);
  248. if (i >= 0) {
  249. return p +
  250. "/[" + std::to_string(i) + "]" +
  251. boost::core::demangle(typeid(*this).name());
  252. } else {
  253. return p + "/" + boost::core::demangle(typeid(*this).name());
  254. }
  255. } else {
  256. return boost::core::demangle(typeid(*this).name());
  257. }
  258. }
  259. virtual void restore(const context::State < U >& state)
  260. {
  261. typename AbstractCoupledModel::Submodels::const_iterator it =
  262. submodels.begin();
  263. while (it != submodels.end()) {
  264. it->second->restore(state.get_substate(it->first));
  265. ++it;
  266. }
  267. States < T, U, V >::restore(this, state);
  268. Internals < T, U, V >::restore(this, state);
  269. Externals < T, U, V >::restore(this, state);
  270. }
  271. virtual void save(context::State < U >& state) const
  272. {
  273. typename AbstractCoupledModel::Submodels::const_iterator it =
  274. submodels.begin();
  275. while (it != submodels.end()) {
  276. context::State < U > substate;
  277. it->second->save(substate);
  278. state.add_substate(it->first, substate);
  279. ++it;
  280. }
  281. States < T, U, V >::save(this, state);
  282. Internals < T, U, V >::save(this, state);
  283. Externals < T, U, V >::save(this, state);
  284. }
  285. virtual void stable()
  286. { Externals < T, U, V >::updated = false; }
  287. void submodel(unsigned int index, type* model)
  288. {
  289. if (model) {
  290. submodels[index] = model;
  291. model->set_parent(this);
  292. } else {
  293. submodels[index] = 0;
  294. }
  295. }
  296. protected:
  297. void change_internal(unsigned int index, double T::* var)
  298. {
  299. submodel_internals.erase(index);
  300. Internals < T, U, V >::internal(index, var);
  301. }
  302. void change_internal(unsigned int index, int T::* var)
  303. {
  304. submodel_internals.erase(index);
  305. Internals < T, U, V >::internalI(index, var);
  306. }
  307. void change_internal(unsigned int index, bool T::* var)
  308. {
  309. submodel_internals.erase(index);
  310. Internals < T, U, V >::internalB(index, var);
  311. }
  312. void link_internal_(unsigned int index, type* model, int sub_index)
  313. {
  314. submodel_internals[index] =
  315. std::pair < type*, int >(model, sub_index);
  316. }
  317. void I_(std::initializer_list < Var > internals)
  318. {
  319. for (typename std::initializer_list < Var >::iterator it =
  320. internals.begin(); it != internals.end(); ++it) {
  321. submodel_internals[it->index] =
  322. std::pair < type*, int >(it->model, it->sub_index);
  323. }
  324. }
  325. void SM_(std::initializer_list < std::pair < unsigned int,
  326. type* > > models)
  327. {
  328. for (typename std::initializer_list < std::pair < unsigned int,
  329. type* > >::iterator it =
  330. models.begin(); it != models.end(); ++it) {
  331. submodels[it->first] = it->second;
  332. it->second->set_parent(this);
  333. }
  334. }
  335. void setsubmodel(unsigned int index, type* model)
  336. {
  337. if (setsubmodels.find(index) == setsubmodels.end()) {
  338. setsubmodels[index] = std::vector < type* >();
  339. }
  340. setsubmodels[index].push_back(model);
  341. model->set_parent(this);
  342. }
  343. private:
  344. SubModelInternals submodel_internals;
  345. Submodels submodels;
  346. Setsubmodels setsubmodels;
  347. };
  348. #define InternalS(index, var, sub_index) link_internal_(index, var, sub_index)
  349. #define ITEM_S(index, var, sub_index) Var(index, var, sub_index)
  350. #define UNWRAP_ITEM_S(...) ITEM_S __VA_ARGS__
  351. #define LIST_S_16(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15, L16) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8), UNWRAP_ITEM_S(L9), UNWRAP_ITEM_S(L10), UNWRAP_ITEM_S(L11), UNWRAP_ITEM_S(L12), UNWRAP_ITEM_S(L13), UNWRAP_ITEM_S(L14), UNWRAP_ITEM_S(L15), UNWRAP_ITEM_S(L16) }
  352. #define LIST_S_15(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8), UNWRAP_ITEM_S(L9), UNWRAP_ITEM_S(L10), UNWRAP_ITEM_S(L11), UNWRAP_ITEM_S(L12), UNWRAP_ITEM_S(L13), UNWRAP_ITEM_S(L14), UNWRAP_ITEM_S(L15) }
  353. #define LIST_S_14(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8), UNWRAP_ITEM_S(L9), UNWRAP_ITEM_S(L10), UNWRAP_ITEM_S(L11), UNWRAP_ITEM_S(L12), UNWRAP_ITEM_S(L13), UNWRAP_ITEM_S(L14) }
  354. #define LIST_S_13(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8), UNWRAP_ITEM_S(L9), UNWRAP_ITEM_S(L10), UNWRAP_ITEM_S(L11), UNWRAP_ITEM_S(L12), UNWRAP_ITEM_S(L13) }
  355. #define LIST_S_12(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8), UNWRAP_ITEM_S(L9), UNWRAP_ITEM_S(L10), UNWRAP_ITEM_S(L11), UNWRAP_ITEM_S(L12) }
  356. #define LIST_S_11(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8), UNWRAP_ITEM_S(L9), UNWRAP_ITEM_S(L10), UNWRAP_ITEM_S(L11) }
  357. #define LIST_S_10(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8), UNWRAP_ITEM_S(L9), UNWRAP_ITEM_S(L10) }
  358. #define LIST_S_9(L1, L2, L3, L4, L5, L6, L7, L8, L9) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8), UNWRAP_ITEM_S(L9) }
  359. #define LIST_S_8(L1, L2, L3, L4, L5, L6, L7, L8) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8) }
  360. #define LIST_S_7(L1, L2, L3, L4, L5, L6, L7) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7) }
  361. #define LIST_S_6(L1, L2, L3, L4, L5, L6) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6) }
  362. #define LIST_S_5(L1, L2, L3, L4, L5) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5) }
  363. #define LIST_S_4(L1, L2, L3, L4) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4) }
  364. #define LIST_S_3(L1, L2, L3) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3) }
  365. #define LIST_S_2(L1, L2) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2) }
  366. #define LIST_S_1(L1) { UNWRAP_ITEM_S(L1) }
  367. #define LIST_S_(N) LIST_S_##N
  368. #define LIST_S_EVAL(N) LIST_S_(N)
  369. #define UNWRAP_S_2(...) EXPAND( LIST_S_EVAL(EXPAND( PP_NARG(__VA_ARGS__) ))(__VA_ARGS__) )
  370. //#define UNWRAP_S_2(...) GET_MACRO(__VA_ARGS__, LIST_S_16, LIST_S_15, LIST_S_14, LIST_S_13, LIST_S_12, LIST_S_11, LIST_S_10, LIST_S_9, LIST_S_8, LIST_S_7, LIST_S_6, LIST_S_5, LIST_S_4, LIST_S_3, LIST_S_2, LIST_S_1)(__VA_ARGS__)
  371. #define InternalsS(L) I_(UNWRAP_S_2 L)
  372. #define ITEM_Sub(index, model) { index, model }
  373. #define UNWRAP_ITEM_Sub(...) ITEM_Sub __VA_ARGS__
  374. #define LIST_Sub_16(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15, L16) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4), UNWRAP_ITEM_Sub(L5), UNWRAP_ITEM_Sub(L6), UNWRAP_ITEM_Sub(L7), UNWRAP_ITEM_Sub(L8), UNWRAP_ITEM_Sub(L9), UNWRAP_ITEM_Sub(L10), UNWRAP_ITEM_Sub(L11), UNWRAP_ITEM_Sub(L12), UNWRAP_ITEM_Sub(L13), UNWRAP_ITEM_Sub(L14), UNWRAP_ITEM_Sub(L15), UNWRAP_ITEM_Sub(L16) }
  375. #define LIST_Sub_15(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4), UNWRAP_ITEM_Sub(L5), UNWRAP_ITEM_Sub(L6), UNWRAP_ITEM_Sub(L7), UNWRAP_ITEM_Sub(L8), UNWRAP_ITEM_Sub(L9), UNWRAP_ITEM_Sub(L10), UNWRAP_ITEM_Sub(L11), UNWRAP_ITEM_Sub(L12), UNWRAP_ITEM_Sub(L13), UNWRAP_ITEM_Sub(L14), UNWRAP_ITEM_Sub(L15) }
  376. #define LIST_Sub_14(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4), UNWRAP_ITEM_Sub(L5), UNWRAP_ITEM_Sub(L6), UNWRAP_ITEM_Sub(L7), UNWRAP_ITEM_Sub(L8), UNWRAP_ITEM_Sub(L9), UNWRAP_ITEM_Sub(L10), UNWRAP_ITEM_Sub(L11), UNWRAP_ITEM_Sub(L12), UNWRAP_ITEM_Sub(L13), UNWRAP_ITEM_Sub(L14) }
  377. #define LIST_Sub_13(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4), UNWRAP_ITEM_Sub(L5), UNWRAP_ITEM_Sub(L6), UNWRAP_ITEM_Sub(L7), UNWRAP_ITEM_Sub(L8), UNWRAP_ITEM_Sub(L9), UNWRAP_ITEM_Sub(L10), UNWRAP_ITEM_Sub(L11), UNWRAP_ITEM_Sub(L12), UNWRAP_ITEM_Sub(L13) }
  378. #define LIST_Sub_12(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4), UNWRAP_ITEM_Sub(L5), UNWRAP_ITEM_Sub(L6), UNWRAP_ITEM_Sub(L7), UNWRAP_ITEM_Sub(L8), UNWRAP_ITEM_Sub(L9), UNWRAP_ITEM_Sub(L10), UNWRAP_ITEM_Sub(L11), UNWRAP_ITEM_Sub(L12) }
  379. #define LIST_Sub_11(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4), UNWRAP_ITEM_Sub(L5), UNWRAP_ITEM_Sub(L6), UNWRAP_ITEM_Sub(L7), UNWRAP_ITEM_Sub(L8), UNWRAP_ITEM_Sub(L9), UNWRAP_ITEM_Sub(L10), UNWRAP_ITEM_Sub(L11) }
  380. #define LIST_Sub_10(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4), UNWRAP_ITEM_Sub(L5), UNWRAP_ITEM_Sub(L6), UNWRAP_ITEM_Sub(L7), UNWRAP_ITEM_Sub(L8), UNWRAP_ITEM_Sub(L9), UNWRAP_ITEM_Sub(L10) }
  381. #define LIST_Sub_9(L1, L2, L3, L4, L5, L6, L7, L8, L9) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4), UNWRAP_ITEM_Sub(L5), UNWRAP_ITEM_Sub(L6), UNWRAP_ITEM_Sub(L7), UNWRAP_ITEM_Sub(L8), UNWRAP_ITEM_Sub(L9) }
  382. #define LIST_Sub_8(L1, L2, L3, L4, L5, L6, L7, L8) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4), UNWRAP_ITEM_Sub(L5), UNWRAP_ITEM_Sub(L6), UNWRAP_ITEM_Sub(L7), UNWRAP_ITEM_Sub(L8) }
  383. #define LIST_Sub_7(L1, L2, L3, L4, L5, L6, L7) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4), UNWRAP_ITEM_Sub(L5), UNWRAP_ITEM_Sub(L6), UNWRAP_ITEM_Sub(L7) }
  384. #define LIST_Sub_6(L1, L2, L3, L4, L5, L6) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4), UNWRAP_ITEM_Sub(L5), UNWRAP_ITEM_Sub(L6) }
  385. #define LIST_Sub_5(L1, L2, L3, L4, L5) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4), UNWRAP_ITEM_Sub(L5) }
  386. #define LIST_Sub_4(L1, L2, L3, L4) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3), UNWRAP_ITEM_Sub(L4) }
  387. #define LIST_Sub_3(L1, L2, L3) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2), UNWRAP_ITEM_Sub(L3) }
  388. #define LIST_Sub_2(L1, L2) { UNWRAP_ITEM_Sub(L1), UNWRAP_ITEM_Sub(L2) }
  389. #define LIST_Sub_1(L1) { UNWRAP_ITEM_Sub(L1) }
  390. #define LIST_Sub_(N) LIST_Sub_##N
  391. #define LIST_Sub_EVAL(N) LIST_Sub_(N)
  392. #define UNWRAP_Sub_2(...) EXPAND( LIST_Sub_EVAL(EXPAND( PP_NARG(__VA_ARGS__) ))(__VA_ARGS__) )
  393. //#define UNWRAP_Sub_2(...) GET_MACRO(__VA_ARGS__, LIST_Sub_16, LIST_Sub_15, LIST_Sub_14, LIST_Sub_13, LIST_Sub_12, LIST_Sub_11, LIST_Sub_10, LIST_Sub_9, LIST_Sub_8, LIST_Sub_7, LIST_Sub_6, LIST_Sub_5, LIST_Sub_4, LIST_Sub_3, LIST_Sub_2, LIST_Sub_1)(__VA_ARGS__)
  394. #define Submodels(L) SM_(UNWRAP_Sub_2 L)
  395. } }
  396. #endif