vq3
vq3Decorator.hpp
1 /*
2  * Copyright (C) 2018, CentraleSupelec
3  *
4  * Author : HervĂ© Frezza-Buet
5  *
6  * Contributor :
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public
10  * License (GPL) as published by the Free Software Foundation; either
11  * version 3 of the License, or any later version.
12  *
13  * This library 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 GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  * Contact : herve.frezza-buet@centralesupelec.fr
23  *
24  */
25 
26 
27 #pragma once
28 
29 #include <vq3Utils.hpp>
30 #include <vq3Stats.hpp>
31 
32 #include <iostream>
33 #include <type_traits>
34 #include <string>
35 #include <atomic>
36 
37 namespace vq3 {
38  namespace decorator {
39 
40  /* ########## */
41  /* # # */
42  /* # SFINAE # */
43  /* # # */
44  /* ########## */
45 
49  struct not_decorated {};
50 
55 
60 
61 
62  template<typename T> using sfinae_test = void;
63 
64  template<bool IS_DECORATEDD, bool HAS_VALUE> struct decoration_kind {using value_type = valued_decoration; };
65  template<> struct decoration_kind<false, false> {using value_type = not_decorated; };
66  template<> struct decoration_kind<false, true > {using value_type = not_decorated; };
67  template<> struct decoration_kind<true, false> {using value_type = unvalued_decoration;};
68 
70  template<typename T, typename = void> struct is_decorated : std::false_type {};
71  template<typename T> struct is_decorated<void, T> : std::false_type {};
72  template<typename T, typename = void> struct has_value : std::false_type {};
73  template<typename T> struct has_value<void, T> : std::false_type {};
74 
76  template<typename T> struct is_decorated<T, sfinae_test<typename T::decorated_type> > : std::true_type {};
77  template<typename T> struct has_value <T, sfinae_test<decltype(std::declval<T>().vq3_value)> > : std::true_type {};
78 
80  template<typename T> struct decoration : decoration_kind<is_decorated<T>::value, has_value<T>::value> {};
81 
83  template<typename KIND>
84  struct print {void operator()() {std::cout << "none" << std::endl;}};
85 
86  template<>
87  struct print<valued_decoration> {void operator()() {std::cout << "valued decoration" << std::endl;}};
88 
89  template<>
90  struct print<unvalued_decoration> {void operator()() {std::cout << "unvalued decoration" << std::endl;}};
91 
92  template<>
93  struct print<not_decorated> {void operator()() {std::cout << "not decorated" << std::endl;}};
94  }
95 
96  namespace spec {
97 
98 
104  template<typename MOTHER, typename KIND>
105  struct Decorator : public MOTHER {
107  using decorated_type = typename MOTHER::decorated_type;
109  bool vq3_the_decoration = false;
110 
112  Decorator() = default;
113 
115  Decorator(const Decorator&) = default;
116 
118  Decorator(const decorated_type& val) : MOTHER(val), vq3_the_decoration(false) {}
119 
121  Decorator& operator=(const decorated_type& val) {this->vq3_value = val;}
122  };
123 
127  template<typename MOTHER>
128  struct Decorator<MOTHER, vq3::decorator::not_decorated> {
130  using decorated_type = MOTHER;
132  MOTHER vq3_value;
134  bool vq3_the_decoration = false;
135 
137  Decorator() = default;
139  Decorator(const Decorator&) = default;
141  Decorator(const decorated_type& val) : vq3_value(val), vq3_the_decoration(false) {}
143  Decorator& operator=(const decorated_type& val) {vq3_value = val;}
144  };
145 
149  template<typename MOTHER>
150  struct Decorator<MOTHER, vq3::decorator::unvalued_decoration> : public MOTHER {
152  using decorated_type = MOTHER;
154  bool vq3_the_decoration = false;
156  Decorator() : MOTHER(), vq3_the_decoration(false) {}
157  };
158 
162  template<>
163  struct Decorator<void, vq3::decorator::not_decorated> {
165  using decorated_type = void;
167  bool vq3_the_decoration = false;
171  Decorator(const Decorator&) = default;
172  };
173 
177  template<typename MOTHER>
178  using decorator = Decorator<MOTHER, typename vq3::decorator::decoration<MOTHER>::value_type>;
179 
180  }
181 
182 
183 
184  namespace decorator {
185 
186 
187  /* ######## */
188  /* # # */
189  /* # None # */
190  /* # # */
191  /* ######## */
192 
193  template<typename MOTHER, typename KIND>
194  struct None : public MOTHER {
195  using decorated_type = typename MOTHER::decorated_type;
196  None() = default;
197  None(const None&) = default;
198  None(const decorated_type& val) : MOTHER(val) {}
199  None& operator=(const decorated_type& val) {this->vq3_value = val;}
200  };
201 
202  // When we decorate a non decorated value.
203  template<typename MOTHER>
204  struct None<MOTHER, not_decorated> {
205  using decorated_type = MOTHER;
206  MOTHER vq3_value;
207  None() = default;
208  None(const None&) = default;
209  None(const decorated_type& val) : vq3_value(val) {}
210  None& operator=(const decorated_type& val) {vq3_value = val;}
211  };
212 
213  // When we decorate a decorated type with no value.
214  template<typename MOTHER>
215  struct None<MOTHER, unvalued_decoration> : public MOTHER {
216  using decorated_type = MOTHER;
217  None() : MOTHER() {}
218  None(const None&) = default;
219  };
220 
221  // When we decorate void.
222  template<>
223  struct None<void, not_decorated> {
224  using decorated_type = void;
225  None() = default;
226  None(const None&) = default;
227  };
228 
229  template<typename MOTHER>
231 
232 
233  /* ########## */
234  /* # # */
235  /* # Tagged # */
236  /* # # */
237  /* ########## */
238 
239  template<typename MOTHER, typename KIND>
240  struct Tagged : public MOTHER {
241  using decorated_type = typename MOTHER::decorated_type;
242  bool vq3_tag = false;
243  Tagged() = default;
244  Tagged(const Tagged&) = default;
245  Tagged(const decorated_type& val) : MOTHER(val), vq3_tag(false) {}
246  Tagged& operator=(const decorated_type& val) {this->vq3_value = val;}
247  };
248 
249  // When we decorate a non decorated value.
250  template<typename MOTHER>
251  struct Tagged<MOTHER, not_decorated> {
252  using decorated_type = MOTHER;
253  MOTHER vq3_value;
254  bool vq3_tag = false;
255  Tagged() = default;
256  Tagged(const Tagged&) = default;
257  Tagged(const decorated_type& val) : vq3_value(val), vq3_tag(false) {}
258  Tagged& operator=(const decorated_type& val) {vq3_value = val;}
259  };
260 
261  // When we decorate a decorated type with no value.
262  template<typename MOTHER>
263  struct Tagged<MOTHER, unvalued_decoration> : public MOTHER {
264  using decorated_type = MOTHER;
265  bool vq3_tag = false;
266  Tagged() : MOTHER(), vq3_tag(false) {}
267  Tagged(const Tagged&) = default;
268  };
269 
270  // When we decorate void.
271  template<>
272  struct Tagged<void, not_decorated> {
273  using decorated_type = void;
274  bool vq3_tag = false;
275  Tagged() : vq3_tag(false) {}
276  Tagged(const Tagged&) = default;
277  };
278 
279  template<typename MOTHER>
281 
282 
283  /* ########### */
284  /* # # */
285  /* # Counter # */
286  /* # # */
287  /* ########### */
288 
289  template<typename MOTHER, typename KIND>
290  struct Counter : public MOTHER {
291  using decorated_type = typename MOTHER::decorated_type;
292  std::atomic_size_t vq3_counter = 0;
293  Counter() = default;
294  Counter(const Counter& other) : MOTHER(other), vq3_counter(0) {}
295  Counter(const decorated_type& val) : MOTHER(val), vq3_counter(0) {}
296  Counter& operator=(const decorated_type& val) {this->vq3_value = val;}
297  };
298 
299  // When we decorate a non decorated value.
300  template<typename MOTHER>
301  struct Counter<MOTHER, not_decorated> {
302  using decorated_type = MOTHER;
303  MOTHER vq3_value;
304  std::atomic_size_t vq3_counter = 0;
305  Counter() = default;
306  // The default definition for copy constructor fails with the
307  // deleted copy contructor of atomic.
308  Counter(const Counter& other) : vq3_value(other.vq3_value), vq3_counter(0){}
309  Counter(const decorated_type& val) : vq3_value(val), vq3_counter(0) {}
310  Counter& operator=(const decorated_type& val) {vq3_value = val;}
311  };
312 
313  // When we decorate a decorated type with no value.
314  template<typename MOTHER>
315  struct Counter<MOTHER, unvalued_decoration> : public MOTHER {
316  using decorated_type = MOTHER;
317  std::atomic_size_t vq3_counter = 0;
318  Counter() : MOTHER(), vq3_counter(0) {}
319  Counter(const Counter& other) : MOTHER(other), vq3_counter(0) {}
320  };
321 
322  // When we decorate void.
323  template<>
324  struct Counter<void, not_decorated> {
325  using decorated_type = void;
326  std::atomic_size_t vq3_counter = 0;
327  Counter() : vq3_counter(0) {}
328  Counter(const Counter& other) : vq3_counter(0) {}
329  };
330 
331  template<typename MOTHER>
333 
334  /* ######## */
335  /* # # */
336  /* # Cost # */
337  /* # # */
338  /* ######## */
339 
340  template<typename MOTHER, typename COST_TYPE, typename KIND>
341  struct Cost : public MOTHER {
342  using decorated_type = typename MOTHER::decorated_type;
343  COST_TYPE vq3_cost;
344  Cost() = default;
345  Cost(const Cost&) = default;
346  Cost(const decorated_type& val) : MOTHER(val), vq3_cost() {}
347  Cost& operator=(const decorated_type& val) {this->vq3_value = val;}
348  };
349 
350  // When we decorate a non decorated value.
351  template<typename MOTHER, typename COST_TYPE>
352  struct Cost<MOTHER, COST_TYPE, not_decorated> {
353  using decorated_type = MOTHER;
354  MOTHER vq3_value;
355  COST_TYPE vq3_cost;
356  Cost() = default;
357  Cost(const Cost&) = default;
358  Cost(const decorated_type& val) : vq3_value(val), vq3_cost() {}
359  Cost& operator=(const decorated_type& val) {vq3_value = val;}
360  };
361 
362  // When we decorate a decorated type with no value.
363  template<typename MOTHER, typename COST_TYPE>
364  struct Cost<MOTHER, COST_TYPE, unvalued_decoration> : public MOTHER {
365  using decorated_type = MOTHER;
366  COST_TYPE vq3_cost;
367  Cost() : MOTHER(), vq3_cost() {}
368  Cost(const Cost&) = default;
369  };
370 
371  // When we decorate void.
372  template<typename COST_TYPE>
373  struct Cost<void, COST_TYPE, not_decorated> {
374  using decorated_type = void;
375  COST_TYPE vq3_cost;
376  Cost() : vq3_cost() {}
377  Cost(const Cost&) = default;
378  };
379 
380  template<typename MOTHER, typename COST_TYPE>
382 
383 
384  /* ############ */
385  /* # # */
386  /* # Labelled # */
387  /* # # */
388  /* ############ */
389 
390  template<typename MOTHER, typename KIND>
391  struct Labelled : public MOTHER {
392  using decorated_type = typename MOTHER::decorated_type;
393  unsigned int vq3_label = 0;
394  Labelled() = default;
395  Labelled(const Labelled&) = default;
396  Labelled(const decorated_type& val) : MOTHER(val), vq3_label(0) {}
397  Labelled& operator=(const decorated_type& val) {this->vq3_value = val;}
398  };
399 
400  // When we decorate a non decorated value.
401  template<typename MOTHER>
402  struct Labelled<MOTHER, not_decorated> {
403  using decorated_type = MOTHER;
404  MOTHER vq3_value;
405  unsigned int vq3_label = 0;
406  Labelled() = default;
407  Labelled(const Labelled&) = default;
408  Labelled(const decorated_type& val) : vq3_value(val), vq3_label(0) {}
409  Labelled& operator=(const decorated_type& val) {vq3_value = val;}
410  };
411 
412  // When we decorate a decorated type with no value.
413  template<typename MOTHER>
414  struct Labelled<MOTHER, unvalued_decoration> : public MOTHER {
415  using decorated_type = MOTHER;
416  unsigned int vq3_label = 0;
417  Labelled() : MOTHER(), vq3_label(0) {}
418  Labelled(const Labelled&) = default;
419  };
420 
421  // When we decorate void.
422  template<>
423  struct Labelled<void, not_decorated> {
424  using decorated_type = void;
425  unsigned int vq3_label = 0;
426  Labelled() : vq3_label(0) {}
427  Labelled(const Labelled&) = default;
428  };
429 
430  template<typename MOTHER>
432 
433  /* ############## */
434  /* # # */
435  /* # Efficiency # */
436  /* # # */
437  /* ############## */
438 
439 
440  template<typename MOTHER, typename KIND>
441  struct Efficiency : public MOTHER {
442  using decorated_type = typename MOTHER::decorated_type;
443  bool vq3_efficient = true;
444  Efficiency() = default;
445  Efficiency(const Efficiency&) = default;
446  Efficiency(const decorated_type& val) : MOTHER(val), vq3_efficient(true) {}
447  Efficiency& operator=(const decorated_type& val) {this->vq3_value = val;}
448  };
449 
450  // When we decorate a non decorated value.
451  template<typename MOTHER>
452  struct Efficiency<MOTHER, not_decorated> {
453  using decorated_type = MOTHER;
454  MOTHER vq3_value;
455  bool vq3_efficient = true;
456  Efficiency() = default;
457  Efficiency(const Efficiency&) = default;
458  Efficiency(const decorated_type& val) : vq3_value(val), vq3_efficient(true) {}
459  Efficiency& operator=(const decorated_type& val) {vq3_value = val;}
460  };
461 
462  // When we decorate a decorated type with no value.
463  template<typename MOTHER>
464  struct Efficiency<MOTHER, unvalued_decoration> : public MOTHER {
465  using decorated_type = MOTHER;
466  bool vq3_efficient = true;
467  Efficiency() : MOTHER(), vq3_efficient(true) {}
468  Efficiency(const Efficiency&) = default;
469  };
470 
471  // When we decorate void.
472  template<>
473  struct Efficiency<void, not_decorated> {
474  using decorated_type = void;
475  bool vq3_efficient = true;
476  Efficiency() : vq3_efficient(true) {}
477  Efficiency(const Efficiency&) = default;
478  };
479 
480  template<typename MOTHER>
482 
483 
484  /* ######## */
485  /* # # */
486  /* # Text # */
487  /* # # */
488  /* ######## */
489 
490 
491  template<typename MOTHER, typename KIND>
492  struct Text : public MOTHER {
493  using decorated_type = typename MOTHER::decorated_type;
494  std::string vq3_text;
495  Text() = default;
496  Text(const Text&) = default;
497  Text(const decorated_type& val) : MOTHER(val), vq3_text() {}
498  Text& operator=(const decorated_type& val) {this->vq3_value = val;}
499  };
500 
501  // When we decorate a non decorated value.
502  template<typename MOTHER>
503  struct Text<MOTHER, not_decorated> {
504  using decorated_type = MOTHER;
505  MOTHER vq3_value;
506  std::string vq3_text;
507  Text() = default;
508  Text(const Text&) = default;
509  Text(const decorated_type& val) : vq3_value(val), vq3_text() {}
510  Text& operator=(const decorated_type& val) {vq3_value = val;}
511  };
512 
513  // When we decorate a decorated type with no value.
514  template<typename MOTHER>
515  struct Text<MOTHER, unvalued_decoration> : public MOTHER {
516  using decorated_type = MOTHER;
517  std::string vq3_text;
518  Text() : MOTHER(), vq3_text() {}
519  Text(const Text&) = default;
520  };
521 
522  // When we decorate void.
523  template<>
524  struct Text<void, not_decorated> {
525  using decorated_type = void;
526  std::string vq3_text;
527  Text() : vq3_text() {}
528  Text(const Text&) = default;
529  };
530 
531  template<typename MOTHER>
533 
534 
535  /* ####### */
536  /* # # */
537  /* # Sum # */
538  /* # # */
539  /* ####### */
540 
541  template<typename MOTHER, typename INCREMENTABLE, typename KIND>
542  struct Sum : public MOTHER {
543  using decorated_type = typename MOTHER::decorated_type;
545  Sum() = default;
546  Sum(const Sum&) = default;
547  Sum(const decorated_type& val) : MOTHER(val), vq3_sum() {}
548  Sum& operator=(const decorated_type& val) {this->vq3_value = val;}
549  };
550 
551  // When we decorate a non decorated value.
552  template<typename MOTHER, typename INCREMENTABLE>
553  struct Sum<MOTHER, INCREMENTABLE, not_decorated> {
554  using decorated_type = MOTHER;
555  MOTHER vq3_value;
557  Sum() = default;
558  Sum(const Sum&) = default;
559  Sum(const decorated_type& val) : vq3_value(val), vq3_sum() {}
560  Sum& operator=(const decorated_type& val) {vq3_value = val;}
561  };
562 
563  // When we decorate a decorated type with no value.
564  template<typename MOTHER, typename INCREMENTABLE>
565  struct Sum<MOTHER, INCREMENTABLE, unvalued_decoration> : public MOTHER {
566  using decorated_type = MOTHER;
568  Sum() : MOTHER(), vq3_sum() {}
569  Sum(const Sum&) = default;
570  };
571 
572  // When we decorate void.
573  template<typename INCREMENTABLE>
574  struct Sum<void, INCREMENTABLE, not_decorated> {
575  using decorated_type = void;
577  Sum() : vq3_sum() {}
578  Sum(const Sum&) = default;
579  };
580 
581  template<typename MOTHER, typename INCREMENTABLE>
583 
584 
585  /* ########### */
586  /* # # */
587  /* # GridPos # */
588  /* # # */
589  /* ########### */
590 
591  template<typename MOTHER, typename KIND>
592  struct GridPos : public MOTHER {
593  using decorated_type = typename MOTHER::decorated_type;
594  std::pair<unsigned int, unsigned int> vq3_gridpos = {0, 0};
595  GridPos() = default;
596  GridPos(const GridPos&) = default;
597  GridPos(const decorated_type& val) : MOTHER(val), vq3_gridpos({0, 0}) {}
598  GridPos& operator=(const decorated_type& val) {this->vq3_value = val;}
599  };
600 
601  // When we decorate a non decorated value.
602  template<typename MOTHER>
603  struct GridPos<MOTHER, not_decorated> {
604  using decorated_type = MOTHER;
605  MOTHER vq3_value;
606  std::pair<unsigned int, unsigned int> vq3_gridpos = {0, 0};
607  GridPos() = default;
608  GridPos(const GridPos&) = default;
609  GridPos(const decorated_type& val) : vq3_value(val), vq3_gridpos({0, 0}) {}
610  GridPos& operator=(const decorated_type& val) {vq3_value = val;}
611  };
612 
613  // When we decorate a decorated type with no value.
614  template<typename MOTHER>
615  struct GridPos<MOTHER, unvalued_decoration> : public MOTHER {
616  using decorated_type = MOTHER;
617  std::pair<unsigned int, unsigned int> vq3_gridpos = {0, 0};
618  GridPos() : MOTHER(), vq3_gridpos({0, 0}) {}
619  GridPos(const GridPos&) = default;
620  };
621 
622  // When we decorate void.
623  template<>
624  struct GridPos<void, not_decorated> {
625  using decorated_type = void;
626  std::pair<unsigned int, unsigned int> vq3_gridpos = {0, 0};
627  GridPos() : vq3_gridpos({0, 0}) {}
628  GridPos(const GridPos&) = default;
629  };
630 
631  template<typename MOTHER>
633 
634 
635 
636 
637  /* ############ */
638  /* # # */
639  /* # Smoother # */
640  /* # # */
641  /* ############ */
642 
643 
644 
645  template<typename MOTHER, typename VALUE, unsigned int SAVITZKY_GOLAY_ORDER, unsigned int SAVITZKY_GOLAY_WINDOW_SIZE, unsigned int SAVITZKY_GOLAY_DEGREE, typename KIND>
646  struct Smoother : public MOTHER {
647  using decorated_type = typename MOTHER::decorated_type;
649  Smoother() = default;
650  Smoother(const Smoother&) = default;
651  Smoother(const decorated_type& val) : MOTHER(val), vq3_smoother() {}
652  Smoother& operator=(const decorated_type& val) {this->vq3_value = val;}
653  };
654 
655  // When we decorate a non decorated value.
656  template<typename MOTHER, typename VALUE, unsigned int SAVITZKY_GOLAY_ORDER, unsigned int SAVITZKY_GOLAY_WINDOW_SIZE, unsigned int SAVITZKY_GOLAY_DEGREE>
657  struct Smoother<MOTHER, VALUE, SAVITZKY_GOLAY_ORDER, SAVITZKY_GOLAY_WINDOW_SIZE, SAVITZKY_GOLAY_DEGREE, not_decorated> {
658  using decorated_type = MOTHER;
659  MOTHER vq3_value;
661  Smoother() = default;
662  Smoother(const Smoother&) = default;
663  Smoother(const decorated_type& val) : vq3_value(val), vq3_smoother() {}
664  Smoother& operator=(const decorated_type& val) {vq3_value = val;}
665  };
666 
667  // When we decorate a decorated type with no value.
668  template<typename MOTHER, typename VALUE, unsigned int SAVITZKY_GOLAY_ORDER, unsigned int SAVITZKY_GOLAY_WINDOW_SIZE, unsigned int SAVITZKY_GOLAY_DEGREE>
669  struct Smoother<MOTHER, VALUE, SAVITZKY_GOLAY_ORDER, SAVITZKY_GOLAY_WINDOW_SIZE, SAVITZKY_GOLAY_DEGREE, unvalued_decoration> : public MOTHER {
670  using decorated_type = MOTHER;
672  Smoother() : MOTHER(), vq3_smoother() {}
673  Smoother(const Smoother&) = default;
674  };
675 
676  // When we decorate void.
677  template<typename VALUE, unsigned int SAVITZKY_GOLAY_ORDER, unsigned int SAVITZKY_GOLAY_WINDOW_SIZE, unsigned int SAVITZKY_GOLAY_DEGREE>
678  struct Smoother<void, VALUE, SAVITZKY_GOLAY_ORDER, SAVITZKY_GOLAY_WINDOW_SIZE, SAVITZKY_GOLAY_DEGREE, not_decorated> {
679  using decorated_type = void;
681  Smoother() : vq3_smoother() {}
682  Smoother(const Smoother&) = default;
683  };
684 
685  template<typename MOTHER, typename VALUE, unsigned int SAVITZKY_GOLAY_ORDER, unsigned int SAVITZKY_GOLAY_WINDOW_SIZE, unsigned int SAVITZKY_GOLAY_DEGREE>
687 
688 
689  /* ########## */
690  /* # # */
691  /* # Custom # */
692  /* # # */
693  /* ########## */
694 
695  template<typename MOTHER, typename CUSTOM_TYPE, typename KIND>
696  struct Custom : public MOTHER {
697  using decorated_type = typename MOTHER::decorated_type;
698  CUSTOM_TYPE vq3_custom;
699  Custom() = default;
700  Custom(const Custom&) = default;
701  Custom(const decorated_type& val) : MOTHER(val), vq3_custom() {}
702  Custom& operator=(const decorated_type& val) {this->vq3_value = val;}
703  };
704 
705  // When we decorate a non decorated value.
706  template<typename MOTHER, typename CUSTOM_TYPE>
707  struct Custom<MOTHER, CUSTOM_TYPE, not_decorated> {
708  using decorated_type = MOTHER;
709  MOTHER vq3_value;
710  CUSTOM_TYPE vq3_custom;
711  Custom() = default;
712  Custom(const Custom&) = default;
713  Custom(const decorated_type& val) : vq3_value(val), vq3_custom() {}
714  Custom& operator=(const decorated_type& val) {vq3_value = val;}
715  };
716 
717  // When we decorate a decorated type with no value.
718  template<typename MOTHER, typename CUSTOM_TYPE>
719  struct Custom<MOTHER, CUSTOM_TYPE, unvalued_decoration> : public MOTHER {
720  using decorated_type = MOTHER;
721  CUSTOM_TYPE vq3_custom;
722  Custom() : MOTHER(), vq3_custom() {}
723  Custom(const Custom&) = default;
724  };
725 
726  // When we decorate void.
727  template<typename CUSTOM_TYPE>
728  struct Custom<void, CUSTOM_TYPE, not_decorated> {
729  using decorated_type = void;
730  CUSTOM_TYPE vq3_custom;
731  Custom() : vq3_custom() {}
732  Custom(const Custom&) = default;
733  };
734 
735  template<typename MOTHER, typename CUSTOM_TYPE>
737  }
738 
739  namespace decorator {
740  namespace online {
741 
742  /* ##################### */
743  /* # # */
744  /* # Mean/Std (online) # */
745  /* # # */
746  /* ##################### */
747 
748  template<typename MOTHER, typename VALUE, typename ONLINE_PARAM, typename KIND>
749  struct MeanStd : public MOTHER {
750  using decorated_type = typename MOTHER::decorated_type;
752  MeanStd() = default;
753  MeanStd(const MeanStd&) = default;
754  MeanStd(const decorated_type& val) : MOTHER(val), vq3_online_mean_std() {}
755  MeanStd& operator=(const decorated_type& val) {this->vq3_value = val;}
756  };
757 
758  // When we decorate a non decorated value.
759  template<typename MOTHER, typename VALUE, typename ONLINE_PARAM>
760  struct MeanStd<MOTHER, VALUE, ONLINE_PARAM, vq3::decorator::not_decorated> {
761  using decorated_type = MOTHER;
762  MOTHER vq3_value;
764  MeanStd() = default;
765  MeanStd(const MeanStd&) = default;
766  MeanStd(const decorated_type& val) : vq3_value(val), vq3_online_mean_std() {}
767  MeanStd& operator=(const decorated_type& val) {vq3_value = val;}
768  };
769 
770  // When we decorate a decorated type with no value.
771  template<typename MOTHER, typename VALUE, typename ONLINE_PARAM>
772  struct MeanStd<MOTHER, VALUE, ONLINE_PARAM, vq3::decorator::unvalued_decoration> : public MOTHER {
773  using decorated_type = MOTHER;
775  MeanStd() : MOTHER(), vq3_online_mean_std() {}
776  MeanStd(const MeanStd&) = default;
777  };
778 
779  // When we decorate void.
780  template<typename VALUE, typename ONLINE_PARAM>
781  struct MeanStd<void, VALUE, ONLINE_PARAM, vq3::decorator::not_decorated> {
782  using decorated_type = void;
784  MeanStd() : vq3_online_mean_std() {}
785  MeanStd(const MeanStd&) = default;
786  };
787 
788  template<typename MOTHER, typename VALUE, typename ONLINE_PARAM>
790  }
791  }
792 }
vq3::decorator::has_value
Definition: vq3Decorator.hpp:72
vq3::decorator::Custom
Definition: vq3Decorator.hpp:696
vq3::decorator::valued_decoration
Definition: vq3Decorator.hpp:59
vq3::decorator::Smoother
Definition: vq3Decorator.hpp:646
vq3::spec::Decorator::vq3_the_decoration
bool vq3_the_decoration
Definition: vq3Decorator.hpp:109
vq3::spec::Decorator< void, vq3::decorator::not_decorated >::Decorator
Decorator()
Definition: vq3Decorator.hpp:169
vq3::spec::Decorator
Definition: vq3Decorator.hpp:105
vq3::decorator::decoration
Definition: vq3Decorator.hpp:80
vq3::decorator::Labelled
Definition: vq3Decorator.hpp:391
vq3::spec::Decorator< MOTHER, vq3::decorator::not_decorated >::vq3_value
MOTHER vq3_value
Definition: vq3Decorator.hpp:132
vq3::utils::savitzky_golay::constant_timestep::estimator< VALUE, SAVITZKY_GOLAY_ORDER, SAVITZKY_GOLAY_WINDOW_SIZE, SAVITZKY_GOLAY_DEGREE >
vq3::spec::Decorator::Decorator
Decorator()=default
vq3::decorator::not_decorated
Definition: vq3Decorator.hpp:49
vq3::decorator::Sum
Definition: vq3Decorator.hpp:542
vq3::decorator::is_decorated
Definition: vq3Decorator.hpp:70
vq3::spec::Decorator::decorated_type
typename MOTHER::decorated_type decorated_type
Definition: vq3Decorator.hpp:107
vq3::decorator::GridPos
Definition: vq3Decorator.hpp:592
vq3::decorator::None
Definition: vq3Decorator.hpp:194
vq3::decorator::Counter
Definition: vq3Decorator.hpp:290
vq3::decorator::print
Definition: vq3Decorator.hpp:84
vq3::spec::Decorator< MOTHER, vq3::decorator::not_decorated >::operator=
Decorator & operator=(const decorated_type &val)
Definition: vq3Decorator.hpp:143
vq3::decorator::Cost
Definition: vq3Decorator.hpp:341
vq3::decorator::online::MeanStd
Definition: vq3Decorator.hpp:749
vq3::spec::Decorator< MOTHER, vq3::decorator::not_decorated >::decorated_type
MOTHER decorated_type
Definition: vq3Decorator.hpp:130
vq3::decorator::Efficiency
Definition: vq3Decorator.hpp:441
vq3::decorator::decoration_kind
Definition: vq3Decorator.hpp:64
vq3::spec::Decorator::Decorator
Decorator(const decorated_type &val)
Definition: vq3Decorator.hpp:118
vq3::spec::Decorator< MOTHER, vq3::decorator::unvalued_decoration >::decorated_type
MOTHER decorated_type
Definition: vq3Decorator.hpp:152
vq3::utils::accum< INCREMENTABLE, double >
vq3::decorator::Tagged
Definition: vq3Decorator.hpp:240
vq3::spec::Decorator< MOTHER, vq3::decorator::unvalued_decoration >::Decorator
Decorator()
Definition: vq3Decorator.hpp:156
vq3::decorator::unvalued_decoration
Definition: vq3Decorator.hpp:54
vq3::decorator::Text
Definition: vq3Decorator.hpp:492
vq3::stats::online::MeanStd
Definition: vq3Stats.hpp:222
vq3::spec::Decorator::operator=
Decorator & operator=(const decorated_type &val)
Definition: vq3Decorator.hpp:121
vq3::spec::Decorator< MOTHER, vq3::decorator::not_decorated >::Decorator
Decorator(const decorated_type &val)
Definition: vq3Decorator.hpp:141
vq3::spec::Decorator< void, vq3::decorator::not_decorated >::decorated_type
void decorated_type
Definition: vq3Decorator.hpp:165