BinaryRule.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2004 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/MEAL/MEAL/BinaryRule.h
10 
11 #ifndef __MEAL_BinaryRule_H
12 #define __MEAL_BinaryRule_H
13 
14 #include "MEAL/Projection.h"
15 #include "MEAL/Composite.h"
16 
17 namespace MEAL {
18 
20  template<class T>
21  class BinaryRule : public T
22  {
23 
24  public:
25 
27  BinaryRule () : composite(this) { }
28 
30  BinaryRule (const BinaryRule& rule) : composite(this) { operator=(rule); }
31 
33  BinaryRule& operator = (const BinaryRule& rule);
34 
36  ~BinaryRule () { }
37 
39  void set_arg1 (T* model);
40 
42  void set_arg2 (T* model);
43 
44  protected:
45 
48 
51 
52  private:
53 
55  Composite composite;
56 
57  };
58 
59 }
60 
61 template<class T>
64 {
65  if (this == &rule)
66  return *this;
67 
68  set_arg1 (rule.arg1);
69  set_arg2 (rule.arg2);
70 
71  return *this;
72 }
73 
74 
75 template<class T>
77 {
78  if (arg1)
79  composite.unmap (arg1);
80 
81  arg1 = model;
82 
83  if (!model)
84  return;
85 
86  if (T::verbose)
87  std::cerr << "MEAL::BinaryRule::set_model map new model" << std::endl;
88 
89  composite.map (arg1);
90 }
91 
92 template<class T>
94 {
95  if (arg2)
96  composite.unmap (arg2);
97 
98  arg2 = model;
99 
100  if (!model)
101  return;
102 
103  if (T::verbose)
104  std::cerr << "MEAL::BinaryRule::set_model map new model" << std::endl;
105 
106  composite.map (arg2);
107 }
108 
109 
110 #endif
void set_arg1(T *model)
Set the first argument to the binary operation.
Definition: BinaryRule.h:76
Abstract base class of binary operators.
Definition: BinaryRule.h:26
BinaryRule()
Default constructor.
Definition: BinaryRule.h:37
Parameter policy for composite functions.
Definition: Composite.h:25
Namespace in which all modeling and calibration related code is declared.
Definition: ExampleComplex2.h:16
Project< T > arg2
The first argument to the binary operation.
Definition: BinaryRule.h:60
~BinaryRule()
Destructor.
Definition: BinaryRule.h:46
Project< T > arg1
The first argument to the binary operation.
Definition: BinaryRule.h:57
BinaryRule & operator=(const BinaryRule &rule)
Assignment operator.
Definition: BinaryRule.h:63
void set_arg2(T *model)
Set the second argument to the binary operation.
Definition: BinaryRule.h:93

Generated using doxygen 1.8.17