elementFormulaRCP.hh

Go to the documentation of this file.
1 
8 #ifndef elementformulaRCP_hh
9 #define elementformulaRCP_hh
10 
11 #if __cplusplus>=201103L
12 #include "elementFormulaRCP_std.hh"
13 
14 #else
16 
17 #endif
18 
19 
20 
21 // #include "toolbox/sharedPointer.hh"
22 // #include "elementFormula.hh"
23 // #include "formula.hh"
24 // #include "constFormula.hh"
25 
26 // #define ElemFormRCPClone_D 0
27 // #define ElemFormRCPValue_D 0
28 // #define FormRCPClone_D 0
29 // #define FormRCPValue_D 0
30 
31 // namespace concepts {
32 
33 
34 // // ***************************************** RCP<const ElementFormula<F,G> > **
35 
36 // template<class F, typename G>
37 // class RCP<const ElementFormula<F,G> >
38 // : public boost::shared_ptr<const ElementFormula<F,G> >
39 // {
40 // public:
41 // /** Special constructor for a constant.
42 
43 // So, a constant can simply given to functions where a
44 // RCP<ElementFormula<F> > is expected.
45 
46 // @see testsuite/testFormula.cc
47 // */
48 // explicit RCP(const F x)
49 // : boost::shared_ptr<const ElementFormula<F,G> >
50 // (new const ConstFormula<F>(x)) {}
51 
52 // /// Default constructor, creates an RCP to a NULL-pointer
53 // RCP() : boost::shared_ptr<const ElementFormula<F,G> >() {}
54 
55 // // this conversion operator is already implemented for shared_ptr
56 // #if 0
57 // // implicit conversion ops.
58 // template<class OldF, class OldG>
59 // RCP(RCP< const ElementFormula<OldF,OldG> > old)
60 // : boost::shared_ptr<const ElementFormula<F,G> >( old )
61 // {
62 // }
63 // #endif
64 
65 // /** Constructor for a simple pointer to ElementFormula, which will
66 // be deleted by the RCP.
67 
68 // It should be only called with pointer to dynamic variables, e.g.
69 // <pre>RCP<const ElementFormula<Real> > p(new ConstFormula<Real>(4));</pre>
70 
71 // Do NOT use it with pointers to variables in the stack. Do not
72 // <pre>ConstFormula<Real> i = 4;
73 // RCP<const ElementFormula<Real> > p(&i); // <-- DO NOT -- </pre>
74 
75 // Instead use the constructor for references (below) which makes a clone.
76 // */
77 // explicit RCP(const ElementFormula<F,G>* x)
78 // : boost::shared_ptr<const ElementFormula<F,G> >(x) {}
79 
80 // /// conversion constructor from boost::shared_ptr
81 // RCP(boost::shared_ptr<const ElementFormula<F,G> >& x)
82 // : boost::shared_ptr<const ElementFormula<F,G> >(x) {}
83 
84 // /// conversion constructor from boost::shared_ptr<H>, where H can
85 // /// be converted into ElementFormula<F,G>
86 // template<class H>
87 // RCP(const boost::shared_ptr<H>& x)
88 // : boost::shared_ptr<const ElementFormula<F,G> >(x) {}
89 
90 // /// Constructor with any two parameters, I is a deleter function
91 // template<class H, class I>
92 // RCP(H x, I y) : boost::shared_ptr<const ElementFormula<F,G> >(x, y) {}
93 
94 // /// Constructor with a given reference,
95 // /// ElementFormula will be cloned.
96 // ///
97 // /// @BEWARE: this function is slightly inefficient (a copy is created),
98 // // but more importantly it is severely prone to errors.
99 // /// @obsolete: try to write code which does NOT depend on this function,
100 // // this functions tells C++ to convert any const
101 // // reference to ElementFormulas AUTOMATICALLY into
102 // // RCP<ElementFormula>. In particular this strip of code
103 // // equates EF-References with EF-SmartPointer, so it equates
104 // // references with pointers. I do not know which side effects
105 // // this strip of code can create, but expect severe ones!
106 // //explicit RCP(const ElementFormula<F,G>& x)
107 // RCP(const ElementFormula<F,G>& x)
108 // : boost::shared_ptr<const ElementFormula<F,G> >(x.clone())
109 // {
110 // DEBUGL(ElemFormRCPClone_D, "Cloned " << **this << " = *" << *this);
111 // }
112 
113 // RCP<const ElementFormula<F,G> >&
114 // operator=(const RCP<const ElementFormula<F,G> >& x)
115 // {
116 // RCP<const ElementFormula<F,G> >(x).swap(*this);
117 // return *this;
118 // }
119 
120 // template<class H>
121 // RCP<const ElementFormula<F,G> >&
122 // operator=(const RCP<H>& x)
123 // {
124 // RCP<const ElementFormula<F,G> >(x).swap(*this);
125 // return *this;
126 // }
127 
128 // #if ElemFormRCPValue_D
129 // // for debugging in case of zero pointers: output of pointer
130 // const ElementFormula<F,G>& operator* () const // never throws
131 // {
132 // DEBUGL(1, *this);
133 // return boost::shared_ptr<const ElementFormula<F,G> >(*this).operator*();
134 // }
135 // #endif
136 // };
137 
138 
139 // // ************************************************ RCP<const Formula<F,G> > **
140 
141 // template<class F>
142 // class RCP<const Formula<F> > : public boost::shared_ptr<const Formula<F> >
143 // {
144 // public:
145 // /** Special constructor for a constant.
146 
147 // So, a constant can simply given to functions where a
148 // RCP<ElementFormula<F> > is expected.
149 
150 // @see testsuite/testFormula.cc
151 // */
152 // explicit RCP(const F x)
153 // : boost::shared_ptr<const Formula<F> >(new const ConstFormula<F>(x)) {}
154 
155 // /// Default constructor
156 // RCP() : boost::shared_ptr<const Formula<F> >() {}
157 
158 // /** Constructor for a simple pointer to ElementFormula, which will
159 // be deleted by the RCP.
160 
161 // It should be only called with pointer to dynamic variables, e.g.
162 // <pre>RCP<const ElementFormula<Real> > p(new ConstFormula<Real>(4));</pre>
163 
164 // Do NOT use it with pointers to variables in the stack. Do not
165 // <pre>ConstFormula<Real> i = 4;
166 // RCP<const ElementFormula<Real> > p(&i); // <-- DO NOT -- </pre>
167 
168 // Instead use the constructor for references (below) which makes a clone.
169 // */
170 // explicit RCP(const Formula<F>* x)
171 // : boost::shared_ptr<const Formula<F> >(x) {}
172 
173 // RCP(boost::shared_ptr<const Formula<F> >& x)
174 // : boost::shared_ptr<const Formula<F> >(x) {}
175 
176 // template<class H>
177 // RCP(const boost::shared_ptr<H>& x)
178 // : boost::shared_ptr<const Formula<F> >(x) {}
179 
180 // /// Constructor with any two parameters
181 // template<class H, class I>
182 // RCP(H x, I y) : boost::shared_ptr<const Formula<F> >(x, y) {}
183 
184 // /// Constructor with a given reference,
185 // /// ElementFormula will be cloned.
186 // ///
187 // /// @BEWARE: this function is slightly inefficient (a copy is created),
188 // // but more importantly it is severely prone to errors.
189 // /// @obsolete: try to write code which does NOT depend on this function,
190 // // this functions tells C++ to convert any const
191 // // reference to ElementFormulas AUTOMATICALLY into
192 // // RCP<ElementFormula>. In particular this strip of code
193 // // equates EF-References with EF-SmartPointer, so it equates
194 // // references with pointers. I do not know which side effects
195 // // this strip of code can create, but expect severe ones!
196 // explicit RCP(const Formula<F>& x) : boost::shared_ptr<const Formula<F> >(x.clone())
197 // {
198 // DEBUGL(FormRCPClone_D, "Cloned " << **this << " = *" << *this);
199 // }
200 
201 // RCP<const Formula<F> >&
202 // operator=(const RCP<const Formula<F> >& x)
203 // {
204 // RCP<const Formula<F> >(x).swap(*this);
205 // return *this;
206 // }
207 
208 // template<class H>
209 // RCP<const Formula<F> >&
210 // operator=(const RCP<H>& x)
211 // {
212 // RCP<const Formula<F> >(x).swap(*this);
213 // return *this;
214 // }
215 
216 // #if FormRCPValue_D
217 // // for debugging in case of zero pointers: output of pointer
218 // const Formula<F>& operator* () const // never throws
219 // {
220 // DEBUGL(1, *this);
221 // return boost::shared_ptr<const Formula<F> >(*this).operator*();
222 // }
223 // #endif
224 
225 // };
226 
227 
228 // } // namespace concepts
229 
230 
231 #endif // elementformulaRCP_hh
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich